Examples of MatchResult


Examples of com.oroinc.text.regex.MatchResult

    {
        privateCheckHtml();
        boolean replacementOccured = false;
        while(true) {
            // Note: endtagM must be *after* starttagM.
            MatchResult starttagM = RegExp.match(cmdPattern("KfmIf", label), html);
            if(starttagM == null) {
                return replacementOccured;
            }

            int offset = starttagM.endOffset(0);
            String html2 = html.substring(offset);
            MatchResult endtagM = RegExp.match("\\</KfmIf\\s*\\>", html2);
            if(endtagM == null) {
                return replacementOccured;
            }
            replacementOccured = true;
            String replacement = (keep ? html.substring(starttagM.endOffset(0), endtagM.beginOffset(0) + offset) : "" );
            if(domark) {
                //D KFMSystem.log.detail("replaceAllKfmIf: mark!");
                replacement = markTag(starttagM.group(0)) + replacement + markTag(endtagM.group(0));
            }
            if(debug) {
                replacement = commentifyTag(starttagM.group(0)) + replacement + commentifyTag(endtagM.group(0));
            }
            //D KFMSystem.log.detail("Replace of Command KfmIf " + label + ": "
            //D                + html.substring(starttagM.endOffset(0), endtagM.beginOffset(0))
            //D                + " -> " + replacement);
            html = html.substring(0, starttagM.beginOffset(0))
                + replacement
                + html2.substring(endtagM.endOffset(0));
        }
    }
View Full Code Here

Examples of com.oroinc.text.regex.MatchResult

     */
    public String getKfmParam (String label, String param)
    {
        privateCheckHtml();
        //D KFMSystem.log.detail("get: " + label + " " + param);
        MatchResult starttagM = RegExp.match(cmdPattern("Kfm", label), html);
        if(starttagM == null) {
            //D KFMSystem.log.detail("label not found.");
            return "";
        }
        MatchResult valueM = RegExp.match(
            "\\s" + param + "\\s*=\\s*"
            // This will allow something like "...', and does *not* allow embedded ">".
            // Note that "group(1)" does not contain the quotes.
            // + "[\"']([^>\"']*)[\"']"
            // This will allow "...'..." and '..."...' and *does* allow embedded ">".
            // Note that "group(1)" now contains the quotes.
             + "((?:\"[^\"]*\")|(?:'[^']*'))"
            , starttagM.group(0));
        if(valueM == null) {
            //D KFMSystem.log.detail("param not found.");
            return "";
        }
        // Now we must strip the quotes.
        // return valueM.group(1);
        String t = valueM.group(1);
        t = t.replace('�', '>');
        return t.substring(1, t.length()-1);
    }
View Full Code Here

Examples of com.oroinc.text.regex.MatchResult

     */
    public boolean replaceKfm (String label, boolean aKeep, String aBefore, String aAfter)
    {
        privateCheckHtml();
        // This regexp ensures that start tag is before end tag.
        MatchResult elementM = null;
        String p = "";
        try {
            p = "(" + cmdPattern("Kfm", label) + ")"            /*group 1: start tag*/
    // This seems very suspect (WARNING: it can cause StackOverflow Errors!):
    //            + "((?:.|\\n)*?)"                             /*group 2: content*/
    // lets try: .*?
                + "(.*?)"                                       /*group 2: content replaced*/
                + "(" + "\\</Kfm\\s*\\>" + ")";                 /*group 3: end tag */
            elementM = RegExp.match(p, html, false, true);
        } catch(Error e) {
            mLog.error(
                "Template::replace,RegExp.match caused Error: " + e + "\n"
                + "Arguments: p = '" + p + "'\n"
                + "html = '" + html + "'");
            return false;
        }
        final int starttagI = 1;
        final int contentI  = 2;
        final int endtagI   = 3;

        if(elementM == null) return false;
        String replacement = aBefore + (aKeep ? elementM.group(contentI) : "") + aAfter;
        if(domark) {
            //D KFMSystem.log.detail("replaceKfm: mark!");
            replacement = markTag(elementM.group(starttagI))
                + replacement + markTag(elementM.group(endtagI));
        }
        if(debug) {
            replacement = commentifyTag(elementM.group(starttagI))
                + replacement + commentifyTag(elementM.group(endtagI));
        }
        html = html.substring(0, elementM.beginOffset(0))
            + replacement
            + html.substring(elementM.endOffset(0));
        //D KFMSystem.log.detail("Replace of Command Kfm " + label + ": " + elementM.group(0) + " -> " + replacement);
        return true;
    }
