|
GXPARSE hosted by |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectca.gorman.util.scan.spi.AbstractScanBuffer
public abstract class AbstractScanBuffer
A ScanBuffer factory.
AbstractScanBuffer holds only references and indices to the data in the
CharSequence. Consequently, a change in the content of a
CharSequence can produce a change in the content of any
buffer or sub-buffer. If a non-volatile character sequence is required,
from a buffer or sub-buffer, the sequence should be obtained by invoking the
toString() method on the buffer, sub-buffer, or a subsequence of the
buffer or sub-buffer. Sub-sequences and strings are obtained directly from
the underlying CharSequence, thereby exploiting all of the
efficiencies in the implementation of the CharSequence.
| Constructor Summary | |
|---|---|
protected |
AbstractScanBuffer(CharSequence charSequence)
Construct on a CharSequence |
protected |
AbstractScanBuffer(CharSequence charSequence,
InputControl inputControl)
Construct on a CharSequence |
| Method Summary | |
|---|---|
MatchedText |
accept(int length)
Remove a prefix of the ScanBuffer from the
ScanBuffer and create a MatchedText
containing the same characters. |
MatchedText |
act(ScanRule scanRule)
Test a ScanRule for a match against a leading prefix
of the ScanBuffer and invoke the corresponding
action if the match
succeeds. |
char |
charAt(int index)
|
void |
discardMatchedText()
Release all previously accepted input
data. |
boolean |
expand()
Increase the amount of data in the buffer, if the buffer supports expansion. |
int |
fill()
Read characters into free space in the buffer. |
Map<String,CharSequence> |
getMap()
Get the map that supports saving
and retrieving character sequences as
temporary values. |
boolean |
hitLast()
Indicate whether the last character in the buffer has been accessed since the previous invocation of this function. |
int |
length()
|
static AbstractScanBuffer |
newInstance(CharSequence charSequence)
Create a AbstractScanBuffer for scanning and
matching on a CharSequence |
static AbstractScanBuffer |
newInstance(CharSequence charSequence,
InputControl inputControl)
Create a AbstractScanBuffer for scanning
and matching on a CharSequence |
CharSequence |
put(String key,
CharSequence value)
Save a CharSequence for later
retrieval in an
action. |
ScanState |
setScanState(ScanState scanState)
Set a reference to the scanner state for use by the
buffer match and act method. |
ScanBuffer |
subBuffer(int offset)
Get a new buffer, beginning at the specified offset from the beginning of the buffer, and continuing to the end of the parent buffer. |
CharSequence |
subSequence(int start,
int end)
|
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
protected AbstractScanBuffer(CharSequence charSequence)
CharSequence that has a fixed length.
- Parameters:
charSequence - The data to be scanned
- Throws:
NullPointerException - if any parameter is null
protected AbstractScanBuffer(CharSequence charSequence,
InputControl inputControl)
CharSequence with a length that can be
increased by a request from the AbstractScanBuffer.
- Parameters:
charSequence - The data to be scannedinputControl - Callback interface for increasing the length
- Throws:
NullPointerException - if any parameter is null
| Method Detail |
|---|
public static AbstractScanBuffer newInstance(CharSequence charSequence,
InputControl inputControl)
AbstractScanBuffer for scanning
and matching on a CharSequence with a length that can be
increased by a request from the AbstractScanBuffer.
- Parameters:
charSequence - The data to be scannedinputControl - Callback interface for increasing the length
- Throws:
NullPointerException - if any parameter is null
G
public static AbstractScanBuffer newInstance(CharSequence charSequence)
AbstractScanBuffer for scanning and
matching on a CharSequence that has a fixed length.
- Parameters:
charSequence - The data to be scanned
- Throws:
NullPointerException - if any parameter is null
public int length()
length in interface CharSequencepublic char charAt(int index)
charAt in interface CharSequencepublic boolean hitLast()
InputScanBufferIndicate whether the last character in the buffer has been accessed since the previous invocation of this function.
Resets the indicator to false until the next time that the
last character is accessed.
hitLast in interface InputScanBuffer
public CharSequence subSequence(int start,
int end)
subSequence in interface CharSequencepublic String toString()
toString in interface CharSequencetoString in class Objectpublic MatchedText accept(int length)
ScanBuffer
Remove a prefix of the ScanBuffer from the
ScanBuffer and create a MatchedText
containing the same characters.
Although the prefix is no longer available in this
ScanBuffer any
ancestors of this
ScanBuffer will remain unchanged.
accept in interface ScanBufferlength - the number (zero or more) of characters to accept and
remove.
MatchedText, containing the
accepted characters
public void discardMatchedText()
throws IOException
InputScanBuffer
Release all previously accepted input
data.
Warning:
In some implementations, the previously accepted
MatchedText instances will no longer contain valid
data.
discardMatchedText in interface InputScanBufferIOException
public int fill()
throws IOException
InputScanBufferRead characters into free space in the buffer.
This method may block until characters become available.
fill in interface InputScanBufferIOException
public boolean expand()
throws IOException
ExpandableIncrease the amount of data in the buffer, if the buffer supports expansion.
Expansion is not guaranteed, because the buffer may not support expansion or because the current state of the buffer (or its data source) may not permit expansion.
A successful expansion of a full buffer will increase the memory used by the buffer. A buffer with free space may simply add more data to the free space instead of acquiring and filling additional memory.
expand in interface ExpandableIOExceptionpublic ScanBuffer subBuffer(int offset)
ScanBufferGet a new buffer, beginning at the specified offset from the beginning of the buffer, and continuing to the end of the parent buffer.
The new buffer shares the characters from the offset to the end of the parent buffer.
subBuffer in interface ScanBuffer
public CharSequence put(String key,
CharSequence value)
ScanBuffer
Save a CharSequence for later
retrieval in an
action.
The data will be discarded when the Scanner completes the
next action.
put in interface ScanBufferpublic Map<String,CharSequence> getMap()
InputScanBuffer
Get the map that supports
saving
and retrieving character sequences as
temporary values.
getMap in interface InputScanBufferpublic ScanState setScanState(ScanState scanState)
InputScanBuffer
Set a reference to the scanner state for use by the
buffer match and act method.
setScanState in interface InputScanBuffer
public MatchedText act(ScanRule scanRule)
throws IOException
ScanBuffer
Test a ScanRule for a match against a leading prefix
of the ScanBuffer and invoke the corresponding
action if the match
succeeds.
act in interface ScanBufferIOExceptionInputScanBuffer.setScanState(ScanState)
|
GXPARSE download | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||