Return true if the given position, in the given pattern, appears
to be the start of a UnicodeSet pattern.
@hide unsupported on Android
978002
public static boolean resemblesPattern(String pattern, int pos) {
        return ((pos+1) < pattern.length() &&
                pattern.charAt(pos) == '[') ||
                resemblesPropertyPattern(pattern, pos);
    }
214244
static boolean matchForward(char[] chars, char[] pattern, int[] cursor) {
    if (pattern.length > cursor[1] - cursor[0])
      return false;
    int index = 0;
    while (index < pattern.length)
      if (chars[cursor[0]++] != pattern[index++])
        return false;
    return true;
  }
912622
private boolean matchLemmaRegexp(AnalyzedTokenReadings aToken,
      Pattern pattern) {
    boolean matches = false;
    for (AnalyzedToken analyzedToken : aToken) {
      final String posTag = analyzedToken.getLemma();
      if (posTag != null) {
        final Matcher m = pattern.matcher(posTag);
        if (m.matches()) {
          matches = true;
          break;
        }
      }
    }
    return matches;
  }
926948
public static boolean hasCharset(String ctype)
    {
        if (ctype == null)
        {
            return false;
        }
        Matcher matcher = CHARSET_PATT.matcher(ctype);
        if (matcher.find())
        {
            return true;
        }
        else
        {
            return false;
        }
    }
412705
private static boolean resemblesPropertyPattern(String pattern, int pos) {
        // Patterns are at least 5 characters long
        if ((pos+5) > pattern.length()) {
            return false;
        }

        // Look for an opening [:, [:^, \p, or \P
        return pattern.regionMatches(pos, "[:", 0, 2) ||
                pattern.regionMatches(true, pos, "\\p", 0, 2) ||
                pattern.regionMatches(pos, "\\N", 0, 2);
    }
706786
protected boolean verifyPatternMatch(String text) {
		if (this.expectedPattern == null) {
			return false;
		}
		return this.expectedPattern.matcher(text).matches();
	}
416467
boolean checkSuffix(char[] chars, int[] cursor) {
    if (suffix == null)
      return true;
    // Compute the only possible starting point. This only works because a clause's minlen
    // is an exact length for SQL-style patterns.  This method is overridden for topic
    // patterns.
    int start = cursor[1] - suffix.minlen;
    if (start < cursor[0])
      // candidate is too short to possibly match
      return false;
    if (!matchClause(suffix, chars, new int[] {start, cursor[1]}))
      return false;
    // The suffix matches, so reflect that in the cursor
    cursor[1] = start;
    return true;
  }
1240799
private static boolean doesNameMatchPattern(final Principal principal, final Pattern pattern) {
        if (pattern != null) {
            val name = principal.getName();
            val result = pattern.matcher(name).matches();
            LOGGER.debug("[{}] matches [{}] == [{}]", pattern.pattern(), name, result);
            return result;
        }
        return true;
    }
767865
public static boolean matches(String pattern, String value) {
        Pattern p = Pattern.compile(pattern);
        Matcher m = p.matcher(value);
        return m.matches();
    }
995272
public static final String convertPattern(String pattern) {
        if (pattern == null) {
            return null;
        }
        else {
            String convertedPattern = pattern;
            for (PatternConverter converter : PATTERN_CONVERTERS) {
                convertedPattern = converter.convert(convertedPattern);
            }

            return convertedPattern;
        }
    }
530895
public static boolean stringInPatterns(String s, List<Pattern> patterns) {
    for (Pattern pattern : patterns) {
      if (pattern.matcher(s).matches()) {
        return true;
      }
    }
    return false;
  }
725534
public boolean patternOverflow()
    {
        BitArray lin = new BitArray(width);
        bits.forEach((i)->lin.set(column(i), true));
        return lin.isSet(0) && lin.isSet(width-1);
    }
1282390
protected static boolean matchesOne(String str, Pattern... patterns) {
        for (Pattern pattern : patterns) {
            if (pattern.matcher(str).matches()) {
                return true;
            }
        }
        return false;
    }
1346395
public static final boolean isListItem(String pattern)
    {
        int idx = pattern.lastIndexOf(Lim);
        if (idx != -1)
        {
            try
            {
                Integer.parseInt(pattern.substring(idx+1));
                return true;
            }
            catch (NumberFormatException ex)
            {
                return false;
            }
        }
        else
        {
            return false;
        }
    }
