/** * Constructs a set from the given pattern. See the class description * for the syntax of the pattern language. Whitespace is ignored. * @param pattern a string specifying what characters are in the set * @exception java.lang.IllegalArgumentException if the pattern contains * a syntax error. * @stable ICU 2.0 */ public UnicodeSet(String pattern) { this(); applyPattern(pattern, null, null, IGNORE_SPACE); }
/** * Constructs a set from the given pattern. See the class description * for the syntax of the pattern language. * @param pattern a string specifying what characters are in the set * @param ignoreWhitespace if true, ignore Unicode Pattern_White_Space characters * @exception java.lang.IllegalArgumentException if the pattern contains * a syntax error. * @stable ICU 2.0 */ public UnicodeSet(String pattern, boolean ignoreWhitespace) { this(); applyPattern(pattern, null, null, ignoreWhitespace ? IGNORE_SPACE : 0); }
/** * Constructs a set from the given pattern. See the class description * for the syntax of the pattern language. * @param pattern a string specifying what characters are in the set * @param options a bitmask indicating which options to apply. * Valid options are IGNORE_SPACE and CASE. * @exception java.lang.IllegalArgumentException if the pattern contains * a syntax error. * @stable ICU 3.8 */ public UnicodeSet(String pattern, int options) { this(); applyPattern(pattern, null, null, options); }
/** * Constructs a set from the given pattern. See the class description * for the syntax of the pattern language. * @param pattern a string specifying what characters are in the set * @param pos on input, the position in pattern at which to start parsing. * On output, the position after the last character parsed. * @param symbols a symbol table mapping variables to char[] arrays * and chars to UnicodeSets * @exception java.lang.IllegalArgumentException if the pattern * contains a syntax error. * @stable ICU 2.0 */ public UnicodeSet(String pattern, ParsePosition pos, SymbolTable symbols) { this(); applyPattern(pattern, pos, symbols, IGNORE_SPACE); }
/** * Constructs a set from the given pattern. See the class description * for the syntax of the pattern language. * @param pattern a string specifying what characters are in the set * @param pos on input, the position in pattern at which to start parsing. * On output, the position after the last character parsed. * @param symbols a symbol table mapping variables to char[] arrays * and chars to UnicodeSets * @param options a bitmask indicating which options to apply. * Valid options are IGNORE_SPACE and CASE. * @exception java.lang.IllegalArgumentException if the pattern * contains a syntax error. * @stable ICU 3.2 */ public UnicodeSet(String pattern, ParsePosition pos, SymbolTable symbols, int options) { this(); applyPattern(pattern, pos, symbols, options); }
/** * Modifies this set to represent the set specified by the given pattern, * optionally ignoring whitespace. * See the class description for the syntax of the pattern language. * @param pattern a string specifying what characters are in the set * @param options a bitmask indicating which options to apply. * Valid options are IGNORE_SPACE and CASE. * @exception java.lang.IllegalArgumentException if the pattern * contains a syntax error. * @stable ICU 3.8 */ public UnicodeSet applyPattern(String pattern, int options) { checkFrozen(); return applyPattern(pattern, null, null, options); }
/** * Modifies this set to represent the set specified by the given pattern. * See the class description for the syntax of the pattern language. * Whitespace is ignored. * @param pattern a string specifying what characters are in the set * @exception java.lang.IllegalArgumentException if the pattern * contains a syntax error. * @stable ICU 2.0 */ public final UnicodeSet applyPattern(String pattern) { checkFrozen(); return applyPattern(pattern, null, null, IGNORE_SPACE); }
/** * Modifies this set to represent the set specified by the given pattern, * optionally ignoring whitespace. * See the class description for the syntax of the pattern language. * @param pattern a string specifying what characters are in the set * @param ignoreWhitespace if true then Unicode Pattern_White_Space characters are ignored * @exception java.lang.IllegalArgumentException if the pattern * contains a syntax error. * @stable ICU 2.0 */ public UnicodeSet applyPattern(String pattern, boolean ignoreWhitespace) { checkFrozen(); return applyPattern(pattern, null, null, ignoreWhitespace ? IGNORE_SPACE : 0); }
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); } }
private int parseUnicodeSet(int i, UnicodeSet set) throws ParseException { // Collect a UnicodeSet pattern between a balanced pair of [brackets]. int level = 0; int j = i; for(;;) { if(j == rules.length()) { setParseError("unbalanced UnicodeSet pattern brackets"); return j; } char c = rules.charAt(j++); if(c == 0x5b) { // '[' ++level; } else if(c == 0x5d) { // ']' if(--level == 0) { break; } } } try { set.applyPattern(rules.substring(i, j)); } catch(Exception e) { setParseError("not a valid UnicodeSet pattern: " + e.getMessage()); } j = skipWhiteSpace(j); if(j == rules.length() || rules.charAt(j) != 0x5d) { setParseError("missing option-terminating ']' after UnicodeSet pattern"); return j; } return ++j; }
RuleCharacterIterator chars = new RuleCharacterIterator(pattern, symbols, pos); applyPattern(chars, symbols, rebuiltPat, options); if (chars.inVariable()) { syntaxError(chars, "Extra chars in variable value");
nested.applyPattern(chars, symbols, patBuf, options); break; case SETMODE2_PROPERTYPAT: