Examples of MatchResult


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

        String type = null;
        boolean allowBody = false;

        if (_patternMatcher.matches(jwcId, _implicitIdPattern))
        {
            MatchResult match = _patternMatcher.getMatch();

            jwcId = match.group(IMPLICIT_ID_PATTERN_ID_GROUP);
            type = match.group(IMPLICIT_ID_PATTERN_TYPE_GROUP);

            String libraryId = match.group(IMPLICIT_ID_PATTERN_LIBRARY_ID_GROUP);
            String simpleType = match.group(IMPLICIT_ID_PATTERN_SIMPLE_TYPE_GROUP);

            // If (and this is typical) no actual component id was specified,
            // then generate one on the fly.
            // The allocated id for anonymous components is
            // based on the simple (unprefixed) type, but starts
View Full Code Here

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

        // probably a new PatternMatcherInput working on a byte[] would do
        // better.
        input.setInput(new String(html));
        while (matcher.contains(input, pattern))
        {
            MatchResult match= matcher.getMatch();
            String s;
            if (log.isDebugEnabled())
                log.debug("match groups " + match.groups());
            // Check for a BASE HREF:
            for (int g=1; g <= NUM_BASE_GROUPS && g <= match.groups(); g++)
            {
                s= match.group(g);
                if (s != null)
                {
                    if (log.isDebugEnabled())
                    {
                        log.debug("new baseUrl: " + s + " - " + baseUrl.toString());
                    }
                    try
                    {
                        baseUrl= new URL(baseUrl, s);
                    }
                    catch (MalformedURLException e)
                    {
                        // Doesn't even look like a URL?
                        // Maybe it isn't: Ignore the exception.
                        if (log.isDebugEnabled())
                        {
                            log.debug(
                                "Can't build base URL from RL "
                                    + s
                                    + " in page "
                                    + baseUrl,
                                e);
                        }
                    }
                }
            }
            for (int g= NUM_BASE_GROUPS+1; g <= match.groups(); g++)
            {
                s= match.group(g);
                if (log.isDebugEnabled())
                {
                    log.debug("group " + g + " - " + match.group(g));
                }
                if (s != null)
                {
                        urls.addURL(s,baseUrl);
                }
View Full Code Here

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

      }
      while (x != matchNumber && !done);

      try
      {
          MatchResult match;
          if (matchNumber >= 0){// Original match behaviour
            match = getCorrectMatch(matches, matchNumber);
            if (match != null)
            {
                vars.put(refName, generateResult(match));
View Full Code Here

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

            PatternMatcher matcher = (PatternMatcher) localMatcher.get();
            String responseText = new String(previousResult.getResponseData());
            PatternMatcherInput input = new PatternMatcherInput(responseText);
            while (matcher.contains(input, searchPattern))
            {
                MatchResult match = matcher.getMatch();
                collectAllMatches.add(match);
            }
        }
        catch (NumberFormatException e)
        {
            log.error("", e);
            return defaultValue;
        }
        catch (Exception e)
        {
            return defaultValue;
        }
        finally
    {
      vars.put(name+"_matchNr", ""+collectAllMatches.size());
        }

        if (collectAllMatches.size() == 0)
        {
            return defaultValue;
        }

        if (valueIndex.equals(ALL))
        {
            StringBuffer value = new StringBuffer();
            Iterator it = collectAllMatches.iterator();
            boolean first = true;
            while (it.hasNext())
            {
                if (!first)
                {
                    value.append(between);
                }
                else
                {
                    first = false;
                }
                value.append(generateResult((MatchResult) it.next(),name, tmplt, vars));
            }
            return value.toString();
        }
        else if (valueIndex.equals(RAND))
        {
            MatchResult result =
                (MatchResult) collectAllMatches.get(
                    rand.nextInt(collectAllMatches.size()));
            return generateResult(result,name, tmplt, vars);
        }
        else
        {
            try
            {
                int index = Integer.parseInt(valueIndex) - 1;
                MatchResult result = (MatchResult) collectAllMatches.get(index);
                return generateResult(result,name, tmplt, vars);
            }
            catch (NumberFormatException e)
            {
                float ratio = Float.parseFloat(valueIndex);
                MatchResult result =
                    (MatchResult) collectAllMatches.get(
                        (int) (collectAllMatches.size() * ratio + .5) - 1);
                return generateResult(result,name, tmplt, vars);
            }
            catch (IndexOutOfBoundsException e)
View Full Code Here

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

        String value = "";
        if (isPathExtension() && isPathExtensionNoEquals() && isPathExtensionNoQuestionmark())
        {
            if (matcher.contains(text, pathExtensionNoEqualsNoQuestionmarkRegexp))
            {
                MatchResult result = matcher.getMatch();
                value = result.group(1);
            }
        }
        else if (isPathExtension() && isPathExtensionNoEquals()) // && ! isPathExtensionNoQuestionmark
        {
            if (matcher.contains(text, pathExtensionNoEqualsQuestionmarkRegexp))
            {
                MatchResult result = matcher.getMatch();
                value = result.group(1);
            }
        }
        else if (isPathExtension() && isPathExtensionNoQuestionmark()) // && ! isPathExtensionNoEquals
        {
            if (matcher.contains(text, pathExtensionEqualsNoQuestionmarkRegexp))
            {
                MatchResult result = matcher.getMatch();
                value = result.group(1);
            }
        }
        else if (isPathExtension()) // && ! isPathExtensionNoEquals && ! isPathExtensionNoQuestionmark
        {
            if (matcher.contains(text, pathExtensionEqualsQuestionmarkRegexp))
            {
                MatchResult result = matcher.getMatch();
                value = result.group(1);
            }
        }
        else // if ! isPathExtension()
        {
            if (matcher.contains(text, parameterRegexp))
            {
                MatchResult result = matcher.getMatch();
                for (int i=1; i<result.groups(); i++)
                {
                    value = result.group(i);
                    if (value != null) break;
                }
            }
        }
View Full Code Here

Examples of org.docopt.Pattern.MatchResult

      }
    }

    extras(help, version, $argv, doc);

    final MatchResult m = pattern.fix().match($argv);

    if (m.matched() && m.getLeft().isEmpty()) {
      // @formatter:off
      // >>> return Dict((a.name, a.value) for a in (pattern.flat() + collected))
      // @formatter:on
      final Map<String, Object> u = new HashMap<String, Object>();

      for (final Pattern p : pattern.flat()) {
        // TODO: Does flat always return LeafPattern objects?
        if (!(p instanceof LeafPattern)) {
          throw new IllegalStateException();
        }

        final LeafPattern lp = (LeafPattern) p;

        u.put(lp.getName(), lp.getValue());
      }

      for (final LeafPattern p : m.getCollected()) {
        u.put(p.getName(), p.getValue());
      }

      return u;
    }
View Full Code Here

Examples of org.jboss.security.xacml.sunxacml.MatchResult

     */
   @Override
   public PolicyFinderResult findPolicy(EvaluationCtx context)
   {
      AbstractPolicy selectedPolicy = null;
      MatchResult match = policySet.match(context);
      int result = match.getResult();

      // if target matching was indeterminate, then return the error
      if (result == MatchResult.INDETERMINATE)
         return new PolicyFinderResult(match.getStatus());

      // see if the target matched
      if (result == MatchResult.MATCH)
      {
         // see if we previously found another match
View Full Code Here

Examples of org.jostraca.comp.apache.oro.text.regex.MatchResult

  private String matchImpl( String pSource, int pSubMatchIndex ) throws RegExpException {
    String  source  = (String) Internal.null_arg( pSource );
    boolean matches = iMatcher.contains( source, iPattern );

    if( matches ) {
      MatchResult mr = iMatcher.getMatch();
      return matchImpl( mr, pSubMatchIndex );
    }
    else {
      return Standard.EMPTY;
    }
View Full Code Here

Examples of org.jregex.MatchResult

        obj.registerMethod(runtime.newNativeMethod("returns a list of all groups captured in this match. if a group is not matched it will be nil in the list. the actual match text is not included in this list.", new TypeCheckingNativeMethod.WithNoArguments("captures", obj) {
                @Override
                public Object activate(IokeObject method, Object on, List<Object> args, Map<String, Object> keywords, IokeObject context, IokeObject message) throws ControlFlow {
                    List<Object> groups = new ArrayList<Object>();
                    MatchResult mr = getMatchResult(on);
                    int len = mr.groupCount();
                    for(int i=1;i<len;i++) {
                        if(mr.isCaptured(i)) {
                            groups.add(context.runtime.newText(mr.group(i)));
                        } else {
                            groups.add(context.runtime.nil);
                        }
                    }

                    return context.runtime.newList(groups);
                }
            }));

        obj.registerMethod(runtime.newNativeMethod("returns a list of all groups captured in this match. if a group is not matched it will be nil in the list. the actual match text is the first element in the list.", new TypeCheckingNativeMethod.WithNoArguments("asList", obj) {
                @Override
                public Object activate(IokeObject method, Object on, List<Object> args, Map<String, Object> keywords, IokeObject context, IokeObject message) throws ControlFlow {
                    List<Object> groups = new ArrayList<Object>();
                    MatchResult mr = getMatchResult(on);
                    int len = mr.groupCount();
                    for(int i=0;i<len;i++) {
                        if(mr.isCaptured(i)) {
                            groups.add(context.runtime.newText(mr.group(i)));
                        } else {
                            groups.add(context.runtime.nil);
                        }
                    }

                    return context.runtime.newList(groups);
                }
            }));

        obj.registerMethod(runtime.newNativeMethod("Takes one optional argument that should be either a number or a symbol. this should be the name or index of a group to return the start index for. if no index is supplied, 0 is the default. if the group in question wasn't matched, returns -1.", new TypeCheckingNativeMethod("start") {
                private final TypeCheckingArgumentsDefinition ARGUMENTS = TypeCheckingArgumentsDefinition
                    .builder()
                    .receiverMustMimic(obj)
                    .withOptionalPositional("index", "0")
                    .getArguments();

                @Override
                public TypeCheckingArgumentsDefinition getArguments() {
                    return ARGUMENTS;
                }

                @Override
                public Object activate(IokeObject method, Object on, List<Object> args, Map<String, Object> keywords, IokeObject context, IokeObject message) throws ControlFlow {
                    int index = 0;

                    if(args.size() > 0) {
                        Object arg = args.get(0);
                        if(IokeObject.data(arg) instanceof Number) {
                            index = Number.extractInt(arg, message, context);
                        } else {
                            String namedIndex = Text.getText(Interpreter.send(context.runtime.asText, context, arg));
                            Integer ix = Regexp.getRegexp(getRegexp(on)).groupId(namedIndex);
                            if(ix == null) {
                                return context.runtime.newNumber(-1);
                            }

                            index = ix;
                        }
                    }
                    MatchResult mr = getMatchResult(on);
                    if(index < mr.groupCount() && mr.isCaptured(index)) {
                        return context.runtime.newNumber(mr.start(index));
                    } else {
                        return context.runtime.newNumber(-1);
                    }
                }
            }));

        obj.registerMethod(runtime.newNativeMethod("Takes one optional argument that should be either a number or a symbol. this should be the name or index of a group to return the end index for. if no index is supplied, 0 is the default. if the group in question wasn't matched, returns -1.", new TypeCheckingNativeMethod("end") {
                private final TypeCheckingArgumentsDefinition ARGUMENTS = TypeCheckingArgumentsDefinition
                    .builder()
                    .receiverMustMimic(obj)
                    .withOptionalPositional("index", "0")
                    .getArguments();

                @Override
                public TypeCheckingArgumentsDefinition getArguments() {
                    return ARGUMENTS;
                }

                @Override
                public Object activate(IokeObject method, Object on, List<Object> args, Map<String, Object> keywords, IokeObject context, IokeObject message) throws ControlFlow {
                    int index = 0;

                    if(args.size() > 0) {
                        Object arg = args.get(0);
                        if(IokeObject.data(arg) instanceof Number) {
                            index = Number.extractInt(arg, message, context);
                        } else {
                            String namedIndex = Text.getText(Interpreter.send(context.runtime.asText, context, arg));
                            Integer ix = Regexp.getRegexp(getRegexp(on)).groupId(namedIndex);
                            if(ix == null) {
                                return context.runtime.newNumber(-1);
                            }

                            index = ix;
                        }
                    }
                    MatchResult mr = getMatchResult(on);
                    if(index < mr.groupCount() && mr.isCaptured(index)) {
                        return context.runtime.newNumber(mr.end(index));
                    } else {
                        return context.runtime.newNumber(-1);
                    }
                }
            }));

        obj.registerMethod(runtime.newNativeMethod("Takes one optional argument that should be either a number or a symbol. this should be the name or index of a group to return the start and end index for. if no index is supplied, 0 is the default. if the group in question wasn't matched, returns nil, otherwise a pair of the start and end indices.", new TypeCheckingNativeMethod("offset") {
                private final TypeCheckingArgumentsDefinition ARGUMENTS = TypeCheckingArgumentsDefinition
                    .builder()
                    .receiverMustMimic(obj)
                    .withOptionalPositional("index", "0")
                    .getArguments();

                @Override
                public TypeCheckingArgumentsDefinition getArguments() {
                    return ARGUMENTS;
                }

                @Override
                public Object activate(IokeObject method, Object on, List<Object> args, Map<String, Object> keywords, IokeObject context, IokeObject message) throws ControlFlow {
                    int index = 0;

                    if(args.size() > 0) {
                        Object arg = args.get(0);
                        if(IokeObject.data(arg) instanceof Number) {
                            index = Number.extractInt(arg, message, context);
                        } else {
                            String namedIndex = Text.getText(Interpreter.send(context.runtime.asText, context, arg));
                            Integer ix = Regexp.getRegexp(getRegexp(on)).groupId(namedIndex);
                            if(ix == null) {
                                return context.runtime.nil;
                            }

                            index = ix;
                        }
                    }
                    MatchResult mr = getMatchResult(on);
                    if(index < mr.groupCount() && mr.isCaptured(index)) {
                        return context.runtime.newPair(context.runtime.newNumber(mr.start(index)), context.runtime.newNumber(mr.end(index)));
                    } else {
                        return context.runtime.nil;
                    }
                }
            }));


        obj.registerMethod(runtime.newNativeMethod("Takes one indexing argument that should be either a number, a range, a text or a symbol. if it's a number or a range of numbers, these will specify the index of the capture to return. 0 is the whole match. negative indices are interpreted in the usual way. if the range is out of range it will only use as many groups as there are. if it's a text or a sym it will be interpreted as a the name of a named group to return. if an index isn't correct or wasn't matched, it returns nil in those places.", new TypeCheckingNativeMethod("[]") {
                private final TypeCheckingArgumentsDefinition ARGUMENTS = TypeCheckingArgumentsDefinition
                    .builder()
                    .receiverMustMimic(obj)
                    .withRequiredPositional("index")
                    .getArguments();

                @Override
                public TypeCheckingArgumentsDefinition getArguments() {
                    return ARGUMENTS;
                }

                @Override
                public Object activate(IokeObject method, Object on, List<Object> args, Map<String, Object> keywords, IokeObject context, IokeObject message) throws ControlFlow {
                    Object arg = args.get(0);

                    MatchResult mr = getMatchResult(on);

                    if((IokeObject.data(arg) instanceof Symbol) || (IokeObject.data(arg) instanceof Text)) {
                        String namedIndex = Text.getText(Interpreter.send(context.runtime.asText, context, arg));
                        Integer ix = Regexp.getRegexp(getRegexp(on)).groupId(namedIndex);
                        if(ix == null || !mr.isCaptured(ix)) {
                            return context.runtime.nil;
                        }
                        return context.runtime.newText(mr.group(ix));
                    } else {
                        int size = mr.groupCount();

                        if(IokeObject.data(arg) instanceof Range) {
                            int first = Number.extractInt(Range.getFrom(arg), message, context);

                            if(first < 0) {
                                return context.runtime.newList(new ArrayList<Object>());
                            }

                            int last = Number.extractInt(Range.getTo(arg), message, context);
                            boolean inclusive = Range.isInclusive(arg);


                            if(last < 0) {
                                last = size + last;
                            }

                            if(last < 0) {
                                return context.runtime.newList(new ArrayList<Object>());
                            }

                            if(last >= size) {
                                last = inclusive ? size-1 : size;
                            }

                            if(first > last || (!inclusive && first == last)) {
                                return context.runtime.newList(new ArrayList<Object>());
                            }

                            if(!inclusive) {
                                last--;
                            }

                            List<Object> result = new ArrayList<Object>();
                            for(int i = first; i < last+1; i++) {
                                if(!mr.isCaptured(i)) {
                                    result.add(context.runtime.nil);
                                } else {
                                    result.add(context.runtime.newText(mr.group(i)));
                                }
                            }

                            return context.runtime.newList(result);
                        }

                        if(!(IokeObject.data(arg) instanceof Number)) {
                            arg = IokeObject.convertToNumber(arg, message, context);
                        }
                        int index = ((Number)IokeObject.data(arg)).asJavaInteger();
                        if(index < 0) {
                            index = size + index;
                        }

                        if(index >= 0 && index < size && mr.isCaptured(index)) {
                            return context.runtime.newText(mr.group(index));
                        } else {
                            return context.runtime.nil;
                        }
                    }
                }
            }));

        obj.registerMethod(runtime.newNativeMethod("will get the named group corresponding to the name of the message, or nil if the named group hasn't been matched. will signal a condition if no such group is defined.", new TypeCheckingNativeMethod("pass") {
                private final TypeCheckingArgumentsDefinition ARGUMENTS = TypeCheckingArgumentsDefinition
                    .builder()
                    .receiverMustMimic(obj)
                    .getArguments();

                @Override
                public TypeCheckingArgumentsDefinition getArguments() {
                    return ARGUMENTS;
                }

                @Override
                public Object activate(IokeObject method, Object on, List<Object> args, Map<String, Object> keywords, IokeObject context, IokeObject message) throws ControlFlow {
                    MatchResult mr = getMatchResult(on);
                    String name = Message.name(message);

                    Integer ix = Regexp.getRegexp(getRegexp(on)).groupId(name);
                    if(ix == null) {
                        final IokeObject condition = IokeObject.as(IokeObject.getCellChain(message.runtime.condition,
                                                                                           message,
                                                                                           context,
                                                                                           "Error",
                                                                                           "NoSuchCell"), context).mimic(message, context);
                        condition.setCell("message", message);
                        condition.setCell("context", context);
                        condition.setCell("receiver", on);
                        condition.setCell("cellName", message.runtime.getSymbol(name));

                        message.runtime.withReturningRestart("ignore", context, new RunnableWithControlFlow() {
                                public void run() throws ControlFlow {
                                    condition.runtime.errorCondition(condition);
                                }});

                        return context.runtime.nil;
                    }

                    if(mr.isCaptured(ix)) {
                        return context.runtime.newText(mr.group(ix));
                    } else {
                        return context.runtime.nil;
                    }
                }
            }));
View Full Code Here

Examples of org.modelmapper.spi.ConditionalConverter.MatchResult

                  propertyNameInfo.getDestinationProperties(), propertyTypeMap.getProvider(),
                  propertyConverter));
            doneMatching = matchingStrategy.isExact();
          } else {
            for (ConditionalConverter<?, ?> converter : converterStore.getConverters()) {
              MatchResult matchResult = converter.match(accessor.getType(),
                  destinationMutator.getType());

              if (!MatchResult.NONE.equals(matchResult)) {
                mapping = new PropertyMappingImpl(propertyNameInfo.getSourceProperties(),
                    propertyNameInfo.getDestinationProperties(), false);
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.