1176701
void scanSet() {
        UnicodeSet uset = null;
        int startPos;
        ParsePosition pos = new ParsePosition(fScanIndex);
        int i;

        startPos = fScanIndex;
        try {
            uset = new UnicodeSet(fRB.fRules, pos, fSymbolTable, UnicodeSet.IGNORE_SPACE);
        } catch (Exception e) { // TODO:  catch fewer exception types.
            // Repackage UnicodeSet errors as RBBI rule builder errors, with location info.
            error(RBBIRuleBuilder.U_BRK_MALFORMED_SET);
        }

        // Verify that the set contains at least one code point.
        //
        if (uset.isEmpty()) {
            // This set is empty.
            //  Make it an error, because it almost certainly is not what the user wanted.
            //  Also, avoids having to think about corner cases in the tree manipulation code
            //   that occurs later on.
            //  TODO:  this shouldn't be an error; it does happen.
            error(RBBIRuleBuilder.U_BRK_RULE_EMPTY_SET);
        }

        // Advance the RBBI parse postion over the UnicodeSet pattern.
        //   Don't just set fScanIndex because the line/char positions maintained
        //   for error reporting would be thrown off.
        i = pos.getIndex();
        for (;;) {
            if (fNextIndex >= i) {
                break;
            }
            nextCharLL();
        }

        RBBINode n;

        n = pushNewNode(RBBINode.setRef);
        n.fFirstPos = startPos;
        n.fLastPos = fNextIndex;
        n.fText = fRB.fRules.substring(n.fFirstPos, n.fLastPos);
        //  findSetFor() serves several purposes here:
        //     - Adopts storage for the UnicodeSet, will be responsible for deleting.
        //     - Mantains collection of all sets in use, needed later for establishing
        //          character categories for run time engine.
        //     - Eliminates mulitiple instances of the same set.
        //     - Creates a new uset node if necessary (if this isn't a duplicate.)
        findSetFor(n.fText, n, uset);
    }
1063213
private int processSet(String regex, int i, StringBuilder result, UnicodeSet temp, ParsePosition pos) {
        try {
            pos.setIndex(i);
            UnicodeSet x = temp.clear().applyPattern(regex, pos, symbolTable, 0);
            x.complement().complement(); // hack to fix toPattern
            result.append(x.toPattern(false));
            i = pos.getIndex() - 1; // allow for the loop increment
            return i;
        } catch (Exception e) {
            throw (IllegalArgumentException) new IllegalArgumentException("Error in " + regex).initCause(e);
        }
    }
1232693
private void parsePattern(String pattern){

		int currentIndex = 0;
		int patternLength = pattern.length();
		Vector<FormatCommandInterface> converterVector = new Vector<FormatCommandInterface>(20);

		while (currentIndex < patternLength) {
			char currentChar = pattern.charAt(currentIndex);

			if (currentChar == '%') {

				currentIndex++;
				currentChar = pattern.charAt(currentIndex);

				switch (currentChar) {
					case CLIENT_ID_CONVERSION_CHAR:
						converterVector.addElement(new ClientIdFormatCommand());
						break;
					case CATEGORY_CONVERSION_CHAR:
						CategoryFormatCommand categoryFormatCommand = new CategoryFormatCommand();
						String specifier = extraxtSpecifier(pattern, currentIndex);
						int specifierLength = specifier.length();
						if (specifierLength > 0) {
							categoryFormatCommand.init(specifier);
							currentIndex = currentIndex + specifierLength + 2;
						}
						converterVector.addElement(categoryFormatCommand);
						break;
					case DATE_CONVERSION_CHAR:
						DateFormatCommand formatCommand = new DateFormatCommand();
						specifier = extraxtSpecifier(pattern, currentIndex);
						specifierLength = specifier.length();
						if (specifierLength > 0) {
							formatCommand.init(specifier);
							currentIndex = currentIndex + specifierLength + 2;
						}
						converterVector.addElement(formatCommand);
						break;
					case MESSAGE_CONVERSION_CHAR:
						converterVector.addElement(new MessageFormatCommand());
						break;

					case PRIORITY_CONVERSION_CHAR:
						converterVector.addElement(new PriorityFormatCommand());
						break;

					case RELATIVE_TIME_CONVERSION_CHAR:
						converterVector.addElement(new TimeFormatCommand());
						break;

					case THREAD_CONVERSION_CHAR:
						converterVector.addElement(new ThreadFormatCommand());
						break;

					case THROWABLE_CONVERSION_CHAR:
						converterVector.addElement(new ThrowableFormatCommand());
						break;

					case PERCENT_CONVERSION_CHAR:
						NoFormatCommand noFormatCommand = new NoFormatCommand();
						noFormatCommand.init("%");
						converterVector.addElement(noFormatCommand);
						break;

					default:
						Log.e(TAG, "Unrecognized conversion character " + currentChar);
						break;
				}

				currentIndex++;

			} else {

				int percentIndex = pattern.indexOf("%", currentIndex);
				String noFormatString = "";
				if (percentIndex != -1) {
					noFormatString = pattern.substring(currentIndex, percentIndex);
				} else {
					noFormatString = pattern.substring(currentIndex, patternLength);
				}

				NoFormatCommand noFormatCommand = new NoFormatCommand();
				noFormatCommand.init(noFormatString);
				converterVector.addElement(noFormatCommand);

				currentIndex = currentIndex + noFormatString.length();
			}

		}

		commandArray = new FormatCommandInterface[converterVector.size()];
		converterVector.copyInto(commandArray);

		patternParsed = true;
	}