Package org.apache.oro.text.regex

Examples of org.apache.oro.text.regex.Perl5Compiler


        if (result != null)
            return result;

        if (_compiler == null)
            _compiler = new Perl5Compiler();

        try
        {
            result = _compiler.compile(pattern, Perl5Compiler.MULTILINE_MASK);
View Full Code Here


    }

    public JMeterProperty transformValue(JMeterProperty prop) throws InvalidVariableException {
        PatternMatcher pm = JMeterUtils.getMatcher();
        Pattern pattern = null;
        PatternCompiler compiler = new Perl5Compiler();
        String input = prop.getStringValue();
        if(input == null) {
            return prop;
        }
        for(Entry<String, String> entry : getVariables().entrySet()){
            String key = entry.getKey();
            String value = entry.getValue();
            if (regexMatch) {
                try {
                    pattern = compiler.compile("\\b("+value+")\\b");
                    input = Util.substitute(pm, pattern,
                            new StringSubstitution(FUNCTION_REF_PREFIX + key + FUNCTION_REF_SUFFIX),
                            input, Util.SUBSTITUTE_ALL);
                } catch (MalformedPatternException e) {
                    log.warn("Malformed pattern " + value);
View Full Code Here

    }

    public JMeterProperty transformValue(JMeterProperty prop) throws InvalidVariableException {
        PatternMatcher pm = JMeterUtils.getMatcher();
        Pattern pattern = null;
        PatternCompiler compiler = new Perl5Compiler();
        String input = prop.getStringValue();
        for(Entry<String, String> entry : getVariables().entrySet()){
            String key = entry.getKey();
            String value = entry.getValue();
            if (regexMatch) {
                try {
                    pattern = compiler.compile(value);
                    input = Util.substitute(pm, pattern,
                            new StringSubstitution(FUNCTION_REF_PREFIX + key + FUNCTION_REF_SUFFIX),
                            input, Util.SUBSTITUTE_ALL);
                } catch (MalformedPatternException e) {
                    log.warn("Malformed pattern " + value);
View Full Code Here

  /**
   * Compiles the supplied pattern sources into a {@link Pattern} array.
   */
  private Pattern[] compilePatterns(String[] source) {
    Perl5Compiler compiler = new Perl5Compiler();
    Pattern[] destination = new Pattern[source.length];
    for (int i = 0; i < source.length; i++) {
      // compile the pattern to be thread-safe
      try {
        destination[i] = compiler.compile(source[i], Perl5Compiler.READ_ONLY_MASK);
      }
      catch (MalformedPatternException ex) {
        throw new IllegalArgumentException(ex.getMessage());
      }
    }
View Full Code Here

     */
    public void setMask(String mask)
            throws InvalidMaskException
    {
        /** perl5 compiler, needed for setting up the masks */
        Perl5Compiler patternCompiler = new Perl5Compiler();

        maskString = mask;

        // Fixme. We should make this configureable by the XML file -- hps
        int maskOptions = Perl5Compiler.DEFAULT_MASK;

        try
        {
            log.debug("Compiling pattern " + maskString);
            maskPattern = patternCompiler.compile(maskString, maskOptions);
        }
        catch (MalformedPatternException mpe)
        {
            throw new InvalidMaskException("Could not compile pattern " + maskString, mpe);
        }
View Full Code Here

  public Object construct() {
    int i;
    boolean[] sel = param.getVarSelected();
    FileWriter w = null;
    PatternMatcherInput input = new PatternMatcherInput("");
    Perl5Compiler myComp = new Perl5Compiler();
    Perl5Matcher myMatch = new Perl5Matcher();
    String line = "";
    String[] regExp = param.getRegularExp();
    String[] separator = param.getSeparator();
    double[] lineValue = new double[param.getNumVarSelected()];
    String[] lineToken = new String[param.getNumVar()];
    String parseToken = null;
    MatrixOsservazioni m;

    //Initialize the input log file.
    try {
      w = new FileWriter(MacroReplacer.replace(LOG_FILE_NAME));
    } catch (IOException e1) {
      e1.printStackTrace();
    }

    try {
      //Init the progress show
      initShow(param.getOptions()[0] + 1);
      countObs = 0;
      totalRaw = 0;
      //Read the first line
      line = reader.readLine();
      while (line != null) {
        //Check if user has pressed the cancel button
        if (isCanceled()) {
          try {
            w.close();
          } catch (IOException e) {
            e.printStackTrace();
          }
          valori = null;
          msg = INPUT_MSG_ABORT;
          return null;
        }
        input.setInput(line);
        totalRaw++;
        countObs++;
        //Update the progress show
        if (totalRaw % getStep() == 0) {
          updateInfos(totalRaw, "<HTML># observations read: " + totalRaw + "<p># errors: " + (totalRaw - countObs) + "</HTML>", false);
        }
        //Legge le stringhe e ne controlla il formato
        for (i = 0; i < param.getNumVar(); i++) {
          //Leggo il token con i separatori (se definiti) qualunque cosa ci sia dentro
          if (separator[i] != null) {
            parseToken = separator[i];
          } else {
            parseToken = regExp[i];
          }

          if (myMatch.contains(input, myComp.compile(parseToken))) {
            if (sel[i]) {
              //Prendo il token
              lineToken[i] = myMatch.getMatch().toString();
              if (separator[i] != null) {
                //  Se il token aveva dei separatori li tolgo
                lineToken[i] = lineToken[i].substring(1, lineToken[i].length() - 1);
                //E prendo quello che mi interessa di cio che rimane
                if (myMatch.contains(lineToken[i], myComp.compile(regExp[i]))) {
                  lineToken[i] = myMatch.getMatch().toString();
                } else {
                  //Wrong row, token dosen't contains required data
                  countObs--;
                  try {
View Full Code Here

    int i, maxInd, j, k;
    boolean[] catchVal = new boolean[param.getOptions()[0]];
    boolean[] sel = param.getVarSelected();
    FileWriter w = null;
    PatternMatcherInput input = new PatternMatcherInput("");
    Perl5Compiler myComp = new Perl5Compiler();
    Perl5Matcher myMatch = new Perl5Matcher();
    String line = "";
    String[] regExp = param.getRegularExp();
    String[] separator = param.getSeparator();
    double[] lineValue = new double[param.getNumVarSelected()];
    String[] lineToken = new String[param.getNumVar()];
    String parseToken = null;
    MatrixOsservazioni m = null;

    try {
      w = new FileWriter(MacroReplacer.replace(LOG_FILE_NAME));
    } catch (IOException e1) {
      e1.printStackTrace();
    }

    try {
      initShow(param.getOptions()[1] + 1);
      maxInd = generateRandom(param.getOptions()[0], param.getOptions()[1], catchVal);
      countObs = 0;
      totalRaw = 0;
      line = reader.readLine();

      for (k = 0; k <= maxInd; k++) {
        if (isCanceled()) {
          try {
            w.close();
          } catch (IOException e) {
            e.printStackTrace();
          }
          valori = null;
          msg = INPUT_MSG_ABORT;
          return null;
        }

        if (!catchVal[k]) {
          line = reader.readLine();
          continue;
        }
        input.setInput(line);
        totalRaw++;
        countObs++;
        if (totalRaw % getStep() == 0) {
          updateInfos(totalRaw, "<HTML># observations read: " + totalRaw + "<p># errors: " + (totalRaw - countObs) + "</HTML>", false);
        }
        //Legge le stringhe e ne controlla il formato
        for (i = 0; i < param.getNumVar(); i++) {
          //Leggo il token con i separatori (se definiti) qualunque cosa ci sia dentro
          if (separator[i] != null) {
            parseToken = separator[i];
          } else {
            parseToken = regExp[i];
          }

          if (myMatch.contains(input, myComp.compile(parseToken))) {
            if (sel[i]) {
              //Prendo il token
              lineToken[i] = myMatch.getMatch().toString();
              if (separator[i] != null) {
                //  Se il token aveva dei separatori li tolgo
                lineToken[i] = lineToken[i].substring(1, lineToken[i].length() - 1);
                //E prendo quello che mi interessa di cio che rimane
                if (myMatch.contains(lineToken[i], myComp.compile(regExp[i]))) {
                  lineToken[i] = myMatch.getMatch().toString();
                } else {
                  //Riga sbagliata, decremento il num di oss
                  countObs--;
View Full Code Here

      w = new FileWriter(MacroReplacer.replace(LOG_FILE_NAME));
    } catch (IOException e1) {
      e1.printStackTrace();
    }
    PatternMatcherInput input = new PatternMatcherInput("");
    Perl5Compiler myComp = new Perl5Compiler();
    Perl5Matcher myMatch = new Perl5Matcher();
    String line = "";
    String[] regExp = param.getRegularExp();
    String[] separator = param.getSeparator();
    double[] lineValue = new double[param.getNumVarSelected()];
    String[] lineToken = new String[param.getNumVar()];
    String parseToken = null;
    MatrixOsservazioni m = null;

    try {
      initShow(maxInd - minInd + 1);
      countObs = 0;
      totalRaw = 0;
      line = reader.readLine();

      for (i = 0; line != null && i < (minInd - 1); i++) {
        line = reader.readLine();
      }

      while (totalRaw + minInd <= maxInd) {
        if (isCanceled()) {
          try {
            w.close();
          } catch (IOException e) {
            e.printStackTrace();
          }
          valori = null;
          msg = INPUT_MSG_ABORT;
          return null;
        }
        input.setInput(line);
        totalRaw++;
        countObs++;
        if (totalRaw % getStep() == 0) {
          updateInfos(totalRaw, "<HTML># observations read: " + totalRaw + "<p># errors: " + (totalRaw - countObs) + "</HTML>", false);
        }
        //Legge le stringhe e ne controlla il formato
        for (i = 0; i < param.getNumVar(); i++) {
          //Leggo il token con i separatori (se definiti) qualunque cosa ci sia dentro
          if (separator[i] != null) {
            parseToken = separator[i];
          } else {
            parseToken = regExp[i];
          }

          if (myMatch.contains(input, myComp.compile(parseToken))) {
            if (sel[i]) {
              //Prendo il token
              lineToken[i] = myMatch.getMatch().toString();
              if (separator[i] != null) {
                //  Se il token aveva dei separatori li tolgo
                lineToken[i] = lineToken[i].substring(1, lineToken[i].length() - 1);
                //E prendo quello che mi interessa di cio che rimane
                if (myMatch.contains(lineToken[i], myComp.compile(regExp[i]))) {
                  lineToken[i] = myMatch.getMatch().toString();
                } else {
                  //Riga sbagliata, decremento il num di oss
                  countObs--;
View Full Code Here

        //  The default packages are always added.
        //
        m_searchPath.add( DEFAULT_PACKAGE );
        m_searchPath.add( DEFAULT_FORMS_PACKAGE );

        PatternCompiler compiler = new Perl5Compiler();

        try {
            m_pluginPattern = compiler.compile( PLUGIN_INSERT_PATTERN );
        } catch( MalformedPatternException e ) {
            log.fatal( "Internal error: someone messed with pluginmanager patterns.", e );
            throw new InternalWikiException( "PluginManager patterns are broken" );
        }
View Full Code Here

        // compile splitpattern
        Element splitElement = DomHelper.getChildElement(widgetElement, FormsConstants.DEFINITION_NS, "split", true);
        if (splitElement != null) {
            String patternString = DomHelper.getAttribute(splitElement, "pattern");
            Perl5Compiler compiler = new Perl5Compiler();
            Pattern pattern;
            try {
                pattern = compiler.compile(patternString, Perl5Compiler.READ_ONLY_MASK);
            } catch (MalformedPatternException e) {
                throw new FormsException("Invalid regular expression '" + patternString + "'.",
                                         e, DomHelper.getLocationObject(splitElement));
            }
            definition.setSplitPattern(pattern, patternString);
View Full Code Here

TOP

Related Classes of org.apache.oro.text.regex.Perl5Compiler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.