Top Description Inners Fields Constructors Methods
com.ibm.icu.text

public Class UnicodeSet

extends UnicodeFilter
implements Iterable<String>, Comparable<UnicodeSet>, Freezable<UnicodeSet>
Class Inheritance
All Implemented Interfaces
com.ibm.icu.util.Freezable, java.lang.Cloneable, java.lang.Comparable, java.lang.Iterable
Imports
java.io.IOException, java.text.ParsePosition, java.util.ArrayList, .Arrays, .Collection, .Collections, .Iterator, .NoSuchElementException, .SortedSet, .TreeSet, com.ibm.icu.impl.BMPSet, .CharacterPropertiesImpl, .PatternProps, .RuleCharacterIterator, .SortedSetRelation, .StringRange, .UCaseProps, .UPropertyAliases, .UnicodeSetStringSpan, .Utility, com.ibm.icu.lang.CharSequences, .CharacterProperties, .UCharacter, .UProperty, .UScript, com.ibm.icu.util.Freezable, .ICUUncheckedIOException, .OutputInt, .ULocale, .VersionInfo

A mutable set of Unicode characters and multicharacter strings. Objects of this class represent character classes used in regular expressions. A character specifies a subset of Unicode code points. Legal code points are U+0000 to U+10FFFF, inclusive.

Note

method freeze() will not only make the set immutable, but also makes important methods much higher performance: contains(c), containsNone(...), span(...), spanBack(...) etc. After the object is frozen, any subsequent call that wants to change the object will throw UnsupportedOperationException.

The UnicodeSet class is not designed to be subclassed.

UnicodeSet supports two APIs. The first is the operand API that allows the caller to modify the value of a UnicodeSet object. It conforms to Java 2's java.util.Set interface, although UnicodeSet does not actually implement that interface. All methods of Set are supported, with the modification that they take a character range or single character instead of an Object, and they take a UnicodeSet instead of a Collection. The operand API may be thought of in terms of boolean logic: a boolean OR is implemented by add, a boolean AND is implemented by retain, a boolean XOR is implemented by complement taking an argument, and a boolean NOT is implemented by complement with no argument. In terms of traditional set theory function names, add is a union, retain is an intersection, remove is an asymmetric difference, and complement with no argument is a set complement with respect to the superset range MIN_VALUE-MAX_VALUE

The second API is the applyPattern()/toPattern() API from the java.text.Format-derived classes. Unlike the methods that add characters, add categories, and control the logic of the set, the method applyPattern() sets all attributes of a UnicodeSet at once, based on a string pattern.

Pattern syntax

Patterns are accepted by the constructors and the applyPattern() methods and returned by the toPattern() method. These patterns follow a syntax similar to that employed by version 8 regular expression character classes. Here are some simple examples:
[] No characters
[a] The character 'a'
[ae] The characters 'a' and 'e'
[a-e] The characters 'a' through 'e' inclusive, in Unicode code point order
[\\u4E01] The character U+4E01
[a{ab}{ac}] The character 'a' and the multicharacter strings "ab" and "ac"
[\p{Lu}] All characters in the general category Uppercase Letter
Any character may be preceded by a backslash in order to remove any special meaning. White space characters, as defined by the Unicode Pattern_White_Space property, are ignored, unless they are escaped.

Property patterns specify a set of characters having a certain property as defined by the Unicode standard. Both the POSIX-like "[:Lu:]" and the Perl-like syntax "\p{Lu}" are recognized. For a complete list of supported property patterns, see the User's Guide for UnicodeSet at https://unicode-org.github.io/icu/userguide/strings/unicodeset. Actual determination of property data is defined by the underlying Unicode database as implemented by UCharacter.

Patterns specify individual characters, ranges of characters, and Unicode property sets. When elements are concatenated, they specify their union. To complement a set, place a '^' immediately after the opening '['. Property patterns are inverted by modifying their delimiters; "[:^foo]" and "\P{foo}". In any other location, '^' has no special meaning.

Since ICU 70, "[^...]", "[:^foo]", "\P{foo}", and "[:binaryProperty=No:]" perform a “code point complement” (all code points minus the original set), removing all multicharacter strings, equivalent to .complement().removeAllStrings() . The complement() API function continues to perform a symmetric difference with all code points and thus retains all multicharacter strings.

Ranges are indicated by placing two a '-' between two characters, as in "a-z". This specifies the range of all characters from the left to the right, in Unicode order. If the left character is greater than or equal to the right character it is a syntax error. If a '-' occurs as the first character after the opening '[' or '[^', or if it occurs as the last character before the closing ']', then it is taken as a literal. Thus "[a\\-b]", "[-ab]", and "[ab-]" all indicate the same set of three characters, 'a', 'b', and '-'.

