|
GXPARSE hosted by | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Scanner
Control interface for a character scanning, matching, and translation engine.
The Scanner
applies a list
of
scan rules
that matches
character sequences
in a
scan buffer
and sends each character sequence
to a corresponding action method
. The action method can
send the characters to the default output
, discard the
characters, or do something else with them.
When no characters can be matched from the rule list, characters are removed from the scan buffer and send to the default output until more characters can be matched, or until the scan buffer is empty. An effective way to replace a few subsequences of characters is to use scan rules to identify those subsequences and send the replacements to the default output and let the scanner send all all other characters directly to the default output.
If the application designer knows that long sequences of characters will be
discarded to default output, scanning efficiency can often be improved by
using ScanRule
s to identify the sequences and send them
directly to the default output. When short sequences are to be discarded
to the default output, it may be better to let the Scanner
do the work.
Method Summary | |
---|---|
void |
scan(CharSequence charSequence,
Appendable appendable,
RuleList ruleList)
Set the scanner to initial condition, scan a CharSequence with fixed content, and output to an
Appendable . |
void |
scan(CharSequence charSequence,
Appendable appendable,
RuleList ruleList,
InputControl inputControl)
Set the scanner to initial condition, scan a CharSequence with modifiable content, and
output to an Appendable . |
void |
scan(Reader reader,
Appendable appendable,
RuleList ruleList)
Set the scanner to initial condition, scan from a Reader ,
and output to an Appendable . |
AsynchronousScanState |
startScan(InputScanBuffer inputScanBuffer,
Appendable appendable,
RuleList ruleList)
Start a new asynchonous scanner and return a view of its current state. |
Method Detail |
---|
void scan(CharSequence charSequence, Appendable appendable, RuleList ruleList) throws IOException
Set the scanner to initial condition, scan a
CharSequence
with fixed content, and output to an
Appendable
.
The Appendable
will be flushed if it is a
Flushable
, but will not be closed if it is also a
Closeable
charSequence
- a character sequence containing the characters to
be scanned as inputappendable
- a default destination for output from the
Scanner
ruleList
- the scanning rules
IllegalStateException
- if Scanner
is already
running.
IOException
- if an output error occurs
NullPointerException
- if any parameter is nullvoid scan(CharSequence charSequence, Appendable appendable, RuleList ruleList, InputControl inputControl) throws IOException
Set the scanner to initial condition, scan a
CharSequence
with modifiable content, and
output to an Appendable
.
The Appendable
will be flushed if it is a
Flushable
, but will not be closed if it is also a
Closeable
charSequence
- a character sequence containing the characters to
be scanned as inputappendable
- a default destination for output from the
Scanner
ruleList
- the scanning rulesinputControl
- a control object that the Scanner
can use to make additional characters available in the
charSequence
IllegalStateException
- if Scanner
is already
running.
IOException
- if an output error occurs
NullPointerException
- if any parameter is nullvoid scan(Reader reader, Appendable appendable, RuleList ruleList) throws IOException
Set the scanner to initial condition, scan from a Reader
,
and output to an Appendable
.
The Appendable
will be flushed if it is a
Flushable
, but will not be closed if it is also a
Closeable
reader
- a source of characters to be scanned as inputappendable
- a default destination for output from the
Scanner
ruleList
- the scanning rules
IllegalStateException
- if Scanner
is already
running.
IOException
- if an input or output error occurs
NullPointerException
- if any parameter is nullAsynchronousScanState startScan(InputScanBuffer inputScanBuffer, Appendable appendable, RuleList ruleList) throws IOException, InterruptedException
Start a new asynchonous scanner and return a view of its current state.
The Appendable
will be flushed if it is a
Flushable
, and be closed if it is also a
Closeable
inputScanBuffer
- a scannable source of character sequencesappendable
- a default destination for output from the
Scanner
ruleList
- the scanning rules
Thread
in which the scanner is running
InterruptedException
- if the thread is interrupted before this
method returns
IOException
- if an input or output error occurs
NullPointerException
- if any parameter is null
|
GXPARSE download | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |