Send bugs or comments to Bernd Kühl (bernd@informatik.uni-osnabrueck.de)

lolo
Class Scan

java.lang.Object
  |
  +--lolo.Scan
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Mux, Scan

public abstract class Scan
extends java.lang.Object
implements java.io.Serializable

The abstract base class for recognizer classes.

Author:
Bernd Kühl (bernd@informatik.uni-osnabrueck.de)
See Also:
Serialized Form

Inner Class Summary
static interface Scan.Action
          Action code for a recognized symbols is represented by Action objects.
static class Scan.State
          A simple class to mark the result for nextChar().
 
Field Summary
protected  Scan.Action action
          The action object; can be null for no action.
protected  boolean ignore
          Marks if the symbol will be ignored.
 
Constructor Summary
Scan()
           
 
Method Summary
 void action(char[] buffer, int off, int len)
          If action is not null, then the action method is called for this object.
abstract  boolean equals(java.lang.Object o)
          Subclasses have to implement this method to indicate whether some other object is "equal to" this one.
 Scan.Action getAction()
          Returns the action object.
 boolean getIgnore()
          Returns the ignore state.
abstract  int hashCode()
          Subclasses have to implement this method to return a hash code value for the receiver.
abstract  Scan.State nextChar(char ch)
          Called by a Scanner for every new character.
abstract  void reset()
          Resets this instance.
 Scan setAction(Scan.Action action)
          Sets the action object.
 Scan setIgnore(boolean ignore)
          Sets the ignore state.
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

action

protected transient Scan.Action action
The action object; can be null for no action.
See Also:
Scan.Action

ignore

protected boolean ignore
Marks if the symbol will be ignored.
Constructor Detail

Scan

public Scan()
Method Detail

reset

public abstract void reset()
Resets this instance.

getAction

public Scan.Action getAction()
Returns the action object.
Returns:
the action object.
See Also:
Scan.Action

setAction

public Scan setAction(Scan.Action action)
Sets the action object.
Parameters:
action - the new action object.
Returns:
this for cascading method calls.
See Also:
Scan.Action

action

public void action(char[] buffer,
                   int off,
                   int len)
If action is not null, then the action method is called for this object.
Parameters:
buffer - the character buffer holding the characters of the symbol.
off - offset into the buffer.
len - number of characters for the symbol.
See Also:
action

setIgnore

public Scan setIgnore(boolean ignore)
Sets the ignore state.
Parameters:
ignore - the new ignore state.
Returns:
this for cascading method calls.

getIgnore

public boolean getIgnore()
Returns the ignore state.
Returns:
the ignore state.

equals

public abstract boolean equals(java.lang.Object o)
Subclasses have to implement this method to indicate whether some other object is "equal to" this one.
Overrides:
equals in class java.lang.Object
Returns:
true if this object is the same as the argument; false otherwise.

hashCode

public abstract int hashCode()
Subclasses have to implement this method to return a hash code value for the receiver.
Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.

nextChar

public abstract Scan.State nextChar(char ch)
Called by a Scanner for every new character.
Returns:
a State object to signal whether more characters are wanted and whether a symbol is found.
See Also:
Scan.State, Scanner

Send bugs or comments to Bernd Kühl (bernd@informatik.uni-osnabrueck.de)