|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.freecompany.util.text.State
public class State
Encompases the state of a text processor. This includes a view of the currently available input data, complete with automatic management functions, as well as a position and mark variable. The position is the position of the last character processed, and the mark is a place holder for recalling the start of the current input chunk.
It should be noted that in general the performance of text operations on this state object will be slightly higher when the entirety of the input sequence is held within a single buffer. In other words, when possible it is preferrable to provide the complete input sequence with a singleappend( CharSequence sequence)
invocation.
By utilizing the CharSequence
interface exclusively, this scanner can natively supports
String
, CharBuffer
, StringBuilder
and StringBuffer
objects as
input sequences, as well as specially wrapped ByteBuffer
instances.
Field Summary | |
---|---|
protected int |
mark
|
protected int |
position
|
protected java.lang.CharSequence |
sequence
|
Constructor Summary | |
---|---|
State()
|
Method Summary | |
---|---|
void |
append(java.nio.ByteBuffer buffer)
The buffer is assumed to be US-ASCII encoded text (with undefined behavior if this is not the case) and is simply wrapped to look like a character sequence. |
void |
append(java.nio.ByteBuffer buffer,
java.nio.charset.CharsetDecoder decoder)
Appends a new buffer to the target using the provided decoder. |
void |
append(java.lang.CharSequence sequence)
Appends a new sequence to the end of the existing one, allowing the sequence to grow in place. |
char |
charAt(int index)
|
void |
clear()
|
java.lang.CharSequence |
expunge()
Performs a soft expunge which only removes the first sequences that have been exhausted. |
java.lang.CharSequence |
expunge(boolean force)
Removes the next unneeded sequence from this parser, if one is available. |
int |
getMark()
|
boolean |
hasNext()
|
java.util.Iterator<java.lang.Character> |
iterator()
|
int |
length()
|
void |
mark()
|
boolean |
marked()
|
java.lang.Character |
next()
|
char |
peek()
Examines the next character without advancing the position. |
char |
peekPlus(int advance)
Examines the character at the position plus the argument without advancing the position. |
int |
position()
|
void |
position(int position)
|
char |
previous()
Returns the character immediately preceeding the current character in this sate object. |
int |
remaining()
|
void |
remove()
|
void |
reset()
|
java.lang.CharSequence |
rest()
|
java.lang.CharSequence |
sequence()
|
java.lang.CharSequence |
slice()
Slices the most recently processed logical characters sequence by capturing and returning the sequence of characters between the mark and the current position and then marking the new position. |
java.lang.CharSequence |
subSequence(int from,
int to)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.lang.CharSequence |
---|
toString |
Field Detail |
---|
protected java.lang.CharSequence sequence
protected int position
protected int mark
Constructor Detail |
---|
public State()
Method Detail |
---|
public void clear()
public void append(java.lang.CharSequence sequence)
public void append(java.nio.ByteBuffer buffer)
UTF-8
.
The buffer is used as is and must be preserved until this state object is no longer
needed, and any sub-sequences or slices have been discarded.
public void append(java.nio.ByteBuffer buffer, java.nio.charset.CharsetDecoder decoder) throws java.nio.charset.CharacterCodingException
CharBuffer
is allocated from the pool and the buffer is decoded into it in it's entirety.
The caller is free to reuse or dispose of the passed buffer immediately.
java.nio.charset.CharacterCodingException
public java.lang.CharSequence expunge()
expunge( boolean force)
with the argument false
.
public java.lang.CharSequence expunge(boolean force)
force
flag is specified, then the first CharSequence
will be
removed regardless of the current position of this scanner.
public java.lang.CharSequence sequence()
public java.lang.CharSequence subSequence(int from, int to)
subSequence
in interface java.lang.CharSequence
public char charAt(int index)
charAt
in interface java.lang.CharSequence
public int length()
length
in interface java.lang.CharSequence
public java.util.Iterator<java.lang.Character> iterator()
iterator
in interface java.lang.Iterable<java.lang.Character>
public java.lang.CharSequence slice()
public final char previous()
public final char peek()
public final char peekPlus(int advance)
public final java.lang.Character next()
next
in interface java.util.Iterator<java.lang.Character>
public final int remaining()
public final boolean hasNext()
hasNext
in interface java.util.Iterator<java.lang.Character>
public final java.lang.CharSequence rest()
public final void position(int position)
public final int position()
public boolean marked()
public final void mark()
public final int getMark()
public final void reset()
public void remove()
remove
in interface java.util.Iterator<java.lang.Character>
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |