Package ghidra.app.util.demangler
Class CharacterIterator
java.lang.Object
ghidra.app.util.demangler.CharacterIterator
A class for bidirectional iteration over a string.
 
 Iterators maintain a current character index, whose valid range is from
 0 to string.length()-1.
 
 The current index can be retrieved by calling getIndex() and set directly
 by calling setIndex().
 
 The methods previous() and next() are used for iteration. They return DONE if
 they would move outside the range from 0 to string.length()-1.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final charConstant that is returned when the iterator has reached either the end or the beginning of the text.
- 
Constructor SummaryConstructorsConstructorDescriptionCharacterIterator(String str) Constructs a new character iterator using str.
- 
Method SummaryModifier and TypeMethodDescriptionintfind(char c) Looks for the next occurrence of 'c' starting at the current index.charReturns the character at the current index and then increments the index by one.intgetIndex()Returns the current index.intReturns the length of the iterator.Returns the underlying string.booleanhasNext()Returns true if there are more characters to read.charnext()Increments the current index by one and returns the character at the new index.intReturns the next integer.nextString(int len) Returns the next ascii string of the specified length starting at the current index.charpeek()Returns the next character without incrementing the current index.charpeek(int lookAhead) Peeks at the character current index + lookAhead.charprevious()Decrements the current index by one and returns the character at the new index.voidsetIndex(int index) Sets the position to the specified position in the text.toString()
- 
Field Details- 
DONEpublic static final char DONEConstant that is returned when the iterator has reached either the end or the beginning of the text. The value is '\\uFFFF', the "not a character" value which should not occur in any valid Unicode string.- See Also:
 
 
- 
- 
Constructor Details- 
CharacterIteratorConstructs a new character iterator using str.- Parameters:
- str- the string to iterate
 
 
- 
- 
Method Details- 
getStringReturns the underlying string.- Returns:
- the underlying string
 
- 
getIndexpublic int getIndex()Returns the current index.- Returns:
- the current index.
 
- 
getLengthpublic int getLength()Returns the length of the iterator.- Returns:
- the length of the iterator
 
- 
setIndexpublic void setIndex(int index) Sets the position to the specified position in the text.- Parameters:
- index- the position within the text.
 
- 
hasNextpublic boolean hasNext()Returns true if there are more characters to read.- Returns:
- true if there are more characters to read
 
- 
peekpublic char peek()Returns the next character without incrementing the current index.- Returns:
- the next character without incrementing the current index
 
- 
peekpublic char peek(int lookAhead) Peeks at the character current index + lookAhead. Returns DONE if the computed position is out of range.- Parameters:
- lookAhead- number of characters to look ahead
- Returns:
- the character at index+lookAhead
 
- 
nextpublic char next()Increments the current index by one and returns the character at the new index. If the resulting index is greater or equal to the end index, the current index is reset to the end index and a value of DONE is returned.- Returns:
- the character at the new position or DONE
 
- 
getAndIncrementpublic char getAndIncrement()Returns the character at the current index and then increments the index by one. If the resulting index is greater or equal to the end index, the current index is reset to the end index and a value of DONE is returned.- Returns:
- the character at the new position or DONE
 
- 
previouspublic char previous()Decrements the current index by one and returns the character at the new index. If the current index is 0, the index remains at 0 and a value of DONE is returned.- Returns:
- the character at the new position or DONE
 
- 
nextStringReturns the next ascii string of the specified length starting at the current index.- Parameters:
- len- the length of the string to read
- Returns:
- the next ascii string
 
- 
nextIntegerpublic int nextInteger()Returns the next integer. The radix must be 10 (decimal). For example, given "...12fred..". If current index is pointing to the '1', then this value will return 12.- Returns:
- the next base-10 integer.
 
- 
findpublic int find(char c) Looks for the next occurrence of 'c' starting at the current index. Returns the character position in the underlying string or -1 if 'c' is not found.
- 
toString
 
-