| |
|
| java.lang.Object com.ibm.icu.text.UCharacterIterator com.ibm.icu.impl.StringUCharacterIterator
StringUCharacterIterator | final public class StringUCharacterIterator extends UCharacterIterator (Code) | | Used by Collation. UCharacterIterator on Strings. Can't use
ReplaceableUCharacterIterator because it is not easy to do a fast setText.
author: synwee |
Method Summary | |
public Object | clone() | public int | current() Returns the current UTF16 character. | public int | getIndex() Gets the current currentIndex in text. | public int | getLength() | public int | getText(char[] fillIn, int offset) Fills the buffer with the underlying text storage of the iterator
If the buffer capacity is not enough a exception is thrown. | public String | getText() | public int | next() Returns next UTF16 character and increments the iterator's currentIndex
by 1. | public int | previous() Returns previous UTF16 character and decrements the iterator's
currentIndex by 1. | public void | setIndex(int currentIndex) Sets the currentIndex to the specified currentIndex in the text and
returns that single UTF16 character at currentIndex. | public void | setText(String text) Reset this iterator to point to a new string. |
StringUCharacterIterator | public StringUCharacterIterator(String str)(Code) | | Public constructor
Parameters: str - text which the iterator will be based on |
StringUCharacterIterator | public StringUCharacterIterator()(Code) | | Public default constructor
|
clone | public Object clone()(Code) | | Creates a copy of this iterator, does not clone the underlying
String object
copy of this iterator |
current | public int current()(Code) | | Returns the current UTF16 character.
current UTF16 character |
getIndex | public int getIndex()(Code) | | Gets the current currentIndex in text.
current currentIndex in text. |
getLength | public int getLength()(Code) | | Returns the length of the text
length of the text |
getText | public int getText(char[] fillIn, int offset)(Code) | | 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()];
}
}
Parameters: fillIn - an array of chars to fill with the underlying UTF-16 code units. Parameters: offset - the position within the array to start putting the data. the number of code units added to fillIn, as a convenience exception: IndexOutOfBoundsException - exception if there is not enoughroom after offset in the array, or if offset < 0. |
getText | public String getText()(Code) | | Convenience method for returning the underlying text storage as as
string
the underlying text storage in the iterator as a string |
next | public int next()(Code) | | Returns next UTF16 character and increments the iterator's currentIndex
by 1.
If the resulting currentIndex is greater or equal to the text length,
the currentIndex is reset to the text length and a value of DONE is
returned.
next UTF16 character in text or DONE if the new currentIndex is off the end of the text range. |
previous | public int previous()(Code) | | Returns previous UTF16 character and decrements the iterator's
currentIndex by 1.
If the resulting currentIndex is less than 0, the currentIndex is reset
to 0 and a value of DONE is returned.
next UTF16 character in text or DONE if the new currentIndex is off the start of the text range. |
setIndex | public void setIndex(int currentIndex) throws IndexOutOfBoundsException(Code) | | Sets the currentIndex to the specified currentIndex in the text and
returns that single UTF16 character at currentIndex.
This assumes the text is stored as 16-bit code units.
Parameters: currentIndex - the currentIndex within the text. exception: IndexOutOfBoundsException - is thrown if an invalid currentIndex is supplied. i.e. currentIndex is out of bounds. |
setText | public void setText(String text)(Code) | | Reset this iterator to point to a new string. This method is used by
other classes that want to avoid allocating new
ReplaceableCharacterIterator objects every time their setText method
is called.
Parameters: text - The String to be iterated over |
|
|
|