Sets may be intersected using the '&' operator or the asymmetric set difference may be taken using the '-' operator, for example, "[[:L:]&[\\u0000-\\u0FFF]]" indicates the set of all Unicode letters with values less than 4096. Operators ('&' and '|') have equal precedence and bind left-to-right. Thus "[[:L:]-[a-z]-[\\u0100-\\u01FF]]" is equivalent to "[[[:L:]-[a-z]]-[\\u0100-\\u01FF]]". This only really matters for difference; intersection is commutative.

[a]The set containing 'a'
[a-z]The set containing 'a' through 'z' and all letters in between, in Unicode order
[^a-z]The set containing all characters but 'a' through 'z', that is, U+0000 through 'a'-1 and 'z'+1 through U+10FFFF
[[pat1][pat2]] The union of sets specified by pat1 and pat2
[[pat1]&[pat2]] The intersection of sets specified by pat1 and pat2
[[pat1]-[pat2]] The asymmetric difference of sets specified by pat1 and pat2
[:Lu:] or \p{Lu} The set of characters having the specified Unicode property; in this case, Unicode uppercase letters
[:^Lu:] or \P{Lu} The set of characters not having the given Unicode property

Formal syntax

pattern :=  ('[' '^'? item* ']') | property
item :=  char | (char '-' char) | pattern-expr
pattern-expr :=  pattern | pattern-expr pattern | pattern-expr op pattern
op :=  '&' | '-'
special :=  '[' | ']' | '-'
char :=  any character that is not special
| ('\\'
any character)
| ('\u' hex hex hex hex)
hex :=  '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' |
    'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f'
property :=  a Unicode property set pattern

Legend:
a := b   a may be replaced by b
a? zero or one instance of a
a* one or more instances of a
a | b either a or b
'a' the literal string between the quotes

To iterate over contents of UnicodeSet, the following are available:

All of the above can be used in for loops. The UnicodeSetIterator can also be used, but not in for loops.

To replace, count elements, or delete spans, see UnicodeSetSpanner.

Author
Alan Liu
ICU Status
Stable since ICU 2.0.
See Also
UnicodeSetIterator, UnicodeSetSpanner

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
public static class
UnicodeSet.EntryRange

A struct-like class used for iteration through ranges, for faster iteration than by String.

private class
private class
private static interface
private static class
private static class
private static class
private static class
public static enum
UnicodeSet.SpanCondition

Argument values for whether span() and similar functions continue while the current character is contained vs. not contained in the set.

private static class
private static class
public abstract static class
UnicodeSet.XSymbolTable

Internal class for customizing UnicodeSet parsing of properties.

Field Summary

Modifier and TypeField and Description
public static final int
ADD_CASE_MAPPINGS

Adds all case mappings for each element in the set.

public static final UnicodeSet
ALL_CODE_POINTS

Constant for the set of all code points.

private static final String
private static final String
private static final String
private volatile BMPSet
private int[]
public static final int
public static final int
CASE_INSENSITIVE

Enable case insensitive matching.

private static final int
public static final UnicodeSet
EMPTY

Constant for the empty set.

private static final SortedSet<String>
private static final int
public static final int
IGNORE_SPACE

Bitmask for constructor and applyPattern() indicating that white space should be ignored.

private static final int
INITIAL_CAPACITY

Enough for sets with few ranges.

private static final int
private static final int
private static final int
private int
private int[]
private static final int
private static final int
private static final int
MAX_LENGTH

Max list [0, 1, 2, ..., max code point, HIGH]

public static final int
MAX_VALUE

Maximum value that can be stored in a UnicodeSet.

public static final int
MIN_VALUE

Minimum value that can be stored in a UnicodeSet.

private static final int
private static final int
private static final int
private static final VersionInfo
private String
pat

The pattern representation of this set.

private int[]
private static final int
private static final int
private static final int
private static final int
public static final int
SIMPLE_CASE_INSENSITIVE

Enable case insensitive matching.

pack-priv SortedSet<String>
private volatile UnicodeSetStringSpan
private static UnicodeSet.XSymbolTable

Constructor Summary

AccessConstructor and Description
public
UnicodeSet()

Constructs an empty set.

public
UnicodeSet(UnicodeSet other)

Constructs a copy of an existing set.

public
UnicodeSet(int
first character, inclusive, of range
start
,
int
last character, inclusive, of range
end
)

Constructs a set containing the given range.

public
UnicodeSet(int...
pairs of character representing ranges
pairs
)

