com.sap.i18n.text
Class Utf16StringCharIter
java.lang.Object
|
+--com.sap.i18n.text.Utf16StringCharIter
- public class Utf16StringCharIter
- extends java.lang.Object
Iterator to iterate over String in Unicode character steps
(1 or 2 16-bit code units) as alternative to String.charAt.
coding sample old:
for (int i = 0; i < s.length(); ++i ) {
char ch = s.charAt( i );
doSomethingWith( ch );
}
coding sample new:
Utf16StringCharIter iter = new Utf16StringCharIter( s );
while( !iter.isFinished() ) {
int ch = iter.getNextChar();
doSomethingWith( ch );
}
Constructor Summary |
Utf16StringCharIter()
Build Utf16StringCharIter empty,
without specifying string to operate on |
Utf16StringCharIter(java.lang.String str)
Build Utf16StringCharIter to iterate on str. |
Method Summary |
int |
getNextChar()
Returns current Unicode character and moves iterator forward
to next Unicode character. |
char |
getNextCharSimplified()
If the current Unicode character is a "simple" character, returns
this character, else returns Unicode replacement character U+FFFD.
|
void |
init(java.lang.String str)
initialize Utf16StringCharIter to iterate on str |
boolean |
isFinished()
Returns if iterator has reached end of string and no
more characters can be retrieved with getNextChar() or
getNextCharSimplified() |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Utf16StringCharIter
public Utf16StringCharIter(java.lang.String str)
- Build Utf16StringCharIter to iterate on str.
Utf16StringCharIter
public Utf16StringCharIter()
- Build Utf16StringCharIter empty,
without specifying string to operate on
init
public final void init(java.lang.String str)
- initialize Utf16StringCharIter to iterate on str
getNextChar
public final int getNextChar()
- Returns current Unicode character and moves iterator forward
to next Unicode character.
getNextCharSimplified
public final char getNextCharSimplified()
- If the current Unicode character is a "simple" character, returns
this character, else returns Unicode replacement character U+FFFD.
A "simple" character means, that the haracter is not a surrogate pair
and is not combined with following combining characters.
Moves iterator forward to next Unicode character.
isFinished
public final boolean isFinished()
- Returns if iterator has reached end of string and no
more characters can be retrieved with getNextChar() or
getNextCharSimplified()