Class UnicodeSet
- java.lang.Object
-
- com.ibm.icu.text.UnicodeFilter
-
- com.ibm.icu.text.UnicodeSet
-
- All Implemented Interfaces:
UnicodeMatcher
,Freezable<UnicodeSet>
,java.lang.Cloneable
,java.lang.Comparable<UnicodeSet>
,java.lang.Iterable<java.lang.String>
public class UnicodeSet extends UnicodeFilter implements java.lang.Iterable<java.lang.String>, java.lang.Comparable<UnicodeSet>, Freezable<UnicodeSet>
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 aUnicodeSet
object. It conforms to Java 2'sjava.util.Set
interface, althoughUnicodeSet
does not actually implement that interface. All methods ofSet
are supported, with the modification that they take a character range or single character instead of anObject
, and they take aUnicodeSet
instead of aCollection
. The operand API may be thought of in terms of boolean logic: a boolean OR is implemented byadd
, a boolean AND is implemented byretain
, a boolean XOR is implemented bycomplement
taking an argument, and a boolean NOT is implemented bycomplement
with no argument. In terms of traditional set theory function names,add
is a union,retain
is an intersection,remove
is an asymmetric difference, andcomplement
with no argument is a set complement with respect to the superset rangeMIN_VALUE-MAX_VALUE
The second API is the
applyPattern()
/toPattern()
API from thejava.text.Format
-derived classes. Unlike the methods that add characters, add categories, and control the logic of the set, the methodapplyPattern()
sets all attributes of aUnicodeSet
at once, based on a string pattern.Pattern syntax
Patterns are accepted by the constructors and theapplyPattern()
methods and returned by thetoPattern()
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 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()
. Thecomplement()
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 byb
a?
zero or one instance of a
a*
one or more instances of a
a | b
either a
orb
'a'
the literal string between the quotes To iterate over contents of UnicodeSet, the following are available:
ranges()
to iterate through the rangesstrings()
to iterate through the stringsiterator()
to iterate through the entire contents in a single loop. That method is, however, not particularly efficient, since it "boxes" each code point into a String.
UnicodeSetIterator
can also be used, but not in for loops.To replace, count elements, or delete spans, see
UnicodeSetSpanner
.- See Also:
UnicodeSetIterator
,UnicodeSetSpanner
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
UnicodeSet.ComparisonStyle
Comparison style enums used bycompareTo(UnicodeSet, ComparisonStyle)
.static class
UnicodeSet.EntryRange
A struct-like class used for iteration through ranges, for faster iteration than by String.private class
UnicodeSet.EntryRangeIterable
private class
UnicodeSet.EntryRangeIterator
private static interface
UnicodeSet.Filter
private static class
UnicodeSet.GeneralCategoryMaskFilter
private static class
UnicodeSet.IdentifierTypeFilter
private static class
UnicodeSet.IntPropertyFilter
private static class
UnicodeSet.NumericValueFilter
private static class
UnicodeSet.ScriptExtensionsFilter
static class
UnicodeSet.SpanCondition
Argument values for whether span() and similar functions continue while the current character is contained vs.private static class
UnicodeSet.UnicodeSetIterator2
private static class
UnicodeSet.VersionFilter
static class
UnicodeSet.XSymbolTable
Internal class for customizing UnicodeSet parsing of properties.
-
Field Summary
Fields Modifier and Type Field Description static int
ADD_CASE_MAPPINGS
Adds all case mappings for each element in the set.static UnicodeSet
ALL_CODE_POINTS
Constant for the set of all code points.private static java.lang.String
ANY_ID
private static java.lang.String
ASCII_ID
private static java.lang.String
ASSIGNED
private BMPSet
bmpSet
private int[]
buffer
static int
CASE
Deprecated.ICU 73 UseCASE_INSENSITIVE
instead.static int
CASE_INSENSITIVE
Enable case insensitive matching.private static int
CASE_MASK
static UnicodeSet
EMPTY
Constant for the empty set.private static java.util.SortedSet<java.lang.String>
EMPTY_STRINGS
private static int
HIGH
static int
IGNORE_SPACE
Bitmask for constructor and applyPattern() indicating that white space should be ignored.private static int
INITIAL_CAPACITY
Enough for sets with few ranges.private static int
LAST0_START
private static int
LAST1_RANGE
private static int
LAST2_SET
private int
len
private int[]
list
private static int
LOW
private static int
MAX_DEPTH
private static int
MAX_LENGTH
Max list [0, 1, 2, ..., max code point, HIGH]static int
MAX_VALUE
Maximum value that can be stored in a UnicodeSet.static int
MIN_VALUE
Minimum value that can be stored in a UnicodeSet.private static int
MODE0_NONE
private static int
MODE1_INBRACKET
private static int
MODE2_OUTBRACKET
private static VersionInfo
NO_VERSION
private java.lang.String
pat
The pattern representation of this set.private int[]
rangeList
private static int
SETMODE0_NONE
private static int
SETMODE1_UNICODESET
private static int
SETMODE2_PROPERTYPAT
private static int
SETMODE3_PREPARSED
static int
SIMPLE_CASE_INSENSITIVE
Enable case insensitive matching.(package private) java.util.SortedSet<java.lang.String>
strings
private UnicodeSetStringSpan
stringSpan
private static UnicodeSet.XSymbolTable
XSYMBOL_TABLE
-
Fields inherited from interface com.ibm.icu.text.UnicodeMatcher
ETHER, U_MATCH, U_MISMATCH, U_PARTIAL_MATCH
-
-
Constructor Summary
Constructors Constructor Description UnicodeSet()
Constructs an empty set.UnicodeSet(int... pairs)
Quickly constructs a set from a set of ranges <s0, e0, s1, e1, s2, e2, ..., sn, en>.UnicodeSet(int start, int end)
Constructs a set containing the given range.UnicodeSet(UnicodeSet other)
Constructs a copy of an existing set.UnicodeSet(java.lang.String pattern)
Constructs a set from the given pattern.UnicodeSet(java.lang.String pattern, boolean ignoreWhitespace)
Constructs a set from the given pattern.UnicodeSet(java.lang.String pattern, int options)
Constructs a set from the given pattern.UnicodeSet(java.lang.String pattern, java.text.ParsePosition pos, SymbolTable symbols)
Constructs a set from the given pattern.UnicodeSet(java.lang.String pattern, java.text.ParsePosition pos, SymbolTable symbols, int options)
Constructs a set from the given pattern.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private static <T extends java.lang.Appendable>
T_appendToPat(T buf, int c, boolean escapeUnprintable)
Append thetoPattern()
representation of a character to the givenAppendable
.private static <T extends java.lang.Appendable>
T_appendToPat(T result, int start, int end, boolean escapeUnprintable)
private static <T extends java.lang.Appendable>
T_appendToPat(T buf, java.lang.String s, boolean escapeUnprintable)
Append thetoPattern()
representation of a string to the givenAppendable
.java.lang.StringBuffer
_generatePattern(java.lang.StringBuffer result, boolean escapeUnprintable)
Generate and append a string representation of this set to result.java.lang.StringBuffer
_generatePattern(java.lang.StringBuffer result, boolean escapeUnprintable, boolean includeStrings)
Generate and append a string representation of this set to result.private <T extends java.lang.Appendable>
T_toPattern(T result, boolean escapeUnprintable)
Append a string representation of this set to result.UnicodeSet
add(int c)
Adds the specified character to this set if it is not already present.private UnicodeSet
add(int[] other, int otherLen, int polarity)
UnicodeSet
add(int start, int end)
Adds the specified range to this set if it is not already present.UnicodeSet
add(java.lang.CharSequence s)
Adds the specified multicharacter to this set if it is not already present.UnicodeSet
add(java.lang.Iterable<?> source)
Add the contents of the collection (as strings) into this UnicodeSet.private UnicodeSet
add_unchecked(int c)
private UnicodeSet
add_unchecked(int start, int end)
UnicodeSet
addAll(int start, int end)
Adds all characters in range (uses preferred naming convention).UnicodeSet
addAll(UnicodeSet c)
Adds all of the elements in the specified set to this set if they're not already present.UnicodeSet
addAll(java.lang.CharSequence s)
Adds each of the characters in this string to the set.UnicodeSet
addAll(java.lang.Iterable<?> source)
Add a collection (as strings) into this UnicodeSet.<T extends java.lang.CharSequence>
UnicodeSetaddAll(T... collection)
static <T> T[]
addAllTo(java.lang.Iterable<T> source, T[] target)
Utility for adding the contents of an iterable to a collection.static <T,U extends java.util.Collection<T>>
UaddAllTo(java.lang.Iterable<T> source, U target)
Utility for adding the contents of an iterable to a collection.java.lang.String[]
addAllTo(java.lang.String[] target)
Add the contents of the UnicodeSet (as strings) into a collection.<T extends java.util.Collection<java.lang.String>>
TaddAllTo(T target)
Add the contents of the UnicodeSet (as strings) into a collection.UnicodeSet
addBridges(UnicodeSet dontCare)
Deprecated.This API is ICU internal only.private static void
addCaseMapping(UnicodeSet set, int result, java.lang.StringBuilder full)
void
addMatchSetTo(UnicodeSet toUnionTo)
Implementation of UnicodeMatcher API.private void
addString(java.lang.CharSequence s)
private static void
append(java.lang.Appendable app, java.lang.CharSequence s)
TODO: create class Appendables?private static void
appendCodePoint(java.lang.Appendable app, int c)
TODO: create Appendable version of UTF16.append(buf, c), maybe in new class Appendables?private <T extends java.lang.Appendable>
TappendNewPattern(T result, boolean escapeUnprintable, boolean includeStrings)
private void
applyFilter(UnicodeSet.Filter filter, UnicodeSet inclusions)
Generic filter-based scanning code for UCD property UnicodeSets.UnicodeSet
applyIntPropertyValue(int prop, int 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.private void
applyPattern(RuleCharacterIterator chars, SymbolTable symbols, java.lang.Appendable rebuiltPat, int options, int depth)
Parse the pattern from the given RuleCharacterIterator.UnicodeSet
applyPattern(java.lang.String pattern)
Modifies this set to represent the set specified by the given pattern.UnicodeSet
applyPattern(java.lang.String pattern, boolean ignoreWhitespace)
Modifies this set to represent the set specified by the given pattern, optionally ignoring whitespace.UnicodeSet
applyPattern(java.lang.String pattern, int options)
Modifies this set to represent the set specified by the given pattern, optionally ignoring whitespace.UnicodeSet
applyPattern(java.lang.String pattern, java.text.ParsePosition pos, SymbolTable symbols, int options)
Deprecated.This API is ICU internal only.UnicodeSet
applyPropertyAlias(java.lang.String propertyAlias, java.lang.String valueAlias)
Modifies this set to contain those code points which have the given value for the given property.UnicodeSet
applyPropertyAlias(java.lang.String propertyAlias, java.lang.String valueAlias, SymbolTable symbols)
Modifies this set to contain those code points which have the given value for the given property.private void
applyPropertyPattern(RuleCharacterIterator chars, java.lang.Appendable rebuiltPat, SymbolTable symbols)
Parse a property pattern.private UnicodeSet
applyPropertyPattern(java.lang.String pattern, java.text.ParsePosition ppos, SymbolTable symbols)
Parse the given property pattern at the given parse position.int
charAt(int index)
Returns the character at the given index within this set, where the set is ordered by ascending code point.private void
checkFrozen()
UnicodeSet
clear()
Removes all of the elements from this set.java.lang.Object
clone()
Return a new set that is equivalent to this one.UnicodeSet
cloneAsThawed()
Clone a thawed version of this class, according to the Freezable interface.UnicodeSet
closeOver(int attribute)
Close this set over the given attribute.private void
closeOverAddCaseMappings()
private void
closeOverCaseInsensitive(boolean simple)
UnicodeSet
compact()
Reallocate this objects internal structures to take up the least possible space, without changing this object's value.static int
compare(int codePoint, java.lang.CharSequence string)
Utility to compare a string to a code point.static int
compare(java.lang.CharSequence string, int codePoint)
Utility to compare a string to a code point.static <T extends java.lang.Comparable<T>>
intcompare(java.lang.Iterable<T> collection1, java.lang.Iterable<T> collection2)
Utility to compare two iterables.static <T extends java.lang.Comparable<T>>
intcompare(java.util.Collection<T> collection1, java.util.Collection<T> collection2, UnicodeSet.ComparisonStyle style)
Utility to compare two collections, optionally by size, and then lexicographically.static <T extends java.lang.Comparable<T>>
intcompare(java.util.Iterator<T> first, java.util.Iterator<T> other)
Deprecated.This API is ICU internal only.int
compareTo(UnicodeSet o)
Compares UnicodeSets, where shorter come first, and otherwise lexicographically (according to the comparison of the first characters that differ).int
compareTo(UnicodeSet o, UnicodeSet.ComparisonStyle style)
Compares UnicodeSets, in three different ways.int
compareTo(java.lang.Iterable<java.lang.String> other)
UnicodeSet
complement()
This is equivalent tocomplement(MIN_VALUE, MAX_VALUE)
.UnicodeSet
complement(int c)
Complements the specified character in this set.UnicodeSet
complement(int start, int end)
Complements the specified range in this set.UnicodeSet
complement(java.lang.CharSequence s)
Complement the specified string in this set.UnicodeSet
complementAll(UnicodeSet c)
Complements in this set all elements contained in the specified set.UnicodeSet
complementAll(java.lang.CharSequence s)
Complement EACH of the characters in this string.boolean
contains(int c)
Returns true if this set contains the given character.boolean
contains(int start, int end)
Returns true if this set contains every character of the given range.boolean
contains(java.lang.CharSequence s)
Returns true if this set contains the given multicharacter string.boolean
containsAll(UnicodeSet b)
Returns true if this set contains all the characters and strings of the given set.<T extends java.lang.CharSequence>
booleancontainsAll(java.lang.Iterable<T> collection)
boolean
containsAll(java.lang.String s)
Returns true if there is a partition of the string such that this set contains each of the partitioned strings.private boolean
containsAll(java.lang.String s, int i)
Recursive routine called if we fail to find a match in containsAll, and there are stringsboolean
containsNone(int start, int end)
Returns true if this set contains none of the characters of the given range.boolean
containsNone(UnicodeSet b)
Returns true if none of the characters or strings in this UnicodeSet appears in the string.boolean
containsNone(java.lang.CharSequence s)
Returns true if this set contains none of the characters of the given string.<T extends java.lang.CharSequence>
booleancontainsNone(java.lang.Iterable<T> collection)
boolean
containsSome(int start, int end)
Returns true if this set contains one or more of the characters in the given range.boolean
containsSome(UnicodeSet s)
Returns true if this set contains one or more of the characters and strings of the given set.boolean
containsSome(java.lang.CharSequence s)
Returns true if this set contains one or more of the characters of the given string.<T extends java.lang.CharSequence>
booleancontainsSome(java.lang.Iterable<T> collection)
private void
ensureBufferCapacity(int newLen)
private void
ensureCapacity(int newLen)
boolean
equals(java.lang.Object o)
Compares the specified object with this set for equality.private int
findCodePoint(int c)
Returns the smallest value i such that c < list[i].int
findIn(java.lang.CharSequence value, int fromIndex, boolean findNot)
Deprecated.This API is ICU internal only.int
findLastIn(java.lang.CharSequence value, int fromIndex, boolean findNot)
Deprecated.This API is ICU internal only.UnicodeSet
freeze()
Freeze this class, according to the Freezable interface.static UnicodeSet
from(java.lang.CharSequence s)
Makes a set from a multicharacter string.static UnicodeSet
fromAll(java.lang.CharSequence s)
Makes a set from each of the characters in the string.static UnicodeSet.XSymbolTable
getDefaultXSymbolTable()
Deprecated.This API is ICU internal only.int
getRangeCount()
Iteration method that returns the number of ranges contained in this set.int
getRangeEnd(int index)
Iteration method that returns the last character in the specified range of this set.int
getRangeStart(int index)
Iteration method that returns the first character in the specified range of this set.java.lang.String
getRegexEquivalent()
Deprecated.This API is ICU internal only.static int
getSingleCodePoint(java.lang.CharSequence s)
Deprecated.This API is ICU internal only.private static int
getSingleCP(java.lang.CharSequence s)
Utility for getting code point from single code point CharSequence.int
hashCode()
Returns the hash code value for this set.boolean
hasStrings()
int
indexOf(int c)
Returns the index of the given character within this set, where the set is ordered by ascending code point.boolean
isEmpty()
Returns true if this set contains no elements.boolean
isFrozen()
Is this frozen, according to the Freezable interface?java.util.Iterator<java.lang.String>
iterator()
Returns a string iterator.int
matches(Replaceable text, int[] offset, int limit, boolean incremental)
Implementation of UnicodeMatcher.matches().int
matchesAt(java.lang.CharSequence text, int offset)
Deprecated.This API is ICU internal only.private static int
matchesAt(java.lang.CharSequence text, int offsetInText, java.lang.CharSequence substring)
Does one string contain another, starting at a specific offset?boolean
matchesIndexValue(int v)
Implementation of UnicodeMatcher API.private static int
matchRest(Replaceable text, int start, int limit, java.lang.String s)
Returns the longest match for s in text at the given position.private static int
max(int a, int b)
(package private) UnicodeSet
maybeOnlyCaseSensitive(UnicodeSet src)
For case closure on a large set, look only at code points with relevant properties.private static java.lang.String
mungeCharName(java.lang.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.java.lang.Iterable<UnicodeSet.EntryRange>
ranges()
Provide for faster iteration than by String.UnicodeSet
remove(int c)
Removes the specified character from this set if it is present.UnicodeSet
remove(int start, int end)
Removes the specified range from this set if it is present.UnicodeSet
remove(java.lang.CharSequence s)
Removes the specified string from this set if it is present.UnicodeSet
removeAll(UnicodeSet c)
Removes from this set all of its elements that are contained in the specified set.UnicodeSet
removeAll(java.lang.CharSequence s)
Remove EACH of the characters in this string.<T extends java.lang.CharSequence>
UnicodeSetremoveAll(java.lang.Iterable<T> collection)
UnicodeSet
removeAllStrings()
Remove all strings from this UnicodeSetstatic boolean
resemblesPattern(java.lang.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(RuleCharacterIterator chars, int iterOpts)
Return true if the given iterator appears to point at a property pattern.private static boolean
resemblesPropertyPattern(java.lang.String pattern, int pos)
Return true if the given position, in the given pattern, appears to be the start of a property set pattern.UnicodeSet
retain(int c)
Retain the specified character from this set if it is present.private UnicodeSet
retain(int[] other, int otherLen, int polarity)
UnicodeSet
retain(int start, int end)
Retain only the elements in this set that are contained in the specified range.UnicodeSet
retain(java.lang.CharSequence cs)
Retain the specified string in this set if it is present.UnicodeSet
retainAll(UnicodeSet c)
Retains only the elements in this set that are contained in the specified set.UnicodeSet
retainAll(java.lang.CharSequence s)
Retains EACH of the characters in this string.<T extends java.lang.CharSequence>
UnicodeSetretainAll(java.lang.Iterable<T> collection)
private static boolean
scfString(java.lang.CharSequence s, java.lang.StringBuilder scf)
UnicodeSet
set(int start, int end)
Make this object represent the rangestart - end
.UnicodeSet
set(UnicodeSet other)
Make this object represent the same set asother
.static void
setDefaultXSymbolTable(UnicodeSet.XSymbolTable xSymbolTable)
Deprecated.This API is ICU internal only.int
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.int
span(java.lang.CharSequence s, int start, UnicodeSet.SpanCondition spanCondition)
Span a string using this UnicodeSet.int
span(java.lang.CharSequence s, UnicodeSet.SpanCondition spanCondition)
Span a string using this UnicodeSet.int
spanAndCount(java.lang.CharSequence s, int start, UnicodeSet.SpanCondition spanCondition, OutputInt outCount)
Deprecated.This API is ICU internal only.int
spanBack(java.lang.CharSequence s, int fromIndex, UnicodeSet.SpanCondition spanCondition)
Span a string backwards (from the fromIndex) using this UnicodeSet.int
spanBack(java.lang.CharSequence s, UnicodeSet.SpanCondition spanCondition)
Span a string backwards (from the end) using this UnicodeSet.private int
spanCodePointsAndCount(java.lang.CharSequence s, int start, UnicodeSet.SpanCondition spanCondition, OutputInt outCount)
java.util.Collection<java.lang.String>
strings()
For iterating through the strings in the set.java.lang.String
stripFrom(java.lang.CharSequence source, boolean matches)
Deprecated.This API is ICU internal only.private static void
syntaxError(RuleCharacterIterator chars, java.lang.String msg)
static java.lang.String[]
toArray(UnicodeSet set)
Add the contents of the UnicodeSet (as strings) into an array.java.lang.String
toPattern(boolean escapeUnprintable)
Returns a string representation of this set.java.lang.String
toString()
Return a programmer-readable string representation of this object.private UnicodeSet
xor(int[] other, int otherLen, int polarity)
-
-
-
Field Detail
-
EMPTY_STRINGS
private static final java.util.SortedSet<java.lang.String> EMPTY_STRINGS
-
EMPTY
public static final UnicodeSet EMPTY
Constant for the empty set.
-
ALL_CODE_POINTS
public static final UnicodeSet ALL_CODE_POINTS
Constant for the set of all code points. (Since UnicodeSets can include strings, does not include everything that a UnicodeSet can.)
-
XSYMBOL_TABLE
private static UnicodeSet.XSymbolTable XSYMBOL_TABLE
-
LOW
private static final int LOW
- See Also:
- Constant Field Values
-
HIGH
private static final int HIGH
- See Also:
- Constant Field Values
-
INITIAL_CAPACITY
private static final int INITIAL_CAPACITY
Enough for sets with few ranges. For example, White_Space has 10 ranges, list length 21.- See Also:
- Constant Field Values
-
MAX_LENGTH
private static final int MAX_LENGTH
Max list [0, 1, 2, ..., max code point, HIGH]- See Also:
- Constant Field Values
-
MIN_VALUE
public static final int MIN_VALUE
Minimum value that can be stored in a UnicodeSet.- See Also:
- Constant Field Values
-
MAX_VALUE
public static final int MAX_VALUE
Maximum value that can be stored in a UnicodeSet.- See Also:
- Constant Field Values
-
len
private int len
-
list
private int[] list
-
rangeList
private int[] rangeList
-
buffer
private int[] buffer
-
strings
java.util.SortedSet<java.lang.String> strings
-
pat
private java.lang.String pat
The pattern representation of this set. This may not be the most economical pattern. It is the pattern supplied to applyPattern(), with variables substituted and whitespace removed. For sets constructed without applyPattern(), or modified using the non-pattern API, this string will be null, indicating that toPattern() must generate a pattern representation from the inversion list.
-
ANY_ID
private static final java.lang.String ANY_ID
- See Also:
- Constant Field Values
-
ASCII_ID
private static final java.lang.String ASCII_ID
- See Also:
- Constant Field Values
-
ASSIGNED
private static final java.lang.String ASSIGNED
- See Also:
- Constant Field Values
-
bmpSet
private volatile BMPSet bmpSet
-
stringSpan
private volatile UnicodeSetStringSpan stringSpan
-
LAST0_START
private static final int LAST0_START
- See Also:
- Constant Field Values
-
LAST1_RANGE
private static final int LAST1_RANGE
- See Also:
- Constant Field Values
-
LAST2_SET
private static final int LAST2_SET
- See Also:
- Constant Field Values
-
MODE0_NONE
private static final int MODE0_NONE
- See Also:
- Constant Field Values
-
MODE1_INBRACKET
private static final int MODE1_INBRACKET
- See Also:
- Constant Field Values
-
MODE2_OUTBRACKET
private static final int MODE2_OUTBRACKET
- See Also:
- Constant Field Values
-
SETMODE0_NONE
private static final int SETMODE0_NONE
- See Also:
- Constant Field Values
-
SETMODE1_UNICODESET
private static final int SETMODE1_UNICODESET
- See Also:
- Constant Field Values
-
SETMODE2_PROPERTYPAT
private static final int SETMODE2_PROPERTYPAT
- See Also:
- Constant Field Values
-
SETMODE3_PREPARSED
private static final int SETMODE3_PREPARSED
- See Also:
- Constant Field Values
-
MAX_DEPTH
private static final int MAX_DEPTH
- See Also:
- Constant Field Values
-
NO_VERSION
private static final VersionInfo NO_VERSION
-
IGNORE_SPACE
public static final int IGNORE_SPACE
Bitmask for constructor and applyPattern() indicating that white space should be ignored. If set, ignore Unicode Pattern_White_Space characters, unless they are quoted or escaped. This may be ORed together with other selectors.- See Also:
- Constant Field Values
-
CASE
@Deprecated public static final int CASE
Deprecated.ICU 73 UseCASE_INSENSITIVE
instead.Alias forCASE_INSENSITIVE
.- See Also:
- Constant Field Values
-
CASE_INSENSITIVE
public static final int CASE_INSENSITIVE
Enable case insensitive matching. E.g., "[ab]" with this flag will match 'a', 'A', 'b', and 'B'. "[^ab]" with this flag will match all except 'a', 'A', 'b', and 'B'. This performs a full closure over case mappings, e.g. 'ſ' (U+017F long s) for 's'.This value is an options bit set value for some constructors, applyPattern(), and closeOver(). It can be ORed together with other, unrelated options.
The resulting set is a superset of the input for the code points but not for the strings. It performs a case mapping closure of the code points and adds full case folding strings for the code points, and reduces strings of the original set to their full case folding equivalents.
This is designed for case-insensitive matches, for example in regular expressions. The full code point case closure allows checking of an input character directly against the closure set. Strings are matched by comparing the case-folded form from the closure set with an incremental case folding of the string in question.
The closure set will also contain single code points if the original set contained case-equivalent strings (like U+00DF for "ss" or "Ss" etc.). This is not necessary (that is, redundant) for the above matching method but results in the same closure sets regardless of whether the original set contained the code point or a string.
- See Also:
- Constant Field Values
-
ADD_CASE_MAPPINGS
public static final int ADD_CASE_MAPPINGS
Adds all case mappings for each element in the set. This adds the full lower-, title-, and uppercase mappings as well as the full case folding of each existing element in the set.This value is an options bit set value for some constructors, applyPattern(), and closeOver(). It can be ORed together with other, unrelated options.
Unlike the “case insensitive” options, this does not perform a closure. For example, it does not add 'ſ' (U+017F long s) for 's', 'K' (U+212A Kelvin sign) for 'k', or replace set strings by their case-folded versions.
- See Also:
- Constant Field Values
-
SIMPLE_CASE_INSENSITIVE
public static final int SIMPLE_CASE_INSENSITIVE
Enable case insensitive matching. Same asCASE_INSENSITIVE
but using only Simple_Case_Folding (scf) mappings, which map each code point to one code point, not full Case_Folding (cf) mappings, which map some code points to multiple code points.This is designed for case-insensitive matches, for example in certain regular expression implementations where only Simple_Case_Folding mappings are used, such as in ECMAScript (JavaScript) regular expressions.
This value is an options bit set value for some constructors, applyPattern(), and closeOver(). It can be ORed together with other, unrelated options.
- See Also:
- Constant Field Values
-
CASE_MASK
private static final int CASE_MASK
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UnicodeSet
public UnicodeSet()
Constructs an empty set.
-
UnicodeSet
public UnicodeSet(UnicodeSet other)
Constructs a copy of an existing set.
-
UnicodeSet
public UnicodeSet(int start, int end)
Constructs a set containing the given range. Ifend > start
then an empty set is created.- Parameters:
start
- first character, inclusive, of rangeend
- last character, inclusive, of range
-
UnicodeSet
public UnicodeSet(int... pairs)
Quickly constructs a set from a set of ranges <s0, e0, s1, e1, s2, e2, ..., sn, en>. There must be an even number of integers, and they must be all greater than zero, all less than or equal to Character.MAX_CODE_POINT. In each pair (..., si, ei, ...) it must be true that si <= ei Between adjacent pairs (...ei, sj...), it must be true that ei+1 < sj- Parameters:
pairs
- pairs of character representing ranges
-
UnicodeSet
public UnicodeSet(java.lang.String pattern)
Constructs a set from the given pattern. See the class description for the syntax of the pattern language. Whitespace is ignored.- Parameters:
pattern
- a string specifying what characters are in the set- Throws:
java.lang.IllegalArgumentException
- if the pattern contains a syntax error.
-
UnicodeSet
public UnicodeSet(java.lang.String pattern, boolean ignoreWhitespace)
Constructs a set from the given pattern. See the class description for the syntax of the pattern language.- Parameters:
pattern
- a string specifying what characters are in the setignoreWhitespace
- if true, ignore Unicode Pattern_White_Space characters- Throws:
java.lang.IllegalArgumentException
- if the pattern contains a syntax error.
-
UnicodeSet
public UnicodeSet(java.lang.String pattern, int options)
Constructs a set from the given pattern. See the class description for the syntax of the pattern language.- Parameters:
pattern
- a string specifying what characters are in the setoptions
- a bitmask indicating which options to apply. Valid options areIGNORE_SPACE
and at most one ofCASE_INSENSITIVE
,ADD_CASE_MAPPINGS
,SIMPLE_CASE_INSENSITIVE
. These case options are mutually exclusive.- Throws:
java.lang.IllegalArgumentException
- if the pattern contains a syntax error.
-
UnicodeSet
public UnicodeSet(java.lang.String pattern, java.text.ParsePosition pos, SymbolTable symbols)
Constructs a set from the given pattern. See the class description for the syntax of the pattern language.- Parameters:
pattern
- a string specifying what characters are in the setpos
- on input, the position in pattern at which to start parsing. On output, the position after the last character parsed.symbols
- a symbol table mapping variables to char[] arrays and chars to UnicodeSets- Throws:
java.lang.IllegalArgumentException
- if the pattern contains a syntax error.
-
UnicodeSet
public UnicodeSet(java.lang.String pattern, java.text.ParsePosition pos, SymbolTable symbols, int options)
Constructs a set from the given pattern. See the class description for the syntax of the pattern language.- Parameters:
pattern
- a string specifying what characters are in the setpos
- on input, the position in pattern at which to start parsing. On output, the position after the last character parsed.symbols
- a symbol table mapping variables to char[] arrays and chars to UnicodeSetsoptions
- a bitmask indicating which options to apply. Valid options areIGNORE_SPACE
and at most one ofCASE_INSENSITIVE
,ADD_CASE_MAPPINGS
,SIMPLE_CASE_INSENSITIVE
. These case options are mutually exclusive.- Throws:
java.lang.IllegalArgumentException
- if the pattern contains a syntax error.
-
-
Method Detail
-
clone
public java.lang.Object clone()
Return a new set that is equivalent to this one.- Overrides:
clone
in classjava.lang.Object
-
set
public UnicodeSet set(int start, int end)
Make this object represent the rangestart - end
. Ifstart > end
then this object is set to an empty range.- Parameters:
start
- first character in the set, inclusiveend
- last character in the set, inclusive
-
set
public UnicodeSet set(UnicodeSet other)
Make this object represent the same set asother
.- Parameters:
other
- aUnicodeSet
whose value will be copied to this object
-
applyPattern
public final UnicodeSet applyPattern(java.lang.String pattern)
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.- Parameters:
pattern
- a string specifying what characters are in the set- Throws:
java.lang.IllegalArgumentException
- if the pattern contains a syntax error.
-
applyPattern
public UnicodeSet applyPattern(java.lang.String pattern, boolean ignoreWhitespace)
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.- Parameters:
pattern
- a string specifying what characters are in the setignoreWhitespace
- if true then Unicode Pattern_White_Space characters are ignored- Throws:
java.lang.IllegalArgumentException
- if the pattern contains a syntax error.
-
applyPattern
public UnicodeSet applyPattern(java.lang.String pattern, int 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.- Parameters:
pattern
- a string specifying what characters are in the setoptions
- a bitmask indicating which options to apply. Valid options areIGNORE_SPACE
and at most one ofCASE_INSENSITIVE
,ADD_CASE_MAPPINGS
,SIMPLE_CASE_INSENSITIVE
. These case options are mutually exclusive.- Throws:
java.lang.IllegalArgumentException
- if the pattern contains a syntax error.
-
resemblesPattern
public static boolean resemblesPattern(java.lang.String pattern, int pos)
Return true if the given position, in the given pattern, appears to be the start of a UnicodeSet pattern.
-
appendCodePoint
private static void appendCodePoint(java.lang.Appendable app, int c)
TODO: create Appendable version of UTF16.append(buf, c), maybe in new class Appendables?- Throws:
java.io.IOException
-
append
private static void append(java.lang.Appendable app, java.lang.CharSequence s)
TODO: create class Appendables?- Throws:
java.io.IOException
-
_appendToPat
private static <T extends java.lang.Appendable> T _appendToPat(T buf, java.lang.String s, boolean escapeUnprintable)
Append thetoPattern()
representation of a string to the givenAppendable
.
-
_appendToPat
private static <T extends java.lang.Appendable> T _appendToPat(T buf, int c, boolean escapeUnprintable)
Append thetoPattern()
representation of a character to the givenAppendable
.
-
_appendToPat
private static <T extends java.lang.Appendable> T _appendToPat(T result, int start, int end, boolean escapeUnprintable)
-
toPattern
public java.lang.String toPattern(boolean escapeUnprintable)
Returns a string representation of this set. If the result of calling this function is passed to a UnicodeSet constructor, it will produce another set that is equal to this one.- Specified by:
toPattern
in interfaceUnicodeMatcher
- Parameters:
escapeUnprintable
- 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.
-
_toPattern
private <T extends java.lang.Appendable> T _toPattern(T result, boolean escapeUnprintable)
Append a string representation of this set to result. This will be a cleaned version of the string passed to applyPattern(), if there is one. Otherwise it will be generated.
-
_generatePattern
public java.lang.StringBuffer _generatePattern(java.lang.StringBuffer result, boolean escapeUnprintable)
Generate and append a string representation of this set to result. This does not use this.pat, the cleaned up copy of the string passed to applyPattern().- Parameters:
result
- the buffer into which to generate the patternescapeUnprintable
- escape unprintable characters if true
-
_generatePattern
public java.lang.StringBuffer _generatePattern(java.lang.StringBuffer result, boolean escapeUnprintable, boolean includeStrings)
Generate and append a string representation of this set to result. This does not use this.pat, the cleaned up copy of the string passed to applyPattern().- Parameters:
result
- the buffer into which to generate the patternescapeUnprintable
- escape unprintable characters if trueincludeStrings
- if false, doesn't include the strings.
-
appendNewPattern
private <T extends java.lang.Appendable> T appendNewPattern(T result, boolean escapeUnprintable, boolean includeStrings)
-
size
public int 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.- Returns:
- the number of elements in this set (its cardinality).
-
isEmpty
public boolean isEmpty()
Returns true if this set contains no elements.- Returns:
- true if this set contains no elements.
-
hasStrings
public boolean hasStrings()
- Returns:
- true if this set contains multi-character strings or the empty string.
-
matchesIndexValue
public boolean matchesIndexValue(int v)
Implementation of UnicodeMatcher API. Returns true if this set contains any character whose low byte is the given value. This is used by RuleBasedTransliterator for indexing.- Specified by:
matchesIndexValue
in interfaceUnicodeMatcher
-
matches
public int matches(Replaceable text, int[] offset, int limit, boolean incremental)
Implementation of UnicodeMatcher.matches(). Always matches the longest possible multichar string.- Specified by:
matches
in interfaceUnicodeMatcher
- Overrides:
matches
in classUnicodeFilter
- Parameters:
text
- the text to be matchedoffset
- 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.limit
- 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.incremental
- if true, then assume further characters may be inserted at limit and check for partial matching. Otherwise assume the text as given is complete.- Returns:
- a match degree value indicating a full match, a partial match, or a mismatch. If incremental is false then U_PARTIAL_MATCH should never be returned.
-
matchRest
private static int matchRest(Replaceable text, int start, int limit, java.lang.String s)
Returns the longest match for s in text at the given position. If limit > start then match forward from start+1 to limit matching all characters except s.charAt(0). If limit < start, go backward starting from start-1 matching all characters except s.charAt(s.length()-1). This method assumes that the first character, text.charAt(start), matches s, so it does not check it.- Parameters:
text
- the text to matchstart
- 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).limit
- 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.- 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
-
matchesAt
@Deprecated public int matchesAt(java.lang.CharSequence text, int offset)
Deprecated.This API is ICU internal only.Tests whether the text matches at the offset. If so, returns the end of the longest substring that it matches. If not, returns -1.
-
matchesAt
private static int matchesAt(java.lang.CharSequence text, int offsetInText, java.lang.CharSequence substring)
Does one string contain another, starting at a specific offset?- Parameters:
text
- text to matchoffsetInText
- offset within that textsubstring
- substring to match at offset in text- Returns:
- -1 if match fails, otherwise other.length()
-
addMatchSetTo
public void addMatchSetTo(UnicodeSet toUnionTo)
Implementation of UnicodeMatcher API. Union the set of all characters that may be matched by this object into the given set.- Specified by:
addMatchSetTo
in interfaceUnicodeMatcher
- Parameters:
toUnionTo
- the set into which to union the source characters
-
indexOf
public int indexOf(int c)
Returns the index of the given character within this set, where the set is ordered by ascending code point. If the character is not in this set, return -1. The inverse of this method ischarAt()
.- Returns:
- an index from 0..size()-1, or -1
-
charAt
public int charAt(int index)
Returns the character at the given index within this set, where the set is ordered by ascending code point. If the index is out of range, return -1. The inverse of this method isindexOf()
.- Parameters:
index
- an index from 0..size()-1- Returns:
- the character at the given index, or -1.
-
add
public UnicodeSet add(int start, int end)
Adds the specified range to this set if it is not already present. If this set already contains the specified range, the call leaves this set unchanged. Ifstart > end
then an empty range is added, leaving the set unchanged.- Parameters:
start
- first character, inclusive, of range to be added to this set.end
- last character, inclusive, of range to be added to this set.
-
addAll
public UnicodeSet addAll(int start, int end)
Adds all characters in range (uses preferred naming convention).- Parameters:
start
- The index of where to start on adding all characters.end
- The index of where to end on adding all characters.- Returns:
- a reference to this object
-
add_unchecked
private UnicodeSet add_unchecked(int start, int end)
-
add
public final UnicodeSet add(int c)
Adds the specified character to this set if it is not already present. If this set already contains the specified character, the call leaves this set unchanged.
-
add_unchecked
private final UnicodeSet add_unchecked(int c)
-
add
public final UnicodeSet add(java.lang.CharSequence s)
Adds the specified multicharacter to this set if it is not already present. If this set already contains the multicharacter, the call leaves this set unchanged. Thus "ch" => {"ch"}- Parameters:
s
- the source string- Returns:
- this object, for chaining
-
addString
private void addString(java.lang.CharSequence s)
-
getSingleCP
private static int getSingleCP(java.lang.CharSequence s)
Utility for getting code point from single code point CharSequence. See the public UTF16.getSingleCodePoint() (which returns -1 for null rather than throwing NPE).- Parameters:
s
- to test- Returns:
- a code point IF the string consists of a single one. otherwise returns -1.
-
addAll
public final UnicodeSet addAll(java.lang.CharSequence s)
Adds each of the characters in this string to the set. Thus "ch" => {"c", "h"} If this set already any particular character, it has no effect on that character.- Parameters:
s
- the source string- Returns:
- this object, for chaining
-
retainAll
public final UnicodeSet retainAll(java.lang.CharSequence s)
Retains EACH of the characters in this string. Note: "ch" == {"c", "h"} If this set already any particular character, it has no effect on that character.- Parameters:
s
- the source string- Returns:
- this object, for chaining
-
complementAll
public final UnicodeSet complementAll(java.lang.CharSequence s)
Complement EACH of the characters in this string. Note: "ch" == {"c", "h"} If this set already any particular character, it has no effect on that character.- Parameters:
s
- the source string- Returns:
- this object, for chaining
-
removeAll
public final UnicodeSet removeAll(java.lang.CharSequence s)
Remove EACH of the characters in this string. Note: "ch" == {"c", "h"} If this set already any particular character, it has no effect on that character.- Parameters:
s
- the source string- Returns:
- this object, for chaining
-
removeAllStrings
public final UnicodeSet removeAllStrings()
Remove all strings from this UnicodeSet- Returns:
- this object, for chaining
-
from
public static UnicodeSet from(java.lang.CharSequence s)
Makes a set from a multicharacter string. Thus "ch" => {"ch"}- Parameters:
s
- the source string- Returns:
- a newly created set containing the given string
-
fromAll
public static UnicodeSet fromAll(java.lang.CharSequence s)
Makes a set from each of the characters in the string. Thus "ch" => {"c", "h"}- Parameters:
s
- the source string- Returns:
- a newly created set containing the given characters
-
retain
public UnicodeSet retain(int start, int end)
Retain only the elements in this set that are contained in the specified range. Ifstart > end
then an empty range is retained, leaving the set empty.- Parameters:
start
- first character, inclusive, of rangeend
- last character, inclusive, of range
-
retain
public final UnicodeSet retain(int c)
Retain the specified character from this set if it is present. Upon return this set will be empty if it did not contain c, or will only contain c if it did contain c.- Parameters:
c
- the character to be retained- Returns:
- this object, for chaining
-
retain
public final UnicodeSet retain(java.lang.CharSequence cs)
Retain the specified string in this set if it is present. Upon return this set will be empty if it did not contain s, or will only contain s if it did contain s.- Parameters:
cs
- the string to be retained- Returns:
- this object, for chaining
-
remove
public UnicodeSet remove(int start, int end)
Removes the specified range from this set if it is present. The set will not contain the specified range once the call returns. Ifstart > end
then an empty range is removed, leaving the set unchanged.- Parameters:
start
- first character, inclusive, of range to be removed from this set.end
- last character, inclusive, of range to be removed from this set.
-
remove
public final UnicodeSet remove(int c)
Removes the specified character from this set if it is present. The set will not contain the specified character once the call returns.- Parameters:
c
- the character to be removed- Returns:
- this object, for chaining
-
remove
public final UnicodeSet remove(java.lang.CharSequence s)
Removes the specified string from this set if it is present. The set will not contain the specified string once the call returns.- Parameters:
s
- the string to be removed- Returns:
- this object, for chaining
-
complement
public UnicodeSet complement(int start, int end)
Complements the specified range in this set. Any character in the range will be removed if it is in this set, or will be added if it is not in this set. Ifstart > end
then an empty range is complemented, leaving the set unchanged.- Parameters:
start
- first character, inclusive, of rangeend
- last character, inclusive, of range
-
complement
public final UnicodeSet complement(int c)
Complements the specified character in this set. The character will be removed if it is in this set, or will be added if it is not in this set.
-
complement
public UnicodeSet complement()
This is equivalent tocomplement(MIN_VALUE, MAX_VALUE)
.Note: This performs a symmetric difference with all code points and thus retains all multicharacter strings. In order to achieve a “code point complement” (all code points minus this set), the easiest is to .
complement()
.removeAllStrings()
.
-
complement
public final UnicodeSet complement(java.lang.CharSequence s)
Complement the specified string in this set. The set will not contain the specified string once the call returns.- Parameters:
s
- the string to complement- Returns:
- this object, for chaining
-
contains
public boolean contains(int c)
Returns true if this set contains the given character.- Specified by:
contains
in classUnicodeFilter
- Parameters:
c
- character to be checked for containment- Returns:
- true if the test condition is met
-
findCodePoint
private final int findCodePoint(int c)
Returns the smallest value i such that c < list[i]. Caller must ensure that c is a legal value or this method will enter an infinite loop. This method performs a binary search.- Parameters:
c
- a character in the range MIN_VALUE..MAX_VALUE inclusive- Returns:
- the smallest integer i in the range 0..len-1, inclusive, such that c < list[i]
-
contains
public boolean contains(int start, int end)
Returns true if this set contains every character of the given range.- Parameters:
start
- first character, inclusive, of the rangeend
- last character, inclusive, of the range- Returns:
- true if the test condition is met
-
contains
public final boolean contains(java.lang.CharSequence s)
Returns true if this set contains the given multicharacter string.- Parameters:
s
- string to be checked for containment- Returns:
- true if this set contains the specified string
-
containsAll
public boolean containsAll(UnicodeSet b)
Returns true if this set contains all the characters and strings of the given set.- Parameters:
b
- set to be checked for containment- Returns:
- true if the test condition is met
-
containsAll
public boolean containsAll(java.lang.String s)
Returns true if there is a partition of the string such that this set contains each of the partitioned strings. For example, for the Unicode set [a{bc}{cd}]
containsAll is true for each of: "a", "bc", ""cdbca"
containsAll is false for each of: "acb", "bcda", "bcx"- Parameters:
s
- string containing characters to be checked for containment- Returns:
- true if the test condition is met
-
containsAll
private boolean containsAll(java.lang.String s, int i)
Recursive routine called if we fail to find a match in containsAll, and there are strings- Parameters:
s
- source stringi
- point to match to the end on- Returns:
- true if ok
-
getRegexEquivalent
@Deprecated public java.lang.String getRegexEquivalent()
Deprecated.This API is ICU internal only.Get the Regex equivalent for this UnicodeSet- Returns:
- regex pattern equivalent to this UnicodeSet
-
containsNone
public boolean containsNone(int start, int end)
Returns true if this set contains none of the characters of the given range.- Parameters:
start
- first character, inclusive, of the rangeend
- last character, inclusive, of the range- Returns:
- true if the test condition is met
-
containsNone
public boolean containsNone(UnicodeSet b)
Returns true if none of the characters or strings in this UnicodeSet appears in the string. For example, for the Unicode set [a{bc}{cd}]
containsNone is true for: "xy", "cb"
containsNone is false for: "a", "bc", "bcd"- Parameters:
b
- set to be checked for containment- Returns:
- true if the test condition is met
-
containsNone
public boolean containsNone(java.lang.CharSequence s)
Returns true if this set contains none of the characters of the given string.- Parameters:
s
- string containing characters to be checked for containment- Returns:
- true if the test condition is met
-
containsSome
public final boolean containsSome(int start, int end)
Returns true if this set contains one or more of the characters in the given range.- Parameters:
start
- first character, inclusive, of the rangeend
- last character, inclusive, of the range- Returns:
- true if the condition is met
-
containsSome
public final boolean containsSome(UnicodeSet s)
Returns true if this set contains one or more of the characters and strings of the given set.- Parameters:
s
- set to be checked for containment- Returns:
- true if the condition is met
-
containsSome
public final boolean containsSome(java.lang.CharSequence s)
Returns true if this set contains one or more of the characters of the given string.- Parameters:
s
- string containing characters to be checked for containment- Returns:
- true if the condition is met
-
addAll
public UnicodeSet addAll(UnicodeSet c)
Adds all of the elements in the specified set to this set if they're not already present. This operation effectively modifies this set so that its value is the union of the two sets. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress.- Parameters:
c
- set whose elements are to be added to this set.
-
retainAll
public UnicodeSet retainAll(UnicodeSet c)
Retains only the elements in this set that are contained in the specified set. In other words, removes from this set all of its elements that are not contained in the specified set. This operation effectively modifies this set so that its value is the intersection of the two sets.- Parameters:
c
- set that defines which elements this set will retain.
-
removeAll
public UnicodeSet removeAll(UnicodeSet c)
Removes from this set all of its elements that are contained in the specified set. This operation effectively modifies this set so that its value is the asymmetric set difference of the two sets.- Parameters:
c
- set that defines which elements will be removed from this set.
-
complementAll
public UnicodeSet complementAll(UnicodeSet c)
Complements in this set all elements contained in the specified set. Any character in the other set will be removed if it is in this set, or will be added if it is not in this set.- Parameters:
c
- set that defines which elements will be complemented from this set.
-
clear
public UnicodeSet clear()
Removes all of the elements from this set. This set will be empty after this call returns.
-
getRangeCount
public int getRangeCount()
Iteration method that returns the number of ranges contained in this set.- See Also:
getRangeStart(int)
,getRangeEnd(int)
-
getRangeStart
public int getRangeStart(int index)
Iteration method that returns the first character in the specified range of this set.- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if index is outside the range0..getRangeCount()-1
- See Also:
getRangeCount()
,getRangeEnd(int)
-
getRangeEnd
public int getRangeEnd(int index)
Iteration method that returns the last character in the specified range of this set.- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if index is outside the range0..getRangeCount()-1
- See Also:
getRangeStart(int)
,getRangeEnd(int)
-
compact
public UnicodeSet compact()
Reallocate this objects internal structures to take up the least possible space, without changing this object's value.
-
equals
public boolean equals(java.lang.Object o)
Compares the specified object with this set for equality. Returns true if the specified object is also a set, the two sets have the same size, and every member of the specified set is contained in this set (or equivalently, every member of this set is contained in the specified set).- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
- Object to be compared for equality with this set.- Returns:
- true if the specified Object is equal to this set.
-
hashCode
public int hashCode()
Returns the hash code value for this set.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the hash code value for this set.
- See Also:
Object.hashCode()
-
toString
public java.lang.String toString()
Return a programmer-readable string representation of this object.- Overrides:
toString
in classjava.lang.Object
-
applyPattern
@Deprecated public UnicodeSet applyPattern(java.lang.String pattern, java.text.ParsePosition pos, SymbolTable symbols, int options)
Deprecated.This API is ICU internal only.Parses the given pattern, starting at the given position. The character at pattern.charAt(pos.getIndex()) must be '[', or the parse fails. Parsing continues until the corresponding closing ']'. If a syntax error is encountered between the opening and closing brace, the parse fails. Upon return from a successful parse, the ParsePosition is updated to point to the character following the closing ']', and an inversion list for the parsed pattern is returned. This method calls itself recursively to parse embedded subpatterns.- Parameters:
pattern
- 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.pos
- 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.- Returns:
- an inversion list for the parsed substring
of
pattern
- Throws:
java.lang.IllegalArgumentException
- if the parse fails.
-
applyPattern
private void applyPattern(RuleCharacterIterator chars, SymbolTable symbols, java.lang.Appendable rebuiltPat, int options, int depth)
Parse the pattern from the given RuleCharacterIterator. The iterator is advanced over the parsed pattern.- Parameters:
chars
- 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.symbols
- symbol table to use to parse and dereference variables, or null if none.rebuiltPat
- the pattern that was parsed, rebuilt or copied from the input pattern, as appropriate.options
- a bit mask. Valid options areIGNORE_SPACE
and at most one ofCASE_INSENSITIVE
,ADD_CASE_MAPPINGS
,SIMPLE_CASE_INSENSITIVE
. These case options are mutually exclusive.
-
syntaxError
private static void syntaxError(RuleCharacterIterator chars, java.lang.String msg)
-
addAllTo
public <T extends java.util.Collection<java.lang.String>> T addAllTo(T target)
Add the contents of the UnicodeSet (as strings) into a collection.- Parameters:
target
- collection to add into
-
addAllTo
public java.lang.String[] addAllTo(java.lang.String[] target)
Add the contents of the UnicodeSet (as strings) into a collection.- Parameters:
target
- collection to add into
-
toArray
public static java.lang.String[] toArray(UnicodeSet set)
Add the contents of the UnicodeSet (as strings) into an array.
-
add
public UnicodeSet add(java.lang.Iterable<?> source)
Add the contents of the collection (as strings) into this UnicodeSet. The collection must not contain null.- Parameters:
source
- the collection to add- Returns:
- a reference to this object
-
addAll
public UnicodeSet addAll(java.lang.Iterable<?> source)
Add a collection (as strings) into this UnicodeSet. Uses standard naming convention.- Parameters:
source
- collection to add into- Returns:
- a reference to this object
-
nextCapacity
private int nextCapacity(int minCapacity)
-
ensureCapacity
private void ensureCapacity(int newLen)
-
ensureBufferCapacity
private void ensureBufferCapacity(int newLen)
-
range
private int[] range(int start, int end)
Assumes start <= end.
-
xor
private UnicodeSet xor(int[] other, int otherLen, int polarity)
-
add
private UnicodeSet add(int[] other, int otherLen, int polarity)
-
retain
private UnicodeSet retain(int[] other, int otherLen, int polarity)
-
max
private static final int max(int a, int b)
-
applyFilter
private void applyFilter(UnicodeSet.Filter filter, UnicodeSet inclusions)
Generic filter-based scanning code for UCD property UnicodeSets.
-
mungeCharName
private static java.lang.String mungeCharName(java.lang.String source)
Remove leading and trailing Pattern_White_Space and compress internal Pattern_White_Space to a single space character.
-
applyIntPropertyValue
public UnicodeSet applyIntPropertyValue(int prop, int 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. Prior contents of this set are lost.- Parameters:
prop
- 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.value
- 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.- Returns:
- a reference to this set
-
applyPropertyAlias
public UnicodeSet applyPropertyAlias(java.lang.String propertyAlias, java.lang.String valueAlias)
Modifies this set to contain those code points which have the given value for the given property. Prior contents of this set are lost.- Parameters:
propertyAlias
- 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].valueAlias
- 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.- Returns:
- a reference to this set
-
applyPropertyAlias
public UnicodeSet applyPropertyAlias(java.lang.String propertyAlias, java.lang.String valueAlias, SymbolTable symbols)
Modifies this set to contain those code points which have the given value for the given property. Prior contents of this set are lost.- Parameters:
propertyAlias
- A string of the property alias.valueAlias
- A string of the value alias.symbols
- if not null, then symbols are first called to see if a property is available. If true, then everything else is skipped.- Returns:
- this set
-
resemblesPropertyPattern
private static boolean resemblesPropertyPattern(java.lang.String pattern, int pos)
Return true if the given position, in the given pattern, appears to be the start of a property set pattern.
-
resemblesPropertyPattern
private static boolean resemblesPropertyPattern(RuleCharacterIterator chars, int iterOpts)
Return true if the given iterator appears to point at a property pattern. Regardless of the result, return with the iterator unchanged.- Parameters:
chars
- iterator over the pattern characters. Upon return it will be unchanged.iterOpts
- RuleCharacterIterator options
-
applyPropertyPattern
private UnicodeSet applyPropertyPattern(java.lang.String pattern, java.text.ParsePosition ppos, SymbolTable symbols)
Parse the given property pattern at the given parse position.- Parameters:
symbols
- TODO
-
applyPropertyPattern
private void applyPropertyPattern(RuleCharacterIterator chars, java.lang.Appendable rebuiltPat, SymbolTable symbols)
Parse a property pattern.- Parameters:
chars
- 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.rebuiltPat
- the pattern that was parsed, rebuilt or copied from the input pattern, as appropriate.symbols
- TODO
-
addCaseMapping
private static final void addCaseMapping(UnicodeSet set, int result, java.lang.StringBuilder full)
-
maybeOnlyCaseSensitive
UnicodeSet maybeOnlyCaseSensitive(UnicodeSet src)
For case closure on a large set, look only at code points with relevant properties.
-
scfString
private static final boolean scfString(java.lang.CharSequence s, java.lang.StringBuilder scf)
-
closeOver
public UnicodeSet closeOver(int attribute)
Close this set over the given attribute. For the attributeCASE_INSENSITIVE
, the result is to modify this set so that:- For each character or string 'a' in this set, all strings 'b' such that foldCase(a) == foldCase(b) are added to this set. (For most 'a' that are single characters, 'b' will have b.length() == 1.)
- For each string 'e' in the resulting set, if e != foldCase(e), 'e' will be removed.
Example: [aqß{Bc}{bC}{Fi}] => [aAqQßfi{ss}{bc}{fi}]
(Here foldCase(x) refers to the operation UCharacter.foldCase(x, true), and a == b actually denotes a.equals(b), not pointer comparison.)
- Parameters:
attribute
- bitmask for attributes to close over. Valid options: At most one ofCASE_INSENSITIVE
,ADD_CASE_MAPPINGS
,SIMPLE_CASE_INSENSITIVE
. These case options are mutually exclusive. Unrelated options bits are ignored.- Returns:
- a reference to this set.
-
closeOverCaseInsensitive
private void closeOverCaseInsensitive(boolean simple)
-
closeOverAddCaseMappings
private void closeOverAddCaseMappings()
-
isFrozen
public boolean isFrozen()
Is this frozen, according to the Freezable interface?- Specified by:
isFrozen
in interfaceFreezable<UnicodeSet>
- Returns:
- value
-
freeze
public UnicodeSet freeze()
Freeze this class, according to the Freezable interface.- Specified by:
freeze
in interfaceFreezable<UnicodeSet>
- Returns:
- this
-
span
public int span(java.lang.CharSequence s, UnicodeSet.SpanCondition spanCondition)
Span a string using this UnicodeSet.To replace, count elements, or delete spans, see
UnicodeSetSpanner
.- Parameters:
s
- The string to be spannedspanCondition
- The span condition- Returns:
- the length of the span
-
span
public int span(java.lang.CharSequence s, int start, UnicodeSet.SpanCondition spanCondition)
Span a string using this UnicodeSet. If the start index is less than 0, span will start from 0. If the start index is greater than the string length, span returns the string length.To replace, count elements, or delete spans, see
UnicodeSetSpanner
.- Parameters:
s
- The string to be spannedstart
- The start index that the span beginsspanCondition
- The span condition- Returns:
- the string index which ends the span (i.e. exclusive)
-
spanAndCount
@Deprecated public int spanAndCount(java.lang.CharSequence s, int start, UnicodeSet.SpanCondition spanCondition, OutputInt 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.To replace, count elements, or delete spans, see
UnicodeSetSpanner
.- Parameters:
outCount
- An output-only object (must not be null) for returning the count.- Returns:
- the limit (exclusive end) of the span
-
spanCodePointsAndCount
private int spanCodePointsAndCount(java.lang.CharSequence s, int start, UnicodeSet.SpanCondition spanCondition, OutputInt outCount)
-
spanBack
public int spanBack(java.lang.CharSequence s, UnicodeSet.SpanCondition spanCondition)
Span a string backwards (from the end) using this UnicodeSet.To replace, count elements, or delete spans, see
UnicodeSetSpanner
.- Parameters:
s
- The string to be spannedspanCondition
- The span condition- Returns:
- The string index which starts the span (i.e. inclusive).
-
spanBack
public int spanBack(java.lang.CharSequence s, int fromIndex, UnicodeSet.SpanCondition spanCondition)
Span a string backwards (from the fromIndex) using this UnicodeSet. If the fromIndex is less than 0, spanBack will return 0. If fromIndex is greater than the string length, spanBack will start from the string length.To replace, count elements, or delete spans, see
UnicodeSetSpanner
.- Parameters:
s
- The string to be spannedfromIndex
- The index of the char (exclusive) that the string should be spanned backwardsspanCondition
- The span condition- Returns:
- The string index which starts the span (i.e. inclusive).
-
cloneAsThawed
public UnicodeSet cloneAsThawed()
Clone a thawed version of this class, according to the Freezable interface.- Specified by:
cloneAsThawed
in interfaceFreezable<UnicodeSet>
- Returns:
- the clone, not frozen
-
checkFrozen
private void checkFrozen()
-
ranges
public java.lang.Iterable<UnicodeSet.EntryRange> ranges()
Provide for faster iteration than by String. Returns an Iterable/Iterator over ranges of code points. The UnicodeSet must not be altered during the iteration. The EntryRange instance is the same each time; the contents are just reset.Warning: To iterate over the full contents, you have to also iterate over the strings.
Warning: For speed, UnicodeSet iteration does not check for concurrent modification. Do not alter the UnicodeSet while iterating.
// Sample code for (EntryRange range : us1.ranges()) { // do something with code points between range.codepoint and range.codepointEnd; } for (String s : us1.strings()) { // do something with each string; }
-
iterator
public java.util.Iterator<java.lang.String> iterator()
Returns a string iterator. Uses the same order of iteration asUnicodeSetIterator
.Warning: For speed, UnicodeSet iteration does not check for concurrent modification. Do not alter the UnicodeSet while iterating.
- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.String>
- See Also:
Set.iterator()
-
containsAll
public <T extends java.lang.CharSequence> boolean containsAll(java.lang.Iterable<T> collection)
- See Also:
containsAll(com.ibm.icu.text.UnicodeSet)
-
containsNone
public <T extends java.lang.CharSequence> boolean containsNone(java.lang.Iterable<T> collection)
-
containsSome
public final <T extends java.lang.CharSequence> boolean containsSome(java.lang.Iterable<T> collection)
- See Also:
containsAll(com.ibm.icu.text.UnicodeSet)
-
addAll
public <T extends java.lang.CharSequence> UnicodeSet addAll(T... collection)
- See Also:
addAll(com.ibm.icu.text.UnicodeSet)
-
removeAll
public <T extends java.lang.CharSequence> UnicodeSet removeAll(java.lang.Iterable<T> collection)
- See Also:
removeAll(com.ibm.icu.text.UnicodeSet)
-
retainAll
public <T extends java.lang.CharSequence> UnicodeSet retainAll(java.lang.Iterable<T> collection)
- See Also:
retainAll(com.ibm.icu.text.UnicodeSet)
-
compareTo
public int compareTo(UnicodeSet o)
Compares UnicodeSets, where shorter come first, and otherwise lexicographically (according to the comparison of the first characters that differ).- Specified by:
compareTo
in interfacejava.lang.Comparable<UnicodeSet>
- See Also:
Comparable.compareTo(java.lang.Object)
-
compareTo
public int compareTo(UnicodeSet o, UnicodeSet.ComparisonStyle style)
Compares UnicodeSets, in three different ways.- See Also:
Comparable.compareTo(java.lang.Object)
-
compareTo
public int compareTo(java.lang.Iterable<java.lang.String> other)
-
compare
public static int compare(java.lang.CharSequence string, int codePoint)
Utility to compare a string to a code point. Same results as turning the code point into a string (with the [ugly] new StringBuilder().appendCodePoint(codepoint).toString()) and comparing, but much faster (no object creation). Actually, there is one difference; a null compares as less. Note that this (=String) order is UTF-16 order -- not code point order.
-
compare
public static int compare(int codePoint, java.lang.CharSequence string)
Utility to compare a string to a code point. Same results as turning the code point into a string and comparing, but much faster (no object creation). Actually, there is one difference; a null compares as less. Note that this (=String) order is UTF-16 order -- not code point order.
-
compare
public static <T extends java.lang.Comparable<T>> int compare(java.lang.Iterable<T> collection1, java.lang.Iterable<T> collection2)
Utility to compare two iterables. Warning: the ordering in iterables is important. For Collections that are ordered, like Lists, that is expected. However, Sets in Java violate Leibniz's law when it comes to iteration. That means that sets can't be compared directly with this method, unless they are TreeSets without (or with the same) comparator. Unfortunately, it is impossible to reliably detect in Java whether subclass of Collection satisfies the right criteria, so it is left to the user to avoid those circumstances.
-
compare
@Deprecated public static <T extends java.lang.Comparable<T>> int compare(java.util.Iterator<T> first, java.util.Iterator<T> other)
Deprecated.This API is ICU internal only.Utility to compare two iterators. Warning: the ordering in iterables is important. For Collections that are ordered, like Lists, that is expected. However, Sets in Java violate Leibniz's law when it comes to iteration. That means that sets can't be compared directly with this method, unless they are TreeSets without (or with the same) comparator. Unfortunately, it is impossible to reliably detect in Java whether subclass of Collection satisfies the right criteria, so it is left to the user to avoid those circumstances.
-
compare
public static <T extends java.lang.Comparable<T>> int compare(java.util.Collection<T> collection1, java.util.Collection<T> collection2, UnicodeSet.ComparisonStyle style)
Utility to compare two collections, optionally by size, and then lexicographically.
-
addAllTo
public static <T,U extends java.util.Collection<T>> U addAllTo(java.lang.Iterable<T> source, U target)
Utility for adding the contents of an iterable to a collection.
-
addAllTo
public static <T> T[] addAllTo(java.lang.Iterable<T> source, T[] target)
Utility for adding the contents of an iterable to a collection.
-
strings
public java.util.Collection<java.lang.String> strings()
For iterating through the strings in the set. Example:for (String key : myUnicodeSet.strings()) { doSomethingWith(key); }
-
getSingleCodePoint
@Deprecated public static int getSingleCodePoint(java.lang.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. Otherwise return Integer.MAX_VALUE.
-
addBridges
@Deprecated public UnicodeSet addBridges(UnicodeSet 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. For example, the ranges: \\u2E80-\\u2E99\\u2E9B-\\u2EF3\\u2F00-\\u2FD5\\u2FF0-\\u2FFB\\u3000-\\u303E change to \\u2E80-\\u303E if the dontCare set includes unassigned characters (for a particular version of Unicode).- Parameters:
dontCare
- Set with the don't-care characters for spanning- Returns:
- the input set, modified
-
findIn
@Deprecated public int findIn(java.lang.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. If findNot is true, then reverse the sense of the match: find the first place where the UnicodeSet doesn't match. If there is no match, length is returned.
-
findLastIn
@Deprecated public int findLastIn(java.lang.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. If findNot is true, then reverse the sense of the match: find the last place where the UnicodeSet doesn't match. If there is no match, -1 is returned. BEFORE index is not in the UnicodeSet.
-
stripFrom
@Deprecated public java.lang.String stripFrom(java.lang.CharSequence source, boolean matches)
Deprecated.This API is ICU internal only. Use replaceFrom.Strips code points from source. If matches is true, script all that match this. If matches is false, then strip all that don't match.- Parameters:
source
- The source of the CharSequence to strip from.matches
- A boolean to either strip all that matches or don't match with the current UnicodeSet object.- Returns:
- The string after it has been stripped.
-
getDefaultXSymbolTable
@Deprecated public static UnicodeSet.XSymbolTable getDefaultXSymbolTable()
Deprecated.This API is ICU internal only.Get the default symbol table. Null means ordinary processing. For internal use only.- Returns:
- the symbol table
-
setDefaultXSymbolTable
@Deprecated public static void setDefaultXSymbolTable(UnicodeSet.XSymbolTable xSymbolTable)
Deprecated.This API is ICU internal only.Set the default symbol table. Null means ordinary processing. For internal use only. Will affect all subsequent parsing of UnicodeSets.WARNING: If this function is used with a UnicodeProperty, and the Unassigned characters (gc=Cn) are different than in ICU, you MUST call
UnicodeProperty.ResetCacheProperties
afterwards. If you then callUnicodeSet.setDefaultXSymbolTable
with null to clear the value, you MUST also callUnicodeProperty.ResetCacheProperties
.- Parameters:
xSymbolTable
- the new default symbol table.
-
-