Lines Matching defs:pattern

24  * A simple pattern matcher, which is safe to use on untrusted data: it does
30 * Pattern type: the given pattern must exactly match the string it is
36 * Pattern type: the given pattern must match the
42 * Pattern type: the given pattern is interpreted with a
53 * Pattern type: the given pattern is interpreted with a regular
59 * evaluation implementation in which matching is done against the pattern in
91 // workspace to use for building a parsed advanced pattern;
94 public PatternMatcher(String pattern, int type) {
95 mPattern = pattern;
98 mParsedPattern = parseAndVerifyAdvancedPattern(pattern);
162 static boolean matchPattern(String match, String pattern, int[] parsedPattern, int type) {
165 return pattern.equals(match);
167 return match.startsWith(pattern);
169 return matchGlobPattern(pattern, match);
176 static boolean matchGlobPattern(String pattern, String match) {
177 final int NP = pattern.length();
183 char nextChar = pattern.charAt(0);
187 nextChar = ip < NP ? pattern.charAt(ip) : 0;
192 nextChar = ip < NP ? pattern.charAt(ip) : 0;
197 // at the end with a pattern match, so
202 nextChar = pattern.charAt(ip);
204 // pattern is found.
207 nextChar = ip < NP ? pattern.charAt(ip) : 0;
216 // Whoops, the next character in the pattern didn't
221 nextChar = ip < NP ? pattern.charAt(ip) : 0;
232 nextChar = ip < NP ? pattern.charAt(ip) : 0;
246 // have a '.*' at the end of the pattern, which should still count
248 if (ip == NP-2 && pattern.charAt(ip) == '.'
249 && pattern.charAt(ip+1) == '*') {
257 * Parses the advanced pattern and returns an integer array representation of it. The integer
259 * negative. This method will throw on any pattern structure violations.
261 synchronized static int[] parseAndVerifyAdvancedPattern(String pattern) {
263 final int LP = pattern.length();
278 char c = pattern.charAt(ip);
286 if (pattern.charAt(ip + 1) == '^') {
292 ip++; // move to the next pattern char
351 throw new IllegalArgumentException("Escape found at end of pattern!");
353 c = pattern.charAt(++ip);
367 && pattern.charAt(ip + 1) == '-'
368 && pattern.charAt(ip + 2) != ']') {
378 int endOfSet = pattern.indexOf('}', ip);
382 String rangeString = pattern.substring(ip, endOfSet);
435 // The current character being analyzed in the pattern
442 while (ip < LP) { // we still have content in the pattern
460 ip++; // move the pointer to the next pattern entry