Package org.kitesdk.morphline.shaded.com.google.code.regexp

Examples of org.kitesdk.morphline.shaded.com.google.code.regexp.Matcher


 
  @Test
  public void testGrokSeparatedValues() throws Exception {
    String msg = "hello\tworld\tfoo";
    Pattern pattern = Pattern.compile("(?<word>.+?)(\\t|\\z)");
    Matcher matcher = pattern.matcher(msg);
    List<String> results = Lists.newArrayList();
    while (matcher.find()) {
      //System.out.println("match:'" + matcher.group(1) + "'");
      results.add(matcher.group(1));
    }
    assertEquals(Arrays.asList("hello", "world", "foo"), results);
  }
View Full Code Here


      return super.doProcess(outputRecord);
    }

    private boolean doMatch(Record inputRecord, Record outputRecord, boolean doExtract) {
      for (Map.Entry<String, Matcher> regexEntry : regexes.entrySet()) {
        Matcher matcher = regexEntry.getValue();
        List values = inputRecord.get(regexEntry.getKey());
        int todo = values.size();
        int minMatches = 1;
        int maxMatches = Integer.MAX_VALUE;
        switch (numRequiredMatches) {
          case once : {
            maxMatches = 1;
            break;
          }
          case all : {
            minMatches = todo;
            break;
          }
          default: {
            break;
          }
        }       
        int numMatches = 0;
        for (Object value : values) {
          matcher.reset(value.toString());
          if (!findSubstrings) {
            if (matcher.matches()) {
              numMatches++;
              if (numMatches > maxMatches) {
                LOG.debug("grok failed because it found too many matches for values: {} for grok command: {}",
                          values, renderedConfig);
                return false;
              }
              extract(outputRecord, matcher, doExtract);
            }
          } else {
            int previousNumMatches = numMatches;
            while (matcher.find()) {
              if (numMatches == previousNumMatches) {
                numMatches++;
                if (numMatches > maxMatches) {
                  LOG.debug("grok failed because it found too many matches for values: {} for grok command: {}",
                            values, renderedConfig);
View Full Code Here

TOP

Related Classes of org.kitesdk.morphline.shaded.com.google.code.regexp.Matcher

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.