Quickly constructs a set from a set of ranges <s0, e0, s1, e1, s2, e2, ..., sn, en>.

public
UnicodeSet(String
a string specifying what characters are in the set
pattern
)

Constructs a set from the given pattern.

public
UnicodeSet(String
a string specifying what characters are in the set
pattern
,
boolean
if true, ignore Unicode Pattern_White_Space characters
ignoreWhitespace
)

Constructs a set from the given pattern.

public
UnicodeSet(String
a string specifying what characters are in the set
pattern
,
int
a bitmask indicating which options to apply. Valid options are IGNORE_SPACE and at most one of CASE_INSENSITIVE, ADD_CASE_MAPPINGS, SIMPLE_CASE_INSENSITIVE. These case options are mutually exclusive.
options
)

Constructs a set from the given pattern.

public
UnicodeSet(String
a string specifying what characters are in the set
pattern
,
ParsePosition
on input, the position in pattern at which to start parsing. On output, the position after the last character parsed.
pos
,
SymbolTable
a symbol table mapping variables to char[] arrays and chars to UnicodeSets
symbols
)

Constructs a set from the given pattern.

public
UnicodeSet(String
a string specifying what characters are in the set
pattern
,
ParsePosition
on input, the position in pattern at which to start parsing. On output, the position after the last character parsed.
pos
,
SymbolTable
a symbol table mapping variables to char[] arrays and chars to UnicodeSets
symbols
,
int
a bitmask indicating which options to apply. Valid options are IGNORE_SPACE and at most one of CASE_INSENSITIVE, ADD_CASE_MAPPINGS, SIMPLE_CASE_INSENSITIVE. These case options are mutually exclusive.
options
)

Constructs a set from the given pattern.

Method Summary

Modifier and TypeMethod and Description
private static <T extends Appendable> T
_appendToPat(T buf, String s, boolean escapeUnprintable)

Append the toPattern() representation of a string to the given Appendable.

private static <T extends Appendable> T
_appendToPat(T buf, int c, boolean escapeUnprintable)

Append the toPattern() representation of a character to the given Appendable.

private static <T extends Appendable> T
_appendToPat(T result, int start, int end, boolean escapeUnprintable)

public StringBuffer
_generatePattern(StringBuffer
the buffer into which to generate the pattern
result
,
boolean
escape unprintable characters if true
escapeUnprintable
)

Generate and append a string representation of this set to result.

public StringBuffer
_generatePattern(StringBuffer
the buffer into which to generate the pattern
result
,
boolean
escape unprintable characters if true
escapeUnprintable
,
boolean
if false, doesn't include the strings.
includeStrings
)

Generate and append a string representation of this set to result.

private <T extends Appendable> T
_toPattern(T result, boolean escapeUnprintable)

Append a string representation of this set to result.

public UnicodeSet
add(int
first character, inclusive, of range to be added to this set.
start
,
int
last character, inclusive, of range to be added to this set.
end
)

Adds the specified range to this set if it is not already present.

public final UnicodeSet
add(int c)

Adds the specified character to this set if it is not already present.

public final UnicodeSet

Returns:

this object, for chaining
add
(CharSequence
the source string
s
)

Adds the specified multicharacter to this set if it is not already present.

public UnicodeSet

Returns:

a reference to this object
add
(Iterable<?>
the collection to add
source
)

Add the contents of the collection (as strings) into this UnicodeSet.

private UnicodeSet
add(int[] other, int otherLen, int polarity)

private UnicodeSet
add_unchecked(int start, int end)

private final UnicodeSet
public UnicodeSet

Returns:

a reference to this object
addAll
(int
The index of where to start on adding all characters.
start
,
int
The index of where to end on adding all characters.
end
)

Adds all characters in range (uses preferred naming convention).

public final UnicodeSet

Returns:

this object, for chaining
addAll
(CharSequence
the source string
s
)

Adds each of the characters in this string to the set.

public UnicodeSet
addAll(UnicodeSet
set whose elements are to be added to this set.
c
)

Adds all of the elements in the specified set to this set if they're not already present.

public UnicodeSet

Returns:

a reference to this object
addAll
(Iterable<?>
collection to add into
source
)

Add a collection (as strings) into this UnicodeSet.

public <T extends CharSequence> UnicodeSet
addAll(T... collection)

public <T extends Collection<String>> T
addAllTo(T
collection to add into
target
)

Add the contents of the UnicodeSet (as strings) into a collection.

public String[]
addAllTo(String[]
collection to add into
target
)

Add the contents of the UnicodeSet (as strings) into a collection.