View Full Code Here

Examples of com.oroinc.text.regex.MatchResult

        boolean replacementOccured = super.replaceAllKfmIf(label, keep);

        for(int i = 1; i <= 3; ++i) {
            lWhile: while(true) {
                // Note: endtagM must be *after* starttagM.
                MatchResult starttagM = RegExp.match(cmdPattern("KfmIf" + i, label), html);
                if(starttagM == null) {
                    break lWhile;
                }

                int offset = starttagM.endOffset(0);
                String html2 = html.substring(offset);
                MatchResult endtagM = RegExp.match("\\</KfmIf" + i + "\\s*\\>", html2);
                if(endtagM == null) {
                    break lWhile;
                }
                replacementOccured = true;
                String replacement = (keep ? html.substring(starttagM.endOffset(0), endtagM.beginOffset(0) + offset) : "" );
                if(domark) {
                    replacement = markTag(starttagM.group(0)) + replacement + markTag(endtagM.group(0));
                }
                if(debug) {
                    replacement = commentifyTag(starttagM.group(0)) + replacement + commentifyTag(endtagM.group(0));
                }
                html = html.substring(0, starttagM.beginOffset(0))
                    + replacement
                    + html2.substring(endtagM.endOffset(0));
            }
        }
        return replacementOccured;
    }
View Full Code Here

