Class StringCharacterIterator

java.lang.Object
java.text.StringCharacterIterator
All Implemented Interfaces:
Cloneable,CharacterIterator

public final classStringCharacterIteratorextendsObjectimplementsCharacterIterator
StringCharacterIterator implements theCharacterIterator protocol for aString. TheStringCharacterIterator class iterates over the entireString. All constructors throwNullPointerException iftext isnull.
Since:
1.1
See Also:
  • Field Summary

    Fields declared in interface java.text.CharacterIterator

    DONE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an iterator with an initial index of 0.
    Constructs an iterator with the specified initial index.
    StringCharacterIterator(String text, int begin, int end, int pos)
    Constructs an iterator over the given range of the given string, with the index set at the specified position.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a copy of this iterator.
    char
    Implements CharacterIterator.current() for String.
    boolean
    Compares the equality of two StringCharacterIterator objects.
    char
    Implements CharacterIterator.first() for String.
    int
    Implements CharacterIterator.getBeginIndex() for String.
    int
    Implements CharacterIterator.getEndIndex() for String.
    int
    Implements CharacterIterator.getIndex() for String.
    int
    Computes a hashcode for this iterator.
    char
    Implements CharacterIterator.last() for String.
    char
    Implements CharacterIterator.next() for String.
    char
    Implements CharacterIterator.previous() for String.
    char
    setIndex(int p)
    Implements CharacterIterator.setIndex() for String.
    void
    Reset this iterator to point to a new string.

    Methods declared in class java.lang.Object

    finalize,getClass,notify,notifyAll,toString,wait,wait,wait
  • Constructor Details

    • StringCharacterIterator

      public StringCharacterIterator(String text)
      Constructs an iterator with an initial index of 0.
      Parameters:
      text - theString to be iterated over
    • StringCharacterIterator

      public StringCharacterIterator(String text, int pos)
      Constructs an iterator with the specified initial index.
      Parameters:
      text - The String to be iterated over
      pos - Initial iterator position
      Throws:
      IllegalArgumentException - ifpos is not within the bounds of range (inclusive) from0 to the length oftext
    • StringCharacterIterator

      public StringCharacterIterator(String text, int begin, int end, int pos)
      Constructs an iterator over the given range of the given string, with the index set at the specified position.
      Parameters:
      text - The String to be iterated over
      begin - Index of the first character
      end - Index of the character following the last character
      pos - Initial iterator position
      Throws:
      IllegalArgumentException - ifbegin andend are not within the bounds of range (inclusive) from0 to the length oftext,begin is greater thanend, orpos is not within the bounds of range (inclusive) frombegin toend
  • Method Details