Package com.ibm.icu.impl
Class ReplaceableUCharacterIterator
- java.lang.Object
-
- com.ibm.icu.text.UCharacterIterator
-
- com.ibm.icu.impl.ReplaceableUCharacterIterator
-
- All Implemented Interfaces:
UForwardCharacterIterator
,java.lang.Cloneable
public class ReplaceableUCharacterIterator extends UCharacterIterator
DLF docs must define behavior when Replaceable is mutated underneath the iterator. This and ICUCharacterIterator share some code, maybe they should share an implementation, or the common state and implementation should be moved up into UCharacterIterator. What are first, last, and getBeginIndex doing here?!?!?!
-
-
Field Summary
Fields Modifier and Type Field Description private int
currentIndex
Current currentIndexprivate Replaceable
replaceable
Replacable object-
Fields inherited from interface com.ibm.icu.text.UForwardCharacterIterator
DONE
-
-
Constructor Summary
Constructors Constructor Description ReplaceableUCharacterIterator(Replaceable replaceable)
Public constructorReplaceableUCharacterIterator(java.lang.String str)
Public constructorReplaceableUCharacterIterator(java.lang.StringBuffer buf)
Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Creates a copy of this iterator, does not clone the underlyingReplaceable
objectint
current()
Returns the current UTF16 character.int
currentCodePoint()
Returns the current codepointint
getIndex()
Gets the current currentIndex in text.int
getLength()
Returns the length of the textint
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.int
next()
Returns next UTF16 character and increments the iterator's currentIndex by 1.int
previous()
Returns previous UTF16 character and decrements the iterator's currentIndex by 1.void
setIndex(int currentIndex)
Sets the currentIndex to the specified currentIndex in the text and returns that single UTF16 character at currentIndex.-
Methods inherited from class com.ibm.icu.text.UCharacterIterator
getCharacterIterator, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getText, getText, moveCodePointIndex, moveIndex, nextCodePoint, previousCodePoint, setToLimit, setToStart
-
-
-
-
Field Detail
-
replaceable
private Replaceable replaceable
Replacable object
-
currentIndex
private int currentIndex
Current currentIndex
-
-
Constructor Detail
-
ReplaceableUCharacterIterator
public ReplaceableUCharacterIterator(Replaceable replaceable)
Public constructor- Parameters:
replaceable
- text which the iterator will be based on
-
ReplaceableUCharacterIterator
public ReplaceableUCharacterIterator(java.lang.String str)
Public constructor- Parameters:
str
- text which the iterator will be based on
-
ReplaceableUCharacterIterator
public ReplaceableUCharacterIterator(java.lang.StringBuffer buf)
Public constructor- Parameters:
buf
- buffer of text on which the iterator will be based
-
-
Method Detail
-
clone
public java.lang.Object clone()
Creates a copy of this iterator, does not clone the underlyingReplaceable
object- Overrides:
clone
in classUCharacterIterator
- Returns:
- copy of this iterator
-
current
public int current()
Returns the current UTF16 character.- Specified by:
current
in classUCharacterIterator
- Returns:
- current UTF16 character
-
currentCodePoint
public int currentCodePoint()
Returns the current codepoint- Overrides:
currentCodePoint
in classUCharacterIterator
- Returns:
- current codepoint
-
getLength
public int getLength()
Returns the length of the text- Specified by:
getLength
in classUCharacterIterator
- Returns:
- length of the text
-
getIndex
public int getIndex()
Gets the current currentIndex in text.- Specified by:
getIndex
in classUCharacterIterator
- Returns:
- current currentIndex in text.
-
next
public int next()
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 DONECODEPOINT is returned.- Specified by:
next
in interfaceUForwardCharacterIterator
- Specified by:
next
in classUCharacterIterator
- Returns:
- next UTF16 character in text or DONE if the new currentIndex is off the end of the text range.
-
previous
public int previous()
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 DONECODEPOINT is returned.- Specified by:
previous
in classUCharacterIterator
- Returns:
- 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 java.lang.IndexOutOfBoundsException
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.
- Specified by:
setIndex
in classUCharacterIterator
- Parameters:
currentIndex
- the currentIndex within the text.- Throws:
java.lang.IllegalArgumentException
- is thrown if an invalid currentIndex is supplied. i.e. currentIndex is out of bounds.java.lang.IndexOutOfBoundsException
- is thrown if an invalid index is supplied
-
getText
public int getText(char[] fillIn, int offset)
Description copied from class:UCharacterIterator
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 callinggetLength()
). 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()]; } }
- Specified by:
getText
in classUCharacterIterator
- Parameters:
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.- Returns:
- the number of code units added to fillIn, as a convenience
-
-