Examples of com.sun.xacml.MatchResult

        while (it.hasNext()) {
            // for each identifier, get only the most recent policy
            AbstractPolicy policy = it.next().first();

            // see if we match
            MatchResult match = policy.match(context);
            int result = match.getResult();

            // if there was an error, we stop right away
            if (result == MatchResult.INDETERMINATE) {
                log.error("Error occured while processing the XACML policy "
                        + policy.getId().toString());
                throw new EntitlementException(match.getStatus());
            }

            // if we matched, we keep track of the matching policy...
            if (result == MatchResult.MATCH) {
                // ...first checking if this is the first match and if
View Full Code Here

Examples of dbfit.util.MatchResult

    @Test
    public void shouldReportCellSuccessToReportingSystem() {
        DiffListener reporter = new CompareStoredQueries.FitFixtureReporter(
                reportingSystem);

        MatchResult cellResult = createCellResult("*demo-1*", SUCCESS);

        reporter.onEvent(cellResult);

        verify(reportingSystem).addCell(cellResult);
    }
View Full Code Here

Examples of dnb.analyze.MatchResult

 
  // XXX return if part status has been assigned
  private static void assignMatchStati(NfoLyzeResult result, Repository repository) {
   
    Map<NfoField, MatchResult> m = result.getMatches();
    MatchResult mr;
       
    if((mr = m.get(NfoField.ARTIST)) != null) { // get the artist's match result, if set, proceed!     
      SimilarScanResult<Artist> f = repository.findSimilarArtist(mr.getMatch());
      mr.setSimilarScanResult(f); // ... attach similar matches to the match itself     
      assignMatchStatus(mr, f); // ... assign stati
      if (f != null) { // XXX compose alternatives & show on UI !
        System.out.println("*********" + f);
      }
    }
    if((mr = m.get(NfoField.GENRE)) != null) { // get the genre's match result, if set, proceed!     
      SimilarScanResult<Genre> f = repository.findSimilarGenre(mr.getMatch());
      mr.setSimilarScanResult(f); // ... attach similar matches to the match itself 
      assignMatchStatus(mr, f);
      if (f != null) { // XXX compose alternatives & show on UI !
        System.out.println("GENRE: *********" + f);
      }
    }
   
    if((mr = m.get(NfoField.RECORD_LABEL)) != null) { // get the label's match result, if set, proceed!
     
      SimilarScanResult<Label> f = repository.findSimilarLabel(mr.getMatch());
      mr.setSimilarScanResult(f); // ... attach similar matches to the match itself 
      assignMatchStatus(mr, f);
     
      if (f != null) { // XXX compose alternatives & show on UI !
        System.out.println("LABEL: *********" + f);       
      }
View Full Code Here

Examples of java.util.regex.MatchResult

      Pattern pattern = fmt.regexPattern;
      Matcher matcher = pattern.matcher(eventStr);
      if (! matcher.matches()) {
        continue;
      }
      MatchResult res = matcher.toMatchResult();
      for (int grp=1; grp <= res.groupCount(); grp++) {
        String value = res.group(grp);
        if (grp == SYSLOG_TIMESTAMP_POS) {
          timeStampString = value;

          // apply available format replacements to timestamp
          if (value != null) {
View Full Code Here

Examples of java.util.regex.MatchResult

    if (o2.global) {
     
      ESeq result = ERT.NIL;
     
      while (matcher.find()) {
        MatchResult mr = matcher.toMatchResult();
     
        ESeq list;
        if (o2.capture_spec == am_all) {
          ESeq l = ERT.NIL;
          for (int i = mr.groupCount(); i >= 0; i--) {
            l = l.cons( capture (subject, mr, i, o2) );
          }
         
          result = result.cons(l);
        } else if ((list = o2.capture_spec.testSeq()) != null) {
          ESeq l = ERT.NIL;
          while (!list.isNil()) {
            EObject group = list.head();
            ESmall num;
            EAtom nam;
            EString nam2;
            if ((num=group.testSmall()) != null)
            {
              l = l.cons( capture (subject, mr, num.value, o2 ));
            } else if ((nam=group.testAtom()) != null) {
              Integer groupNo = o2.named_groups.get(nam.getName());
              if (groupNo != null) {
                l = l.cons( capture (subject, mr, groupNo.intValue(), o2 ));
              }
            } else if ((nam2=group.testString()) != null) {
              Integer groupNo = o2.named_groups.get(nam2.stringValue());
              if (groupNo != null) {
                l = l.cons( capture (subject, mr, groupNo.intValue(), o2 ));
              }
            } else {
              throw new NotImplemented("named capture groups");
            }
            list = list.tail();
          }
          result = result.cons(l);

        } else {
          throw new NotImplemented("global and not all");
        }
      }
     
      if (result == ERT.NIL) {
        return am_nomatch;
      } else {
         return new ETuple2(am_match, result.reverse());
      }
     
    } else {
     
      if (matcher.find()) {
       
        if (o2.capture_spec  == am_none) {
          return am_match;
        }
       
        MatchResult mr = matcher.toMatchResult();
     
        int max = mr.groupCount();
        while( mr.start(max) == -1)
          max -= 1;
       
        ESeq il;
        if (o2.capture_spec == am_all) {
          ESeq l = ERT.NIL;
          for (int i = max; i >= 0; i--) {
            l = l.cons( capture (subject, mr, i, o2) );
          }
          return new ETuple2(am_match, l);
         
        } else if (o2.capture_spec == am_all_but_first) {
          ESeq l = ERT.NIL;
          for (int i = max; i > 0; i--) {
            l = l.cons( capture (subject, mr, i, o2) );
          }
          return new ETuple2(am_match, l);
         
        } else if (o2.capture_spec == am_first) {
          EObject l = capture (subject, mr, 0, o2);
          return new ETuple2(am_match, l);
         
        } else if ((il = o2.capture_spec.testSeq()) != null) {
         
          ESeq out = ERT.NIL;
         
           for (; !il.isNil(); il = il.tail()) {
             EObject what = il.head();
            ESmall idx = what.testSmall();
             EAtom nam;
            if (idx != null && mr.start(idx.value) != -1) {
               EObject val = capture (subject, mr, idx.value, o2);
               out = out.cons(val);
             } else if ((nam=what.testAtom())!=null) {
               Integer idx2 = o2.named_groups.get(nam.getName());
               if (idx2 != null) {
View Full Code Here

Examples of java.util.regex.MatchResult

        }

        void parseMacKeyHeaderLine(String line, KatResult kr) {
            Scanner ls = new Scanner(line);
            ls.findInLine(".*=\\s*(\\d+) .*");
            MatchResult result = null;
            try {
                result = ls.match();
            } catch (Exception e) {
                System.out.println("Mac header: " + line);
                e.printStackTrace();
                System.exit(1);
            }
            kr.macKeyLen = Integer.parseInt(result.group(1));
            kr.macKey = new byte[kr.macKeyLen];
            state = MacKey;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.