java.lang.Object | |
↳ | sun.text.normalizer.UCharacterIterator |
![]() |
Abstract class that defines an API for iteration on text objects.This is an
interface for forward and backward iteration and random access into a text
object. Forward iteration is done with post-increment and backward iteration
is done with pre-decrement semantics, while the
java.text.CharacterIterator
interface methods provided forward
iteration with "pre-increment" and backward iteration with pre-decrement
semantics. This API is more efficient for forward iteration over code points.
The other major difference is that this API can do both code unit and code point
iteration, java.text.CharacterIterator
can only iterate over
code units and is limited to BMP (0 - 0xFFFF)
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | DONE | Indicator that we have reached the ends of the UTF16 text. |
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Protected default constructor for the subclasses
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a copy of this iterator, independent from other iterators.
| |||||||||||
Returns the code unit at the current index.
| |||||||||||
Gets the current index in text.
| |||||||||||
Returns a
UCharacterIterator object given a
CharacterIterator. | |||||||||||
Returns a
UCharacterIterator object given a
source StringBuffer. | |||||||||||
Returns a
UCharacterIterator object given a
source string. | |||||||||||
Returns the length of the text
| |||||||||||
Fills the buffer with the underlying text storage of the iterator
If the buffer capacity is not enough a exception is thrown.
| |||||||||||
Convenience method for returning the underlying text storage as as string
| |||||||||||
Convenience override for
getText(char[], int) that provides
an offset of 0. | |||||||||||
Moves the current position by the number of code units
specified, either forward or backward depending on the sign
of delta (positive or negative respectively).
| |||||||||||
Returns the UTF16 code unit at index, and increments to the next
code unit (post-increment semantics).
| |||||||||||
Returns the code point at index, and increments to the next code
point (post-increment semantics).
| |||||||||||
Decrement to the position of the previous code unit in the
text, and return it (pre-decrement semantics).
| |||||||||||
Sets the index to the specified index in the text.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Indicator that we have reached the ends of the UTF16 text. Moved from UForwardCharacterIterator.java
Protected default constructor for the subclasses
Creates a copy of this iterator, independent from other iterators. If it is not possible to clone the iterator, returns null.
CloneNotSupportedException |
---|
Returns the code unit at the current index. If index is out of range, returns DONE. Index is not changed.
Gets the current index in text.
Returns a UCharacterIterator
object given a
CharacterIterator.
source | a valid CharacterIterator object. |
---|
IllegalArgumentException | if the argument is null |
---|
Returns a UCharacterIterator
object given a
source StringBuffer.
source | an string buffer of UTF-16 code units |
---|
IllegalArgumentException | if the argument is null |
---|
Returns a UCharacterIterator
object given a
source string.
source | a string |
---|
IllegalArgumentException | if the argument is null |
---|
Returns the length of the text
Fills the buffer with the underlying text storage of the iterator
If the buffer capacity is not enough a exception is thrown. The capacity
of the fill in buffer should at least be equal to length of text in the
iterator obtained by calling getLength()
.
Usage:
UChacterIterator iter = new UCharacterIterator.getInstance(text);
char[] buf = new char[iter.getLength()];
iter.getText(buf);
OR
char[] buf= new char[1];
int len = 0;
for(;;){
try{
len = iter.getText(buf);
break;
}catch(IndexOutOfBoundsException e){
buf = new char[iter.getLength()];
}
}
fillIn | an array of chars to fill with the underlying UTF-16 code units. |
---|---|
offset | the position within the array to start putting the data. |
exception if there is not enough room after offset in the array, or if offset < 0. |
Convenience method for returning the underlying text storage as as string
Convenience override for getText(char[], int)
that provides
an offset of 0.
fillIn | an array of chars to fill with the underlying UTF-16 code units. |
---|
exception if there is not enough room in the array. |
Moves the current position by the number of code units specified, either forward or backward depending on the sign of delta (positive or negative respectively). If the resulting index would be less than zero, the index is set to zero, and if the resulting index would be greater than limit, the index is set to limit.
delta | the number of code units to move the current index. |
---|
IndexOutOfBoundsException | is thrown if an invalid index is supplied |
---|
Returns the UTF16 code unit at index, and increments to the next code unit (post-increment semantics). If index is out of range, DONE is returned, and the iterator is reset to the limit of the text.
Returns the code point at index, and increments to the next code
point (post-increment semantics). If index does not point to a
valid surrogate pair, the behavior is the same as
next()
. Otherwise the iterator is incremented past
the surrogate pair, and the code point represented by the pair
is returned.
Decrement to the position of the previous code unit in the text, and return it (pre-decrement semantics). If the resulting index is less than 0, the index is reset to 0 and DONE is returned.
Sets the index to the specified index in the text.
index | the index within the text. |
---|
IndexOutOfBoundsException | is thrown if an invalid index is supplied |
---|