public static <T, U extends Collection<T>> U
addAllTo(Iterable<T> source, U target)

Utility for adding the contents of an iterable to a collection.

public static <T> T[]
addAllTo(Iterable<T> source, T[] target)

Utility for adding the contents of an iterable to a collection.

public UnicodeSet

Returns:

the input set, modified
addBridges
(UnicodeSet
Set with the don't-care characters for spanning
dontCare
)

Deprecated This API is ICU internal only.
Simplify the ranges in a Unicode set by merging any ranges that are only separated by characters in the dontCare set.
private static final void
addCaseMapping(UnicodeSet set, int result, StringBuilder full)

public void
addMatchSetTo(UnicodeSet
the set into which to union the source characters
toUnionTo
)

Implements com.ibm.icu.text.UnicodeMatcher.addMatchSetTo.

Implementation of UnicodeMatcher API.
private void
private static void
append(Appendable app, CharSequence s)

Todo

create class Appendables?

private static void
appendCodePoint(Appendable app, int c)

Todo

create Appendable version of UTF16.append(buf, c), maybe in new class Appendables?

private <T extends Appendable> T
appendNewPattern(T result, boolean escapeUnprintable, boolean includeStrings)

private void
applyFilter(UnicodeSet.Filter filter, UnicodeSet inclusions)

Generic filter-based scanning code for UCD property UnicodeSets.

public UnicodeSet

Returns:

a reference to this set
applyIntPropertyValue
(int
a property in the range UProperty.BIN_START..UProperty.BIN_LIMIT-1 or UProperty.INT_START..UProperty.INT_LIMIT-1 or. UProperty.MASK_START..UProperty.MASK_LIMIT-1.
prop
,
int
a value in the range UCharacter.getIntPropertyMinValue(prop).. UCharacter.getIntPropertyMaxValue(prop), with one exception. If prop is UProperty.GENERAL_CATEGORY_MASK, then value should not be a UCharacter.getType() result, but rather a mask value produced by logically ORing (1 << UCharacter.getType()) values together. This allows grouped categories such as [:L:] to be represented.
value
)

Modifies this set to contain those code points which have the given value for the given binary or enumerated property, as returned by UCharacter.getIntPropertyValue.

public final UnicodeSet
applyPattern(String
a string specifying what characters are in the set
pattern
)

Modifies this set to represent the set specified by the given pattern.

public UnicodeSet
applyPattern(String
a string specifying what characters are in the set
pattern
,
boolean
if true then Unicode Pattern_White_Space characters are ignored
ignoreWhitespace
)

Modifies this set to represent the set specified by the given pattern, optionally ignoring whitespace.

public UnicodeSet
applyPattern(String
a string specifying what characters are in the set
pattern
,
int
a bitmask indicating which options to apply. Valid options are IGNORE_SPACE and at most one of CASE_INSENSITIVE, ADD_CASE_MAPPINGS, SIMPLE_CASE_INSENSITIVE. These case options are mutually exclusive.
options
)

Modifies this set to represent the set specified by the given pattern, optionally ignoring whitespace.

public UnicodeSet

Returns:

an inversion list for the parsed substring of pattern
applyPattern
(String
the string containing the pattern to be parsed. The portion of the string from pos.getIndex(), which must be a '[', to the corresponding closing ']', is parsed.
pattern
,
ParsePosition
upon entry, the position at which to being parsing. The character at pattern.charAt(pos.getIndex()) must be a '['. Upon return from a successful parse, pos.getIndex() is either the character after the closing ']' of the parsed pattern, or pattern.length() if the closing ']' is the last character of the pattern string.
pos
,
SymbolTable symbols, int options)

Deprecated This API is ICU internal only.
Parses the given pattern, starting at the given position.
private void
applyPattern(RuleCharacterIterator
iterator over the pattern characters. Upon return it will be advanced to the first character after the parsed pattern, or the end of the iteration if all characters are parsed.
chars
,
SymbolTable
symbol table to use to parse and dereference variables, or null if none.
symbols
,
Appendable
the pattern that was parsed, rebuilt or copied from the input pattern, as appropriate.
rebuiltPat
,
int
a bit mask. Valid options are IGNORE_SPACE and at most one of CASE_INSENSITIVE, ADD_CASE_MAPPINGS, SIMPLE_CASE_INSENSITIVE. These case options are mutually exclusive.
options
,
int depth)

Parse the pattern from the given RuleCharacterIterator.

public UnicodeSet

Returns:

