Note: The counting, deletion, and replacement depend on alternating a SpanCondition with
its inverse. That is, the code spans, then spans for the inverse, then spans, and so on.
For the inverse, the following mapping is used:
UnicodeSet.SpanCondition#SIMPLE → UnicodeSet.SpanCondition#NOT_CONTAINED UnicodeSet.SpanCondition#CONTAINED → UnicodeSet.SpanCondition#NOT_CONTAINED UnicodeSet.SpanCondition#NOT_CONTAINED → UnicodeSet.SpanCondition#SIMPLE | SIMPLE | xxx[ab]cyyy |
|---|---|
| CONTAINED | xxx[abc]yyy |
| NOT_CONTAINED | [xxx]ab[cyyy] |
So here is what happens when you alternate:
| start | |xxxabcyyy |
|---|---|
| NOT_CONTAINED | xxx|abcyyy |
| CONTAINED | xxxabc|yyy |
| NOT_CONTAINED | xxxabcyyy| |
The entire string is traversed.
| Modifier and Type | Class and Description |
|---|---|
| public static enum | UnicodeSetSpanner.CountMethod
Options for replaceFrom and countIn to control how to treat each matched span. |
| public static enum | UnicodeSetSpanner.TrimOption
Options for the trim() method |
| Modifier and Type | Field and Description |
|---|---|
| private final UnicodeSet |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public int | Returns: the count. Zero if there are none.the sequence to count characters in sequence)Returns the number of matching characters found in a character sequence, counting by CountMethod.MIN_ELEMENTS using SpanCondition.SIMPLE. |
| public int | Returns: the count. Zero if there are none.the sequence to count characters in sequence, UnicodeSetSpanner.whether to treat an entire span as a match, or individual elements as matches countMethodReturns the number of matching characters found in a character sequence, using SpanCondition.SIMPLE. |
| public int | Returns: the count. Zero if there are none.the sequence to count characters in sequence, UnicodeSetSpanner.whether to treat an entire span as a match, or individual elements as matches countMethod,the spanCondition to use. SIMPLE or CONTAINED means only count the elements in the span;
NOT_CONTAINED is the reverse spanConditionWarning when a UnicodeSet contains strings, there may be unexpected behavior in edge cases. Returns the number of matching characters found in a character sequence. |
| public String | Returns: modified string.charsequence to replace matching spans in. sequence)Delete all the matching spans in sequence, using SpanCondition.SIMPLE
The code alternates spans; see the class doc for |
| public String | Returns: modified string.charsequence to replace matching spans in. sequence, UnicodeSet.specify whether to modify the matching spans (CONTAINED or SIMPLE) or the non-matching (NOT_CONTAINED) spanConditionDelete all matching spans in sequence, according to the spanCondition. |
| public boolean | equals(Object
the reference object with which to compare. other)Overrides java. |
| public UnicodeSet | |
| public int | |
| public String | Returns: modified string.charsequence to replace matching spans in. sequence, CharSequence replacement sequence. To delete, use "" replacement)Replace all matching spans in sequence by the replacement, counting by CountMethod.MIN_ELEMENTS using SpanCondition.SIMPLE. |
| public String | Returns: modified string.charsequence to replace matching spans in. sequence, CharSequence replacement sequence. To delete, use "" replacement, UnicodeSetSpanner.whether to treat an entire span as a match, or individual elements as matches countMethodReplace all matching spans in sequence by replacement, according to the CountMethod, using SpanCondition.SIMPLE. |
| public String | Returns: modified string.charsequence to replace matching spans in. sequence, CharSequence replacement sequence. To delete, use "" replacement, UnicodeSetSpanner.whether to treat an entire span as a match, or individual elements as matches countMethod,specify whether to modify the matching spans (CONTAINED or SIMPLE) or the non-matching
(NOT_CONTAINED) spanConditionReplace all matching spans in sequence by replacement, according to the countMethod and spanCondition. |
| public CharSequence | Returns: a subsequencethe sequence to trim sequence)Returns a trimmed sequence (using CharSequence.subsequence()), that omits matching elements at the start and end of the string, using TrimOption.BOTH and SpanCondition.SIMPLE. |
| public CharSequence | Returns: a subsequencethe sequence to trim sequence, UnicodeSetSpanner.LEADING, TRAILING, or BOTH trimOptionReturns a trimmed sequence (using CharSequence.subsequence()), that omits matching elements at the start or end of the string, using the trimOption and SpanCondition.SIMPLE. |
| public CharSequence | Returns: a subsequencethe sequence to trim sequence, UnicodeSetSpanner.LEADING, TRAILING, or BOTH trimOption,SIMPLE, CONTAINED or NOT_CONTAINED spanConditionReturns a trimmed sequence (using CharSequence.subsequence()), that omits matching elements at the start or end of the string, depending on the trimOption and spanCondition. |
| unicodeSet | back to summary |
|---|---|
| private final UnicodeSet unicodeSet | |
| UnicodeSetSpanner | back to summary |
|---|---|
| public UnicodeSetSpanner(UnicodeSet source) Create a spanner from a UnicodeSet. For speed and safety, the UnicodeSet should be frozen. However, this class can be used with a non-frozen version to avoid the cost of freezing.
| |
| countIn | back to summary |
|---|---|
| public int countIn(CharSequence sequence) Returns the number of matching characters found in a character sequence,
counting by CountMethod.MIN_ELEMENTS using SpanCondition.SIMPLE.
The code alternates spans; see the class doc for
| |
| countIn | back to summary |
|---|---|
| public int countIn(CharSequence sequence, UnicodeSetSpanner. Returns the number of matching characters found in a character sequence, using SpanCondition.SIMPLE.
The code alternates spans; see the class doc for
| |
| countIn | back to summary |
|---|---|
| public int countIn(CharSequence sequence, UnicodeSetSpanner. Returns the number of matching characters found in a character sequence.
The code alternates spans; see the class doc for
| |
| deleteFrom | back to summary |
|---|---|
| public String deleteFrom(CharSequence sequence) Delete all the matching spans in sequence, using SpanCondition.SIMPLE
The code alternates spans; see the class doc for
| |
| deleteFrom | back to summary |
|---|---|
| public String deleteFrom(CharSequence sequence, UnicodeSet. Delete all matching spans in sequence, according to the spanCondition.
The code alternates spans; see the class doc for
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| getUnicodeSet | back to summary |
|---|---|
| public UnicodeSet getUnicodeSet() Returns the UnicodeSet used for processing. It is frozen iff the original was.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| replaceFrom | back to summary |
|---|---|
| public String replaceFrom(CharSequence sequence, CharSequence replacement) Replace all matching spans in sequence by the replacement,
counting by CountMethod.MIN_ELEMENTS using SpanCondition.SIMPLE.
The code alternates spans; see the class doc for
| |
| replaceFrom | back to summary |
|---|---|
| public String replaceFrom(CharSequence sequence, CharSequence replacement, UnicodeSetSpanner. Replace all matching spans in sequence by replacement, according to the CountMethod, using SpanCondition.SIMPLE.
The code alternates spans; see the class doc for
| |
| replaceFrom | back to summary |
|---|---|
| public String replaceFrom(CharSequence sequence, CharSequence replacement, UnicodeSetSpanner. Replace all matching spans in sequence by replacement, according to the countMethod and spanCondition.
The code alternates spans; see the class doc for
| |
| trim | back to summary |
|---|---|
| public CharSequence trim(CharSequence sequence) Returns a trimmed sequence (using CharSequence.subsequence()), that omits matching elements at the start and end of the string, using TrimOption.BOTH and SpanCondition.SIMPLE. For example:
... returns "cat".
| |
| trim | back to summary |
|---|---|
| public CharSequence trim(CharSequence sequence, UnicodeSetSpanner. Returns a trimmed sequence (using CharSequence.subsequence()), that omits matching elements at the start or end of the string, using the trimOption and SpanCondition.SIMPLE. For example:
... returns "catbab".
| |
| trim | back to summary |
|---|---|
| public CharSequence trim(CharSequence sequence, UnicodeSetSpanner. Returns a trimmed sequence (using CharSequence.subsequence()), that omits matching elements at the start or end of the string, depending on the trimOption and spanCondition. For example:
... returns "catbab".
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final UnicodeSetSpanner. | MIN_ELEMENTS
Use the smallest number of elements in the spanned range for counting and modification,
based on the |
| public static final UnicodeSetSpanner. | WHOLE_SPAN
Collapse spans. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static UnicodeSetSpanner. | |
| public static UnicodeSetSpanner. |
| MIN_ELEMENTS | back to summary |
|---|---|
| public static final UnicodeSetSpanner. Use the smallest number of elements in the spanned range for counting and modification,
based on the For example, in the string "abab" with SpanCondition.SIMPLE:
| |
| WHOLE_SPAN | back to summary |
|---|---|
| public static final UnicodeSetSpanner. Collapse spans. That is, modify/count the entire matching span as a single item, instead of separate set elements.
| |
| CountMethod | back to summary |
|---|---|
| private CountMethod() | |
| valueOf | back to summary |
|---|---|
| public static UnicodeSetSpanner. | |
| values | back to summary |
|---|---|
| public static UnicodeSetSpanner. | |
| Modifier and Type | Field and Description |
|---|---|
| public static final UnicodeSetSpanner. | BOTH
Trim leading and trailing spans. |
| public static final UnicodeSetSpanner. | LEADING
Trim leading spans. |
| public static final UnicodeSetSpanner. | TRAILING
Trim trailing spans. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static UnicodeSetSpanner. | |
| public static UnicodeSetSpanner. |
| BOTH | back to summary |
|---|---|
| public static final UnicodeSetSpanner. Trim leading and trailing spans.
| |
| LEADING | back to summary |
|---|---|
| public static final UnicodeSetSpanner. Trim leading spans.
| |
| TRAILING | back to summary |
|---|---|
| public static final UnicodeSetSpanner. Trim trailing spans.
| |
| TrimOption | back to summary |
|---|---|
| private TrimOption() | |
| valueOf | back to summary |
|---|---|
| public static UnicodeSetSpanner. | |
| values | back to summary |
|---|---|
| public static UnicodeSetSpanner. | |