/** * Creates a matcher for a given combination of pattern and input. Both * elements can be changed later on. * * @param pattern * the pattern to use. * @param input * the input to use. */ Matcher(Pattern pattern, CharSequence input) { usePattern(pattern); reset(input); }
matcher.region(pos, end); if (hour == -1 && matcher.usePattern(TIME_PATTERN).matches()) { hour = Integer.parseInt(matcher.group(1)); minute = Integer.parseInt(matcher.group(2)); second = Integer.parseInt(matcher.group(3)); } else if (dayOfMonth == -1 && matcher.usePattern(DAY_OF_MONTH_PATTERN).matches()) { dayOfMonth = Integer.parseInt(matcher.group(1)); } else if (month == -1 && matcher.usePattern(MONTH_PATTERN).matches()) { String monthString = matcher.group(1).toLowerCase(Locale.US); month = MONTH_PATTERN.pattern().indexOf(monthString) / 4; // Sneaky! jan=1, dec=12. } else if (year == -1 && matcher.usePattern(YEAR_PATTERN).matches()) { year = Integer.parseInt(matcher.group(1));
/** * Skip over any whitespace so that the matcher region starts at the next * token. */ private void skipWhitespace() { matcher.usePattern(WHITESPACE); if (matcher.lookingAt()) { matcher.region(matcher.end(), matcher.regionEnd()); } }
/** * Skip over any whitespace so that the matcher region starts at the next * token. */ private void skipWhitespace() { matcher.usePattern(WHITESPACE); if (matcher.lookingAt()) { matcher.region(matcher.end(), matcher.regionEnd()); } }
matcher.region(pos, end); if (hour == -1 && matcher.usePattern(TIME_PATTERN).matches()) { hour = Integer.parseInt(matcher.group(1)); minute = Integer.parseInt(matcher.group(2)); second = Integer.parseInt(matcher.group(3)); } else if (dayOfMonth == -1 && matcher.usePattern(DAY_OF_MONTH_PATTERN).matches()) { dayOfMonth = Integer.parseInt(matcher.group(1)); } else if (month == -1 && matcher.usePattern(MONTH_PATTERN).matches()) { String monthString = matcher.group(1).toLowerCase(Locale.US); month = MONTH_PATTERN.pattern().indexOf(monthString) / 4; // Sneaky! jan=1, dec=12. } else if (year == -1 && matcher.usePattern(YEAR_PATTERN).matches()) { year = Integer.parseInt(matcher.group(1));
Pattern badflag = Pattern.compile("[a-z]+", 0xaaaaaa); Matcher am = okpat.matcher("hello, world"); am.usePattern(okpat); am.usePattern(null); try { String uee = new String(new byte[] { 'a', 'b' }, "unkown charset");
"' - it looks like an index name, which is not allowed." ); matcher.usePattern( PATTERN_INDEX_NAME_END ); if ( matcher.find() ) matcher.usePattern( PATTERN_PROPERTY_CLAUSE_BEGIN ); if ( !matcher.find() ) matcher.usePattern( PATTERN_FIRST_PROPERTY ); if ( !matcher.find() ) if ( matcher.pattern() != PATTERN_FOLLOWING_PROPERTY ) matcher.usePattern( PATTERN_FOLLOWING_PROPERTY ); matcher.usePattern( PATTERN_PROPERTY_CLAUSE_END ); if ( !matcher.find() )
matcher.region(pos, end); if (hour == -1 && matcher.usePattern(TIME_PATTERN).matches()) { hour = Integer.parseInt(matcher.group(1)); minute = Integer.parseInt(matcher.group(2)); second = Integer.parseInt(matcher.group(3)); } else if (dayOfMonth == -1 && matcher.usePattern(DAY_OF_MONTH_PATTERN).matches()) { dayOfMonth = Integer.parseInt(matcher.group(1)); } else if (month == -1 && matcher.usePattern(MONTH_PATTERN).matches()) { String monthString = matcher.group(1).toLowerCase(Locale.US); month = MONTH_PATTERN.pattern().indexOf(monthString) / 4; // Sneaky! jan=1, dec=12. } else if (year == -1 && matcher.usePattern(YEAR_PATTERN).matches()) { year = Integer.parseInt(matcher.group(1));
checkOpen(); matcher.usePattern(LINE_PATTERN); matcher.region(findStartIndex, bufferLength);
private boolean setTokenRegion() { // The position where token begins int tokenStartIndex = 0; // The position where token ends int tokenEndIndex = 0; // Use delimiter pattern matcher.usePattern(delimiter); matcher.region(findStartIndex, bufferLength); tokenStartIndex = findPreDelimiter(); if (setHeadTokenRegion(tokenStartIndex)) { return true; } tokenEndIndex = findDelimiterAfter(); // If the second delimiter is not found if (tokenEndIndex == -1) { // Just first Delimiter Exists if (findStartIndex == bufferLength) { return false; } tokenEndIndex = bufferLength; findStartIndex = bufferLength; } matcher.region(tokenStartIndex, tokenEndIndex); return true; }
int horizonLineSeparator = 0; matcher.usePattern(MULTI_LINE_TERMINATOR); matcher.region(findStartIndex, bufferLength); matcher.usePattern(pattern);
matcher.usePattern(TOKEN); if (matcher.lookingAt()) { currentToken = matcher.group();
matcher.usePattern(TOKEN); if (matcher.lookingAt()) { currentToken = matcher.group();
checkOpen(); checkNotNull(pattern); matcher.usePattern(pattern); matcher.region(findStartIndex, bufferLength); while (true) {
throw new IllegalArgumentException("horizon < 0"); matcher.usePattern(pattern);
matcher.usePattern(pattern); if (!matcher.matches()) { recoverPreviousStatus();
return false; matcher.usePattern(pattern); boolean hasNext = false;
/** * Skip over any whitespace so that the matcher region starts at the next token. */ private void skipWhitespace() { matcher.usePattern(WHITESPACE); if (matcher.lookingAt()) { matcher.region(matcher.end(), matcher.regionEnd()); } }
matcher.usePattern(TOKEN); if (matcher.lookingAt()) { currentToken = matcher.group();
for (Rule r : rules) if (m.usePattern(r.pattern).lookingAt())