a reference to this set
applyPropertyAlias
(String
a property alias, either short or long. The name is matched loosely. See PropertyAliases.txt for names and a description of loose matching. If the value string is empty, then this string is interpreted as either a General_Category value alias, a Script value alias, a binary property alias, or a special ID. Special IDs are matched loosely and correspond to the following sets: "ANY" = [\\u0000-\\U0010FFFF], "ASCII" = [\\u0000-\\u007F].
propertyAlias
,
String
a value alias, either short or long. The name is matched loosely. See PropertyValueAliases.txt for names and a description of loose matching. In addition to aliases listed, numeric values and canonical combining classes may be expressed numerically, e.g., ("nv", "0.5") or ("ccc", "220"). The value string may also be empty.
valueAlias
)

Modifies this set to contain those code points which have the given value for the given property.

public UnicodeSet

Returns:

this set
applyPropertyAlias
(String
A string of the property alias.
propertyAlias
,
String
A string of the value alias.
valueAlias
,
SymbolTable
if not null, then symbols are first called to see if a property is available. If true, then everything else is skipped.
symbols
)

Modifies this set to contain those code points which have the given value for the given property.

private UnicodeSet
applyPropertyPattern(String pattern, ParsePosition ppos, SymbolTable
TODO
symbols
)

Parse the given property pattern at the given parse position.

private void
applyPropertyPattern(RuleCharacterIterator
iterator over the pattern characters. Upon return it will be advanced to the first character after the parsed pattern, or the end of the iteration if all characters are parsed.
chars
,
Appendable
the pattern that was parsed, rebuilt or copied from the input pattern, as appropriate.
rebuiltPat
,
SymbolTable
TODO
symbols
)

Parse a property pattern.

public int

Returns:

the character at the given index, or -1.
charAt
(int
an index from 0..size()-1
index
)

Returns the character at the given index within this set, where the set is ordered by ascending code point.

private void
public UnicodeSet
clear()

Removes all of the elements from this set.

public Object
clone()

Overrides java.lang.Object.clone.

Return a new set that is equivalent to this one.
public UnicodeSet

Returns:

the clone, not frozen
cloneAsThawed
()

Implements com.ibm.icu.util.Freezable.cloneAsThawed.

Clone a thawed version of this class, according to the Freezable interface.
public UnicodeSet

Returns:

a reference to this set.
closeOver
(int
bitmask for attributes to close over. Valid options: At most one of CASE_INSENSITIVE, ADD_CASE_MAPPINGS, SIMPLE_CASE_INSENSITIVE. These case options are mutually exclusive. Unrelated options bits are ignored.
attribute
)

Close this set over the given attribute.

private void
private void
closeOverCaseInsensitive(boolean simple)

public UnicodeSet
compact()

Reallocate this objects internal structures to take up the least possible space, without changing this object's value.

public static int
compare(CharSequence string, int codePoint)

Utility to compare a string to a code point.

public static int
compare(int codePoint, CharSequence string)

Utility to compare a string to a code point.

public static <T extends Comparable<T>> int
compare(Iterable<T> collection1, Iterable<T> collection2)

Utility to compare two iterables.

public static <T extends Comparable<T>> int
compare(Iterator<T> first, Iterator<T> other)

Deprecated This API is ICU internal only.
Utility to compare two iterators.
public static <T extends Comparable<T>> int
compare(Collection<T> collection1, Collection<T> collection2, UnicodeSet.ComparisonStyle style)

Utility to compare two collections, optionally by size, and then lexicographically.

public int
compareTo(UnicodeSet
the object to be compared.
o
)

Implements java.lang.Comparable.compareTo.

Compares UnicodeSets, where shorter come first, and otherwise lexicographically (according to the comparison of the first characters that differ).
public int
compareTo(UnicodeSet o, UnicodeSet.ComparisonStyle style)

Compares UnicodeSets, in three different ways.

