Package java.util.regex

Examples of java.util.regex.Matcher


  }
 
  private static Pattern CACHE_HINT = Pattern.compile("/\\*\\+?\\s*cache(\\(\\s*(pref_mem)?\\s*(ttl:\\d{1,19})?\\s*(updatable)?\\s*(scope:(session|vdb|user))?[^\\)]*\\))?[^\\*]*\\*\\/.*", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); //$NON-NLS-1$
   
  static CacheHint getQueryCacheOption(String query) {
      Matcher match = CACHE_HINT.matcher(query);
      if (match.matches()) {
        CacheHint hint = new CacheHint();
        if (match.group(2) !=null) {
          hint.setPrefersMemory(true);
        }
        String ttl = match.group(3);
        if (ttl != null) {
          hint.setTtl(Long.valueOf(ttl.substring(4)));
        }
        if (match.group(4) != null) {
          hint.setUpdatable(true);
        }
        String scope =  match.group(5);
        if (scope != null) {
          scope = scope.substring(6);
          hint.setScope(scope);
        }       
        return hint;


      try {
        return TimeUtils.parseTimeString(s);
      } catch (RuntimeDroolsException e) {
        // cannot parse delay, trying to interpret it
        Map<String, String> replacements = new HashMap<String, String>();
        Matcher matcher = PARAMETER_MATCHER.matcher(s);
            while (matcher.find()) {
              String paramName = matcher.group(1);
              if (replacements.get(paramName) == null) {
                  VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
                      resolveContextInstance(VariableScope.VARIABLE_SCOPE, paramName);
                    if (variableScopeInstance != null) {
                        Object variableValue = variableScopeInstance.getVariable(paramName);

       
        for (Map.Entry<String, Object> entry: workItem.getParameters().entrySet()) {
            if (entry.getValue() instanceof String) {
                String s = (String) entry.getValue();
                Map<String, String> replacements = new HashMap<String, String>();
                Matcher matcher = PARAMETER_MATCHER.matcher(s);
                while (matcher.find()) {
                    String paramName = matcher.group(1);
                    if (replacements.get(paramName) == null) {
                        VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
                            resolveContextInstance(VariableScope.VARIABLE_SCOPE, paramName);
                        if (variableScopeInstance != null) {
                            Object variableValue = variableScopeInstance.getVariable(paramName);

            }
        }
        String processId = getSubProcessNode().getProcessId();
        // resolve processId if necessary
        Map<String, String> replacements = new HashMap<String, String>();
    Matcher matcher = PARAMETER_MATCHER.matcher(processId);
        while (matcher.find()) {
          String paramName = matcher.group(1);
          if (replacements.get(paramName) == null) {
              VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
                  resolveContextInstance(VariableScope.VARIABLE_SCOPE, paramName);
                if (variableScopeInstance != null) {
                    Object variableValue = variableScopeInstance.getVariable(paramName);

      try {
        return TimeUtils.parseTimeString(s);
      } catch (RuntimeDroolsException e) {
        // cannot parse delay, trying to interpret it
        Map<String, String> replacements = new HashMap<String, String>();
        Matcher matcher = PARAMETER_MATCHER.matcher(s);
            while (matcher.find()) {
              String paramName = matcher.group(1);
              if (replacements.get(paramName) == null) {
                  VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
                      resolveContextInstance(VariableScope.VARIABLE_SCOPE, paramName);
                    if (variableScopeInstance != null) {
                        Object variableValue = variableScopeInstance.getVariable(paramName);

            if (!piNode.getTarget().equals("xml-stylesheet")) continue;
            StylesheetInfo info = new StylesheetInfo();
            info = new StylesheetInfo();
            info.setOrigin(StylesheetInfo.AUTHOR);
            String pi = piNode.getData();
            Matcher m = _alternatePattern.matcher(pi);
            if (m.matches()) {
                int start = m.end();
                String alternate = pi.substring(start + 1, pi.indexOf(pi.charAt(start), start + 1));
                //TODO: handle alternate stylesheets
                if (alternate.equals("yes")) continue;//DON'T get alternate stylesheets for now
            }
            m = _typePattern.matcher(pi);
            if (m.find()) {
                int start = m.end();
                String type = pi.substring(start + 1, pi.indexOf(pi.charAt(start), start + 1));
                //TODO: handle other stylesheet types
                if (!type.equals("text/css")) continue;//for now
                info.setType(type);
            }
            m = _hrefPattern.matcher(pi);
            if (m.find()) {
                int start = m.end();
                String href = pi.substring(start + 1, pi.indexOf(pi.charAt(start), start + 1));
                info.setUri(href);
            }
            m = _titlePattern.matcher(pi);
            if (m.find()) {
                int start = m.end();
                String title = pi.substring(start + 1, pi.indexOf(pi.charAt(start), start + 1));
                info.setTitle(title);
            }
            m = _mediaPattern.matcher(pi);
            if (m.find()) {
                int start = m.end();
                String media = pi.substring(start + 1, pi.indexOf(pi.charAt(start), start + 1));
                info.setMedia(media);
            } else {
                info.addMedium("screen");
            }

    final List<TemplateNode> node_list = new LinkedList<TemplateNode>();
    if (input == null || input.length() == 0) {
      return node_list;
    }

    final Matcher matcher = PATTERN.matcher(input);

    while (matcher.find()) {
      for (int i = 1; i <= matcher.groupCount(); i++) {
        if (matcher.group(i) != null) {
          switch (i) {
            case 1: // literal string
              node_list.add(TextNode.create(matcher.group(i)));
              break;
            case 2: // left bracket ([[])
              node_list.add(TextNode.create("["));
              break;
            case 3: // a [# comment]

      return NODE_TYPE.TEXT_NODE;
    }
  }

  private String consume(Pattern p, StringBuilder input) throws TemplateParserException {
    Matcher m = p.matcher(input);
    if (m.lookingAt()) {
      String string_to_return = m.group(1);
      // This is apparently an inefficient operation, but parsing should only
      // happen when the template is loaded or changes, so it doesn't happen
      // very often.
      input.delete(0, m.end());
      logger.finest("consumed '" + string_to_return + "'");
      return string_to_return;
    }
    throw new TemplateParserException(
        "Unexpected or malformed input: " + input);

        regexp = StringUtils.replace(regexp, WILDCARD, ".*?");
        return Pattern.compile(regexp);
    }

    public boolean matches(String destFieldTypeName) {
        Matcher matcher = pattern.matcher(destFieldTypeName);
        return matcher.matches();
    }

    rePattern.insert(0, '^');
    rePattern.append('$');

    try {
            Pattern patternRegex = Pattern.compile(rePattern.toString(), Pattern.DOTALL);
            Matcher matcher = patternRegex.matcher(search);
            return matcher.matches();
    } catch(PatternSyntaxException e) {
            throw new ExpressionEvaluationException(e, "ERR.015.006.0014", QueryPlugin.Util.getString("ERR.015.006.0014", new Object[]{pattern, e.getMessage()})); //$NON-NLS-1$ //$NON-NLS-2$
    }
  }

TOP

Related Classes of java.util.regex.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.