StringCharacterIterator
  public
  
  final
  
  class
  StringCharacterIterator
  
    extends Object
  
  
  
  
  
      implements
      
        CharacterIterator
      
  
  
| java.lang.Object | |
| ↳ | java.text.StringCharacterIterator | 
StringCharacterIterator implements the
 CharacterIterator protocol for a String.
 The StringCharacterIterator class iterates over the
 entire String.
See also:
Summary
| Inherited constants | 
|---|
| Public constructors | |
|---|---|
| 
      StringCharacterIterator(String text)
      Constructs an iterator with an initial index of 0. | |
| 
      StringCharacterIterator(String text, int pos)
      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. | |
| Public methods | |
|---|---|
| 
        
        
        
        
        
        Object | 
      clone()
      Creates a copy of this iterator. | 
| 
        
        
        
        
        
        char | 
      current()
      Implements CharacterIterator.current() for String. | 
| 
        
        
        
        
        
        boolean | 
      equals(Object obj)
      Compares the equality of two StringCharacterIterator objects. | 
| 
        
        
        
        
        
        char | 
      first()
      Implements CharacterIterator.first() for String. | 
| 
        
        
        
        
        
        int | 
      getBeginIndex()
      Implements CharacterIterator.getBeginIndex() for String. | 
| 
        
        
        
        
        
        int | 
      getEndIndex()
      Implements CharacterIterator.getEndIndex() for String. | 
| 
        
        
        
        
        
        int | 
      getIndex()
      Implements CharacterIterator.getIndex() for String. | 
| 
        
        
        
        
        
        int | 
      hashCode()
      Computes a hashcode for this iterator. | 
| 
        
        
        
        
        
        char | 
      last()
      Implements CharacterIterator.last() for String. | 
| 
        
        
        
        
        
        char | 
      next()
      Implements CharacterIterator.next() for String. | 
| 
        
        
        
        
        
        char | 
      previous()
      Implements CharacterIterator.previous() for String. | 
| 
        
        
        
        
        
        char | 
      setIndex(int p)
      Implements CharacterIterator.setIndex() for String. | 
| 
        
        
        
        
        
        void | 
      setText(String text)
      Reset this iterator to point to a new string. | 
| Inherited methods | |
|---|---|
Public constructors
StringCharacterIterator
public StringCharacterIterator (String text)
Constructs an iterator with an initial index of 0.
| Parameters | |
|---|---|
| text | String: theStringto be iterated over | 
StringCharacterIterator
public StringCharacterIterator (String text, int pos)
Constructs an iterator with the specified initial index.
| Parameters | |
|---|---|
| text | String: The String to be iterated over | 
| pos | int: Initial iterator position | 
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 | String: The String to be iterated over | 
| begin | int: Index of the first character | 
| end | int: Index of the character following the last character | 
| pos | int: Initial iterator position | 
Public methods
clone
public Object clone ()
Creates a copy of this iterator.
| Returns | |
|---|---|
| Object | A copy of this | 
current
public char current ()
Implements CharacterIterator.current() for String.
| Returns | |
|---|---|
| char | the character at the current position or DONE if the current position is off the end of the text. | 
See also:
equals
public boolean equals (Object obj)
Compares the equality of two StringCharacterIterator objects.
| Parameters | |
|---|---|
| obj | Object: the StringCharacterIterator object to be compared with. | 
| Returns | |
|---|---|
| boolean | true if the given obj is the same as this StringCharacterIterator object; false otherwise. | 
first
public char first ()
Implements CharacterIterator.first() for String.
| Returns | |
|---|---|
| char | the first character in the text, or DONE if the text is empty | 
See also:
getBeginIndex
public int getBeginIndex ()
Implements CharacterIterator.getBeginIndex() for String.
| Returns | |
|---|---|
| int | the index at which the text begins. | 
See also:
getEndIndex
public int getEndIndex ()
Implements CharacterIterator.getEndIndex() for String.
| Returns | |
|---|---|
| int | the index after the last character in the text | 
See also:
getIndex
public int getIndex ()
Implements CharacterIterator.getIndex() for String.
| Returns | |
|---|---|
| int | the current index. | 
See also:
hashCode
public int hashCode ()
Computes a hashcode for this iterator.
| Returns | |
|---|---|
| int | A hash code | 
last
public char last ()
Implements CharacterIterator.last() for String.
| Returns | |
|---|---|
| char | the last character in the text, or DONE if the text is empty | 
See also:
next
public char next ()
Implements CharacterIterator.next() for String.
| Returns | |
|---|---|
| char | the character at the new position or DONE if the new position is off the end of the text range. | 
See also:
previous
public char previous ()
Implements CharacterIterator.previous() for String.
| Returns | |
|---|---|
| char | the character at the new position or DONE if the current position is equal to getBeginIndex(). | 
See also:
setIndex
public char setIndex (int p)
Implements CharacterIterator.setIndex() for String.
| Parameters | |
|---|---|
| p | int: the position within the text.  Valid values range from
 getBeginIndex() to getEndIndex().  An IllegalArgumentException is thrown
 if an invalid value is supplied. | 
| Returns | |
|---|---|
| char | the character at the specified position or DONE if the specified position is equal to getEndIndex() | 
See also:
setText
public void setText (String text)
Reset this iterator to point to a new string. This package-visible method is used by other java.text classes that want to avoid allocating new StringCharacterIterator objects every time their setText method is called.
| Parameters | |
|---|---|
| text | String: The String to be iterated over | 