public int
compareTo(Iterable<String>
the object to be compared.
other
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.
public UnicodeSet
complement(int
first character, inclusive, of range
start
,
int
last character, inclusive, of range
end
)

Complements the specified range in this set.

public final UnicodeSet
complement(int c)

Complements the specified character in this set.

public UnicodeSet
complement()

This is equivalent to complement(MIN_VALUE, MAX_VALUE).

public final UnicodeSet

Returns:

this object, for chaining
complement
(CharSequence
the string to complement
s
)

Complement the specified string in this set.

public final UnicodeSet

Returns:

this object, for chaining
complementAll
(CharSequence
the source string
s
)

Complement EACH of the characters in this string.

public UnicodeSet
complementAll(UnicodeSet
set that defines which elements will be complemented from this set.
c
)

Complements in this set all elements contained in the specified set.

public boolean

Returns:

true if the test condition is met
contains
(int
character to be checked for containment
c
)

Implements abstract com.ibm.icu.text.UnicodeFilter.contains.

Returns true if this set contains the given character.
public boolean

Returns:

true if the test condition is met
contains
(int
first character, inclusive, of the range
start
,
int
last character, inclusive, of the range
end
)

Returns true if this set contains every character of the given range.

public final boolean

Returns:

true if this set contains the specified string
contains
(CharSequence
string to be checked for containment
s
)

Returns true if this set contains the given multicharacter string.

public boolean

Returns:

true if the test condition is met
containsAll
(UnicodeSet
set to be checked for containment
b
)

Returns true if this set contains all the characters and strings of the given set.

public boolean

Returns:

true if the test condition is met
containsAll
(String
string containing characters to be checked for containment
s
)

Returns true if there is a partition of the string such that this set contains each of the partitioned strings.

private boolean

Returns:

true if ok
containsAll
(String
source string
s
,
int
point to match to the end on
i
)

Recursive routine called if we fail to find a match in containsAll, and there are strings

public <T extends CharSequence> boolean
containsAll(Iterable<T> collection)

public boolean

Returns:

true if the test condition is met
containsNone
(int
first character, inclusive, of the range
start
,
int
last character, inclusive, of the range
end
)

Returns true if this set contains none of the characters of the given range.

public boolean

Returns:

true if the test condition is met
containsNone
(UnicodeSet
set to be checked for containment
b
)

Returns true if none of the characters or strings in this UnicodeSet appears in the string.

public boolean

Returns:

true if the test condition is met
containsNone
(CharSequence
string containing characters to be checked for containment
s
)

Returns true if this set contains none of the characters of the given string.

public <T extends CharSequence> boolean
containsNone(Iterable<T> collection)

public final boolean

Returns:

true if the condition is met
containsSome
(int
first character, inclusive, of the range
start
,
int
last character, inclusive, of the range
end
)

Returns true if this set contains one or more of the characters in the given range.

public final boolean

Returns:

true if the condition is met
containsSome
(UnicodeSet
set to be checked for containment
s
)

Returns true if this set contains one or more of the characters and strings of the given set.

public final boolean

Returns:

true if the condition is met
containsSome
(CharSequence
string containing characters to be checked for containment
s
)

Returns true if this set contains one or more of the characters of the given string.

public final <T extends CharSequence> boolean
containsSome(Iterable<T> collection)

private void
private void
ensureCapacity(int newLen)

public boolean

Returns:

true if the specified Object is equal to this set.
equals
(Object
Object to be compared for equality with this set.
o
)

Overrides java.lang.Object.equals.

Compares the specified object with this set for equality.
private final int

Returns:

the smallest integer i in the range 0..len-1, inclusive, such that c < list[i]
findCodePoint
(int
a character in the range MIN_VALUE..MAX_VALUE inclusive
c
)

Returns the smallest value i such that c < list[i].

public int
findIn(CharSequence value, int fromIndex, boolean findNot)

Deprecated This API is ICU internal only. Use span instead.
Find the first index at or after fromIndex where the UnicodeSet matches at that index.
public int
findLastIn(CharSequence value, int fromIndex, boolean findNot)

Deprecated This API is ICU internal only. Use spanBack instead.
Find the last index before fromIndex where the UnicodeSet matches at that index.
public UnicodeSet

Returns:

this
freeze
()

Implements com.ibm.icu.util.Freezable.freeze.

Freeze this class, according to the Freezable interface.
public static UnicodeSet

Returns:

a newly created set containing the given string
from
(CharSequence
the source string
s
)

Makes a set from a multicharacter string.

public static UnicodeSet

Returns:

a newly created set containing the given characters
fromAll
(CharSequence
the source string
s
)

Makes a set from each of the characters in the string.

public static UnicodeSet.XSymbolTable

Returns:

the symbol table
getDefaultXSymbolTable
()

Deprecated This API is ICU internal only.
Get the default symbol table.
public int
getRangeCount()

Iteration method that returns the number of ranges contained in this set.

public int
getRangeEnd(int index)

Iteration method that returns the last character in the specified range of this set.

public int
getRangeStart(int index)

Iteration method that returns the first character in the specified range of this set.

public String

Returns:

regex pattern equivalent to this UnicodeSet
getRegexEquivalent
()

Deprecated This API is ICU internal only.
Get the Regex equivalent for this UnicodeSet
public static int
getSingleCodePoint(CharSequence s)

Deprecated This API is ICU internal only.
Return the value of the first code point, if the string is exactly one code point.
private static int

Returns:

a code point IF the string consists of a single one. otherwise returns -1.
getSingleCP
(CharSequence
to test
s
)

Utility for getting code point from single code point CharSequence.

public int

Returns:

the hash code value for this set.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns the hash code value for this set.
public boolean

Returns:

true if this set contains multi-character strings or the empty string.
hasStrings
()

public int

Returns:

an index from 0..size()-1, or -1
indexOf
(int c)

Returns the index of the given character within this set, where the set is ordered by ascending code point.

public boolean

Returns:

true if this set contains no elements.
isEmpty
()

Returns true if this set contains no elements.

public boolean

Returns:

value
isFrozen
()

Implements com.ibm.icu.util.Freezable.isFrozen.

Is this frozen, according to the Freezable interface?
public Iterator<String>
iterator()

Implements java.lang.Iterable.iterator.

Returns a string iterator.
public int
matches(Replaceable
the text to be matched
text
,
int[]
on input, the index into text at which to begin matching. On output, the limit of the matched text. The number of matched characters is the output value of offset minus the input value. Offset should always point to the HIGH SURROGATE (leading code unit) of a pair of surrogates, both on entry and upon return.
offset
,
int
the limit index of text to be matched. Greater than offset for a forward direction match, less than offset for a backward direction match. The last character to be considered for matching will be text.charAt(limit-1) in the forward direction or text.charAt(limit+1) in the backward direction.
limit
,
boolean
if true, then assume further characters may be inserted at limit and check for partial matching. Otherwise assume the text as given is complete.
incremental
)

Overrides com.ibm.icu.text.UnicodeFilter.matches.

Implements com.ibm.icu.text.UnicodeMatcher.matches.

Implementation of UnicodeMatcher.matches().
public int
matchesAt(CharSequence text, int offset)

Deprecated This API is ICU internal only.
Tests whether the text matches at the offset.
private static int

Returns:

-1 if match fails, otherwise other.length()
matchesAt
(CharSequence
text to match
text
,
int
offset within that text
offsetInText
,
CharSequence
substring to match at offset in text
substring
)

Does one string contain another, starting at a specific offset?

public boolean
matchesIndexValue(int v)

Implements com.ibm.icu.text.UnicodeMatcher.matchesIndexValue.

Implementation of UnicodeMatcher API.
private static int

Returns:

If part of s matches up to the limit, return |limit - start|. If all of s matches before reaching the limit, return s.length(). If there is a mismatch between s and text, return 0
matchRest
(Replaceable
the text to match
text
,
int
the first character to match. In the forward direction, text.charAt(start) is matched against s.charAt(0). In the reverse direction, it is matched against s.charAt(s.length()-1).
start
,
int
the limit offset for matching, either last+1 in the forward direction, or last-1 in the reverse direction, where last is the index of the last character to match.
limit
,
String s)

Returns the longest match for s in text at the given position.

private static final int
max(int a, int b)

pack-priv UnicodeSet
maybeOnlyCaseSensitive(UnicodeSet src)

For case closure on a large set, look only at code points with relevant properties.

private static String
mungeCharName(String source)

Remove leading and trailing Pattern_White_Space and compress internal Pattern_White_Space to a single space character.

private int
nextCapacity(int minCapacity)

private int[]
range(int start, int end)

Assumes start <= end.

public Iterable<UnicodeSet.EntryRange>
ranges()

Provide for faster iteration than by String.

public UnicodeSet
remove(int
first character, inclusive, of range to be removed from this set.
start
,
int
last character, inclusive, of range to be removed from this set.
end
)

Removes the specified range from this set if it is present.

public final UnicodeSet

Returns:

this object, for chaining
remove
(int
the character to be removed
c
)

Removes the specified character from this set if it is present.

public final UnicodeSet

Returns:

this object, for chaining
remove
(CharSequence
the string to be removed
s
)

Removes the specified string from this set if it is present.

public final UnicodeSet

Returns:

this object, for chaining
removeAll
(CharSequence
the source string
s
)

Remove EACH of the characters in this string.

public UnicodeSet
removeAll(UnicodeSet
set that defines which elements will be removed from this set.
c
)

Removes from this set all of its elements that are contained in the specified set.

public <T extends CharSequence> UnicodeSet
removeAll(Iterable<T> collection)

public final UnicodeSet

Returns:

this object, for chaining
removeAllStrings
()

Remove all strings from this UnicodeSet

public static boolean
resemblesPattern(String pattern, int pos)

Return true if the given position, in the given pattern, appears to be the start of a UnicodeSet pattern.

private static boolean
resemblesPropertyPattern(String pattern, int pos)

Return true if the given position, in the given pattern, appears to be the start of a property set pattern.

private static boolean
resemblesPropertyPattern(RuleCharacterIterator
iterator over the pattern characters. Upon return it will be unchanged.
chars
,
int
RuleCharacterIterator options
iterOpts
)

Return true if the given iterator appears to point at a property pattern.

public UnicodeSet
retain(int
first character, inclusive, of range
start
,
int
last character, inclusive, of range
end
)

Retain only the elements in this set that are contained in the specified range.

public final UnicodeSet

Returns:

this object, for chaining
retain
(int
the character to be retained
c
)

Retain the specified character from this set if it is present.

public final UnicodeSet

Returns:

this object, for chaining
retain
(CharSequence
the string to be retained
cs
)

Retain the specified string in this set if it is present.

private UnicodeSet
retain(int[] other, int otherLen, int polarity)

public final UnicodeSet

Returns:

this object, for chaining
retainAll
(CharSequence
the source string
s
)

Retains EACH of the characters in this string.

public UnicodeSet
retainAll(UnicodeSet
set that defines which elements this set will retain.
c
)

Retains only the elements in this set that are contained in the specified set.

public <T extends CharSequence> UnicodeSet
retainAll(Iterable<T> collection)

private static final boolean
public UnicodeSet
set(int
first character in the set, inclusive
start
,
int
last character in the set, inclusive
end
)

Make this object represent the range start - end.

public UnicodeSet
set(UnicodeSet
a UnicodeSet whose value will be copied to this object
other
)

Make this object represent the same set as other.

public static void
setDefaultXSymbolTable(UnicodeSet.XSymbolTable
the new default symbol table.
xSymbolTable
)

Deprecated This API is ICU internal only.
Set the default symbol table.
public int

Returns:

the number of elements in this set (its cardinality).
size
()

Returns the number of elements in this set (its cardinality) Note than the elements of a set may include both individual codepoints and strings.

public int

Returns:

the length of the span
span
(CharSequence
The string to be spanned
s
,
UnicodeSet.SpanCondition
The span condition
spanCondition
)

Span a string using this UnicodeSet.

public int

Returns:

the string index which ends the span (i.e. exclusive)
span
(CharSequence
The string to be spanned
s
,
int
The start index that the span begins
start
,
UnicodeSet.SpanCondition
The span condition
spanCondition
)

Span a string using this UnicodeSet.

public int

Returns:

the limit (exclusive end) of the span
spanAndCount
(CharSequence s, int start, UnicodeSet.SpanCondition spanCondition, OutputInt
An output-only object (must not be null) for returning the count.
outCount
)

Deprecated This API is ICU internal only.
Same as span() but also counts the smallest number of set elements on any path across the span.
public int

Returns:

The string index which starts the span (i.e. inclusive).
spanBack
(CharSequence
The string to be spanned
s
,
UnicodeSet.SpanCondition
The span condition
spanCondition
)

Span a string backwards (from the end) using this UnicodeSet.

public int

Returns:

The string index which starts the span (i.e. inclusive).
spanBack
(CharSequence
The string to be spanned
s
,
int
The index of the char (exclusive) that the string should be spanned backwards
fromIndex
,
UnicodeSet.SpanCondition
The span condition
spanCondition
)

Span a string backwards (from the fromIndex) using this UnicodeSet.

private int
spanCodePointsAndCount(CharSequence s, int start, UnicodeSet.SpanCondition spanCondition, OutputInt outCount)

Deprecated as a consequence of OutputInt being deprecated.
public Collection<String>
strings()

For iterating through the strings in the set.

public String

Returns:

The string after it has been stripped.
stripFrom
(CharSequence
The source of the CharSequence to strip from.
source
,
boolean
A boolean to either strip all that matches or don't match with the current UnicodeSet object.
matches
)

Deprecated This API is ICU internal only. Use replaceFrom.
Strips code points from source.
private static void
public static String[]
toArray(UnicodeSet set)

Add the contents of the UnicodeSet (as strings) into an array.

public String
toPattern(boolean
if true then convert unprintable character to their hex escape representations, \\uxxxx or \\Uxxxxxxxx. Unprintable characters are those other than U+000A, U+0020..U+007E.
escapeUnprintable
)

Implements com.ibm.icu.text.UnicodeMatcher.toPattern.

Returns a string representation of this set.
public String
toString()

Overrides java.lang.Object.toString.

Return a programmer-readable string representation of this object.
private UnicodeSet
xor(int[] other, int otherLen, int polarity)