Package java.util.regex

Examples of java.util.regex.Matcher


      Embedded,
      Socket
    }
   
    public static ConnectionType acceptsUrl(String url) {
      Matcher m = urlPattern.matcher(url);
      if (m.matches()) {
        return m.group(2) != null?ConnectionType.Socket:ConnectionType.Embedded;
      }
      return null;
    }


        jdbcURL = jdbcURL.trim();
        if (jdbcURL.length() == 0) {
            throw new IllegalArgumentException();
        }
       
        Matcher m = urlPattern.matcher(jdbcURL);
        if (!m.matches()) {
          throw new IllegalArgumentException();
        }
        vdbName = m.group(1);
        connectionURL = m.group(2);
        if (connectionURL != null) {
          connectionURL = connectionURL.trim();
        }
        String props = m.group(3);
        if (props != null) {
          parseConnectionProperties(props, this.properties);
        }
    }

    public JavaMethod getFinderMethodBySignature(String finderSignature) {
        return getMethodBySignature(finderSignature);
    }

    public JavaMethod getMethodBySignature(String signature) {
        Matcher matcher = methodPattern.matcher(signature);

        if (matcher.matches()) {
            JavaMethod method = new JavaMethod(new Type(matcher.group(1)), matcher.group(2));

            // Now let's find out the arguments
            matcher = paramPattern.matcher(matcher.group(3));
            int beginIdx = 0;
            int count = 0;
            String paramType = null;
            String paramName = null;
            List paramLst = new ArrayList();

            while (matcher.find(beginIdx)) {
                int paramDim = 0;

                if (matcher.group(1) != null) {
                    paramType = matcher.group(2) + (matcher.group(4) != null ? matcher.group(4) : "");
                    paramName = matcher.group(3);
                } else {
                    paramType = matcher.group(6);
                    paramName = "_arg" + (count++);
                }

                // Now we need to parse paramType for it's dimensions
                Matcher dMatcher = dimensionPattern.matcher(paramType);

                if (dMatcher.find()) {
                    paramType = paramType.substring(0, dMatcher.start());
                    paramDim = 1;

                    while (dMatcher.find(dMatcher.end())) {
                        paramDim++;
                    }
                }

                paramLst.add(new JavaParameter(new Type(paramType, paramDim), paramName));

public class SystemPropertiesHandler {
    public static Map<String, String> getSystemProperties(String[] arguments) {
        Map<String, String> propertyMap = new HashMap<String, String>();
        Pattern pattern = Pattern.compile("-D([^=]*)=?(.*)");
        for (String argument : arguments) {
            Matcher matcher = pattern.matcher(argument);
            if (matcher.find()) {
                String key = matcher.group(1);
                String value = matcher.group(2);
                if (key.length() > 0) {
                    propertyMap.put(key, value);
                }
            }
        }

            throw new RuntimeException("Error when loading properties file=" + propertiesFile, e);
        }

        Pattern pattern = Pattern.compile("systemProp\\.(.*)");
        for (Object argument : properties.keySet()) {
            Matcher matcher = pattern.matcher(argument.toString());
            if (matcher.find()) {
                String key = matcher.group(1);
                if (key.length() > 0) {
                    propertyMap.put(key, properties.get(argument).toString());
                }
            }
        }

    }

    public JavaForkOptions jvmArgs(Iterable<?> arguments) {
        for (Object argument : arguments) {
            String argStr = argument.toString();
            Matcher matcher = sysPropPattern.matcher(argStr);
            if (matcher.matches()) {
                systemProperties.put(matcher.group(1), matcher.group(2));
                continue;
            }
            matcher = noArgSysPropPattern.matcher(argStr);
            if (matcher.matches()) {
                systemProperties.put(matcher.group(1), null);
                continue;
            }
            matcher = maxHeapPattern.matcher(argStr);
            if (matcher.matches()) {
                maxHeapSize = matcher.group(1);
                continue;
            }
            matcher = bootstrapPattern.matcher(argStr);
            if (matcher.matches()) {
                setBootstrapClasspath(getResolver().resolveFiles((Object[]) matcher.group(1).split(Pattern.quote(File.pathSeparator))));
                continue;
            }
            if (argStr.equals("-ea") || argStr.equals("-enableassertions")) {
                assertionsEnabled = true;
                continue;

    public static String toCamelCase(CharSequence string) {
        if (string == null) {
            return null;
        }
        StringBuilder builder = new StringBuilder();
        Matcher matcher = Pattern.compile("[^\\w]+").matcher(string);
        int pos = 0;
        while (matcher.find()) {
            builder.append(StringUtils.capitalize(string.subSequence(pos, matcher.start()).toString()));
            pos = matcher.end();
        }
        builder.append(StringUtils.capitalize(string.subSequence(pos, string.length()).toString()));
        return builder.toString();
    }

    protected boolean isRequestdForHandler(HttpRequest request) {
        return !request.isInternal();
    }

    protected boolean handleBody(HttpRequest request, HttpResponse response) throws IOException {
        Matcher urlMatch = rule.matcher( request.getUrl() );
        StringBuffer buffer = null;
        if(urlMatch.find()) {
            if( buffer == null ) {
                buffer = new StringBuffer( substitution );
            }
            int lastIndex = 0;
            do {

    }

   

    public void analyse(Parser parser, int range) {
        Matcher m = pattern.matcher(parser.get(range));
        if (!m.matches()) {
            parser.recordError(range, SCHEME_PATTERN_MATCH_FAILED);
            return;
        }
        for (int g = 1; g <= m.groupCount(); g++)
            if (m.start(g) != -1)
                actions[g].check(m, parser, range);

    }

    static final String emptyStringArray[] = new String[0];

    static private String[] mySplit(String p) {
        //return splitter.split(p);
       
        Matcher m = keyword.matcher(p);
        ArrayList rslt = new ArrayList();
        int pos = 0;
//        rslt.add("");
        while (m.find()) {
            if (m.start()>pos || pos==0) {
                rslt.add(p.substring(pos,m.start()));
            }
            rslt.add(p.substring(m.start(),m.end()));
            pos = m.end();
        }
        if (pos < p.length())
            rslt.add(p.substring(pos));
       
//        m.

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.