Class CharacterIteratorWrapper

  • All Implemented Interfaces:
    UForwardCharacterIterator, java.lang.Cloneable

    public class CharacterIteratorWrapper
    extends UCharacterIterator
    This class is a wrapper around CharacterIterator and implements the UCharacterIterator protocol
    • Constructor Summary

      Constructors 
      Constructor Description
      CharacterIteratorWrapper​(java.text.CharacterIterator iter)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object clone()
      Creates a clone of this iterator.
      int current()
      Returns the code unit at the current index.
      java.text.CharacterIterator getCharacterIterator()
      Returns a java.text.CharacterIterator object for the underlying text of this iterator.
      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 moveIndex​(int delta)
      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).
      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.
      void setToLimit()
      Sets the current index to the limit.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • iterator

        private java.text.CharacterIterator iterator
    • Constructor Detail

      • CharacterIteratorWrapper

        public CharacterIteratorWrapper​(java.text.CharacterIterator iter)
    • Method Detail

      • next

        public int next()
        Description copied from class: UCharacterIterator
        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.
        Specified by:
        next in interface UForwardCharacterIterator
        Specified by:
        next in class UCharacterIterator
        Returns:
        the next UTF16 code unit, or DONE if the index is at the limit of the text.
        See Also:
        UCharacterIterator.next()
      • previous

        public int previous()
        Description copied from class: UCharacterIterator
        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.
        Specified by:
        previous in class UCharacterIterator
        Returns:
        the previous code unit in the text, or DONE if the new index is before the start of the text.
        See Also:
        UCharacterIterator.previous()
      • 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 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()];
                     }
                 }
         
        Specified by:
        getText in class UCharacterIterator
        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:
        UCharacterIterator.getText(char[])
      • moveIndex

        public int moveIndex​(int delta)
        Description copied from class: UCharacterIterator
        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.
        Overrides:
        moveIndex in class UCharacterIterator
        Parameters:
        delta - the number of code units to move the current index.
        Returns:
        the new index.