APIdia Launch Partner
Top Description Fields Constructors Methods
java.text

public final Class StringCharacterIterator

extends Object
implements CharacterIterator
Class Inheritance
All Implemented Interfaces
java.text.CharacterIterator, java.lang.Cloneable
Imports
java.util.Objects

StringCharacterIterator implements the CharacterIterator protocol for a String. The StringCharacterIterator class iterates over the entire String. All constructors throw NullPointerException if text is null.
Since
1.1
See Also
CharacterIterator

Field Summary

Modifier and TypeField and Description
private int
private int
private int
private String

Constructor Summary

AccessConstructor and Description
public
StringCharacterIterator(String
the String to be iterated over
text
)

Constructs an iterator with an initial index of 0.

public
StringCharacterIterator(String
The String to be iterated over
text
,
int
Initial iterator position
pos
)

Constructs an iterator with the specified initial index.

public
StringCharacterIterator(String
The String to be iterated over
text
,
int
Index of the first character
begin
,
int
Index of the character following the last character
end
,
int
Initial iterator position
pos
)

Constructs an iterator over the given range of the given string, with the index set at the specified position.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

A copy of this
clone
()

Overrides java.lang.Object.clone.

Implements java.text.CharacterIterator.clone.

Creates a copy of this iterator.

public char
current()

Implements java.text.CharacterIterator.current.

Implements CharacterIterator.current() for String.

public boolean

Returns:

true if the given obj is the same as this StringCharacterIterator object; false otherwise.
equals
(Object
the StringCharacterIterator object to be compared with.
obj
)

Overrides java.lang.Object.equals.

Compares the equality of two StringCharacterIterator objects.

public char
first()

Implements java.text.CharacterIterator.first.

Implements CharacterIterator.first() for String.

public int
getBeginIndex()

Implements java.text.CharacterIterator.getBeginIndex.

Implements CharacterIterator.getBeginIndex() for String.

public int
getEndIndex()

Implements java.text.CharacterIterator.getEndIndex.

Implements CharacterIterator.getEndIndex() for String.

public int
getIndex()

Implements java.text.CharacterIterator.getIndex.

Implements CharacterIterator.getIndex() for String.

public int

Returns:

A hash code
hashCode
()

Overrides java.lang.Object.hashCode.

Computes a hashcode for this iterator.

public char
last()

Implements java.text.CharacterIterator.last.

Implements CharacterIterator.last() for String.

public char
next()

Implements java.text.CharacterIterator.next.

Implements CharacterIterator.next() for String.

public char
previous()

Implements java.text.CharacterIterator.previous.

Implements CharacterIterator.previous() for String.

public char
setIndex(int p)

Implements java.text.CharacterIterator.setIndex.

Implements CharacterIterator.setIndex() for String.

public void
setText(String
The String to be iterated over
text
)

Reset this iterator to point to a new string.

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

beginback to summary
private int begin
endback to summary
private int end
posback to summary
private int pos
textback to summary
private String text

Constructor Detail

StringCharacterIteratorback to summary
public StringCharacterIterator(String text)

Constructs an iterator with an initial index of 0.

Parameters
text:String

the String to be iterated over

StringCharacterIteratorback to summary
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

Exceptions
IllegalArgumentException:
if pos is not within the bounds of range (inclusive) from 0 to the length of text
StringCharacterIteratorback to summary
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

Exceptions
IllegalArgumentException:
if begin and end are not within the bounds of range (inclusive) from 0 to the length of text, begin is greater than end, or pos is not within the bounds of range (inclusive) from begin to end

Method Detail

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Implements java.text.CharacterIterator.clone.

Creates a copy of this iterator.

Returns:Object

A copy of this

currentback to summary
public char current()

Implements java.text.CharacterIterator.current.

Implements CharacterIterator.current() for String.

See Also
CharacterIterator#current
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

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.

firstback to summary
public char first()

Implements java.text.CharacterIterator.first.

Implements CharacterIterator.first() for String.

See Also
CharacterIterator#first
getBeginIndexback to summary
public int getBeginIndex()

Implements java.text.CharacterIterator.getBeginIndex.

Implements CharacterIterator.getBeginIndex() for String.

See Also
CharacterIterator#getBeginIndex
getEndIndexback to summary
public int getEndIndex()

Implements java.text.CharacterIterator.getEndIndex.

Implements CharacterIterator.getEndIndex() for String.

See Also
CharacterIterator#getEndIndex
getIndexback to summary
public int getIndex()

Implements java.text.CharacterIterator.getIndex.

Implements CharacterIterator.getIndex() for String.

See Also
CharacterIterator#getIndex
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Computes a hashcode for this iterator.

Returns:int

A hash code

lastback to summary
public char last()

Implements java.text.CharacterIterator.last.

Implements CharacterIterator.last() for String.

See Also
CharacterIterator#last
nextback to summary
public char next()

Implements java.text.CharacterIterator.next.

Implements CharacterIterator.next() for String.

See Also
CharacterIterator#next
previousback to summary
public char previous()

Implements java.text.CharacterIterator.previous.

Implements CharacterIterator.previous() for String.

See Also
CharacterIterator#previous
setIndexback to summary
public char setIndex(int p)

Implements java.text.CharacterIterator.setIndex.

Implements CharacterIterator.setIndex() for String.

Exceptions
IllegalArgumentException:
if p is not within the bounds (inclusive) of getBeginIndex() to getEndIndex()
See Also
CharacterIterator#setIndex
setTextback to summary
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

Exceptions
NullPointerException:
if text is null
Since
1.2