Package org.apache.oro.text.regex

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


        String delim = null;

        if (parts == null) {
            Perl5Matcher matcher = JMeterUtils.getMatcher();
            PatternMatcherInput input = new PatternMatcherInput(headerLine);
            Pattern pattern = JMeterUtils.getPatternCache()
            // This assumes the header names are all single words with no spaces
            // word followed by 0 or more repeats of (non-word char + word)
            // where the non-word char (\2) is the same
            // e.g. abc|def|ghi but not abd|def~ghi
View Full Code Here


        Perl5Matcher localMatcher = JMeterUtils.getMatcher();
        // The headers and body are divided by a blank line
        String regularExpression = "^.$";
        Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
       
        PatternMatcherInput input = new PatternMatcherInput(stringToCheck);
        while(localMatcher.contains(input, pattern)) {
            MatchResult match = localMatcher.getMatch();
            return match.beginOffset(0);
        }
        // No divider was found
View Full Code Here

    }

    private int matchStrings(int matchNumber, Perl5Matcher matcher,
            Pattern pattern, List<MatchResult> matches, int found,
            String inputString) {
        PatternMatcherInput input = new PatternMatcherInput(inputString);
        while (matchNumber <=0 || found != matchNumber) {
            if (matcher.contains(input, pattern)) {
                log.debug("RegexExtractor: Match found!");
                matches.add(matcher.getMatch());
                found++;
View Full Code Here

            log.debug("Pattern = " + templatePattern.getPattern());
            log.debug("template = " + rawTemplate);
        }
        int beginOffset = 0;
        MatchResult currentResult;
        PatternMatcherInput pinput = new PatternMatcherInput(rawTemplate);
        while(matcher.contains(pinput, templatePattern)) {
            currentResult = matcher.getMatch();
            final int beginMatch = currentResult.beginOffset(0);
            if (beginMatch > beginOffset) { // string is not empty
                combined.add(rawTemplate.substring(beginOffset, beginMatch));
View Full Code Here

  @Override
  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 {
                    w.write("Error in row " + totalRaw + " : Element " + i + " is wrong\n");
                  } catch (IOException e) {
                    e.printStackTrace();
                  }
                  break;
                }
              }
            }
          } else {
            //Wrong raw, element not found
            countObs--;
            try {
              w.write("Error in row " + totalRaw + " : Line doesn't match format (element " + i + " not found)\n");
            } catch (IOException e) {
              e.printStackTrace();
            }
            break;
          }
        }
        int j = 0;
        //Correct raw
        if (i == param.getNumVar()) {
          if (input.endOfInput()) {
            //Parse the string value in their correct formats
            for (i = 0; i < param.getNumVar(); i++) {
              if (sel[i]) {
                if (map[i] == null) {
                  lineValue[j++] = Double.parseDouble(lineToken[i]);
View Full Code Here

  public Object construct() {
    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--;

                  try {
                    w.write("Error in row " + k + " : Element " + i + " is wrong\n");
                  } catch (IOException e) {
                    e.printStackTrace();
                  }
                  break;
                }
              }
            }
          } else {
            //Riga sbagliata, decremento il num di oss
            countObs--;
            try {
              w.write("Error in row " + k + " : Line doesn't match format (element " + i + " not found)\n");
            } catch (IOException e) {
              e.printStackTrace();
            }
            break;

          }
        }
        j = 0;
        //Riga Corretta
        if (i == param.getNumVar()) {
          if (input.endOfInput()) {
            //Converte i valori (stringa) letti
            for (i = 0; i < param.getNumVar(); i++) {
              if (sel[i]) {
                if (map[i] == null) {
                  lineValue[j++] = Double.parseDouble(lineToken[i]);
View Full Code Here

    try {
      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--;

                  try {
                    w.write("Error in row " + (totalRaw + minInd) + " : Element " + i + " is wrong\n");
                  } catch (IOException e) {
                    e.printStackTrace();
                  }
                  break;
                }
              }
            }
          } else {
            //Riga sbagliata, decremento il num di oss
            countObs--;
            try {
              w.write("Error in row " + (totalRaw + minInd) + " : Line doesn't match format (element " + i + " not found)\n");
            } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
            break;
          }
        }
        j = 0;
        //Riga Corretta
        if (i == param.getNumVar()) {
          if (input.endOfInput()) {
            //Converte i valori (stringa) letti
            for (i = 0; i < param.getNumVar(); i++) {
              if (sel[i]) {
                if (map[i] == null) {
                  lineValue[j++] = Double.parseDouble(lineToken[i]);
View Full Code Here

        }

        List<MatchResult> collectAllMatches = new ArrayList<MatchResult>();
        try {
            PatternMatcher matcher = JMeterUtils.getMatcher();
            PatternMatcherInput input = new PatternMatcherInput(textToMatch);
            while (matcher.contains(input, searchPattern)) {
                MatchResult match = matcher.getMatch();
                collectAllMatches.add(match);
            }
        } finally {
View Full Code Here

        List<String> pieces = new ArrayList<String>();
        // String or Integer
        List<Object> combined = new LinkedList<Object>();
        PatternMatcher matcher = JMeterUtils.getMatcher();
        Util.split(pieces, matcher, templatePattern, rawTemplate);
        PatternMatcherInput input = new PatternMatcherInput(rawTemplate);
        boolean startsWith = isFirstElementGroup(rawTemplate);
        if (startsWith) {
            pieces.remove(0);// Remove initial empty entry
        }
        Iterator<String> iter = pieces.iterator();
View Full Code Here

        Perl5Matcher localMatcher = JMeterUtils.getMatcher();
        // The headers and body are divided by a blank line
        String regularExpression = "^.$";
        Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
       
        PatternMatcherInput input = new PatternMatcherInput(stringToCheck);
        while(localMatcher.contains(input, pattern)) {
            MatchResult match = localMatcher.getMatch();
            return match.beginOffset(0);
        }
        // No divider was found
View Full Code Here

TOP

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

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.