public class

CharacterIteratorWrapper

extends UCharacterIterator
java.lang.Object
   ↳ sun.text.normalizer.UCharacterIterator
     ↳ sun.text.normalizer.CharacterIteratorWrapper

Class Overview

This class is a wrapper around CharacterIterator and implements the UCharacterIterator protocol

Summary

[Expand]
Inherited Constants
From class sun.text.normalizer.UCharacterIterator
Public Constructors
CharacterIteratorWrapper(CharacterIterator iter)
Public Methods
Object clone()
Creates a clone of this iterator.
int current()
Returns the code unit at the current index.
int getIndex()
Gets the current index in text.
int getLength()
Returns the length of the text
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.
int next()
Returns the UTF16 code unit at index, and increments to the next code unit (post-increment semantics).
int previous()
Decrement to the position of the previous code unit in the text, and return it (pre-decrement semantics).
void setIndex(int index)
Sets the index to the specified index in the text.
[Expand]
Inherited Methods
From class sun.text.normalizer.UCharacterIterator
From class java.lang.Object

Public Constructors

public CharacterIteratorWrapper (CharacterIterator iter)

Public Methods

public Object clone ()

Creates a clone of this iterator. Clones the underlying character iterator.

Returns
  • copy of this iterator
See Also

public int current ()

Returns the code unit at the current index. If index is out of range, returns DONE. Index is not changed.

Returns
  • current code unit
See Also

public int getIndex ()

Gets the current index in text.

Returns
  • current index in text.
See Also

public int getLength ()

Returns the length of the text

Returns
  • length of the text
See Also

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. 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.
offset the position within the array to start putting the data.
Returns
  • the number of code units added to fillIn, as a convenience
See Also

public int next ()

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 next UTF16 code unit, or DONE if the index is at the limit of the text.
See Also

public int previous ()

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.

Returns
  • the previous code unit in the text, or DONE if the new index is before the start of the text.
See Also

public void setIndex (int index)

Sets the index to the specified index in the text.

Parameters
index the index within the text.
See Also