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

lolo
Class Mux

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

class Mux
extends Scan

A Mux mulitplexes two or more Scan instances.

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

Inner classes inherited from class lolo.Scan
Scan.Action, Scan.State
 
Field Summary
protected  boolean[] done
          Array displaying active Scan objects.
protected  int max
          Indexes into scans.
protected  int next
          Indexes into scans.
protected  Scan[] scans
          Collects all managed Scan instances.
protected  Scan.State stateObject
          A State object which is used for nextChar().
protected  Scan winner
          At the end of one round winner holds the winning Scan object.
 
Fields inherited from class lolo.Scan
action, ignore
 
Constructor Summary
Mux(Scan s1, Scan s2)
          Creates a Mux object.
 
Method Summary
 void action(char[] buffer, int off, int len)
          Calls action() for the winning Scan object.
 void add(Scan scan)
          Adds a Scan object.
 boolean equals(java.lang.Object obj)
          Indicate whether some other object is "equal to" this one.
 int hashCode()
          Returns a hash code value for the object.
 Scan.State nextChar(char ch)
          Called by a Scanner for every new character.
 void reset()
          Resets all managed Scan instance.
 Scan setAction(Scan.Action action)
          This method just throws a RuntimeException because no action for a Mux is allowed.
 java.lang.String toString()
          Returns a string representation.
 Scan winner()
          Returns the winning Scan object.
 
Methods inherited from class lolo.Scan
getAction, getIgnore, setIgnore
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

stateObject

protected final Scan.State stateObject
A State object which is used for nextChar().

scans

protected Scan[] scans
Collects all managed Scan instances.

max

protected int max
Indexes into scans.

next

protected int next
Indexes into scans.

winner

protected transient Scan winner
At the end of one round winner holds the winning Scan object.

done

protected boolean[] done
Array displaying active Scan objects.
Constructor Detail

Mux

public Mux(Scan s1,
           Scan s2)
    throws java.lang.IllegalArgumentException
Creates a Mux object.
Parameters:
s1 - a Scan object.
s2 - a Scan object.
Throws:
java.lang.IllegalArgumentException - if one argument is null.
Method Detail

add

public void add(Scan scan)
         throws java.lang.IllegalArgumentException
Adds a Scan object.
Parameters:
scan - a Scan object.
Throws:
java.lang.IllegalArgumentException - if scan argument is null.

reset

public void reset()
Resets all managed Scan instance.
Overrides:
reset in class Scan

nextChar

public Scan.State nextChar(char ch)
Description copied from class: Scan
Called by a Scanner for every new character.
Overrides:
nextChar in class Scan
Following copied from class: lolo.Scan
Returns:
a State object to signal whether more characters are wanted and whether a symbol is found.
See Also:
Scan.State, Scanner

action

public void action(char[] buffer,
                   int off,
                   int len)
Calls action() for the winning Scan object.
Overrides:
action in class Scan
Following copied from class: lolo.Scan
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:
Scan.action

winner

public Scan winner()
Returns the winning Scan object.
Returns:
the winning Scan object.

toString

public java.lang.String toString()
Returns a string representation.
Overrides:
toString in class java.lang.Object
Returns:
a string representation.

hashCode

public int hashCode()
Returns a hash code value for the object.
Overrides:
hashCode in class Scan
Returns:
the sum of the hash codes of the encapsulated objects.

equals

public boolean equals(java.lang.Object obj)
Indicate whether some other object is "equal to" this one.
Overrides:
equals in class Scan
Parameters:
obj - the reference object with which to compare.
Returns:
true if obj is a Mux object and contains the same objects (by identity) in the same order, false otherwise.

setAction

public Scan setAction(Scan.Action action)
This method just throws a RuntimeException because no action for a Mux is allowed.
Overrides:
setAction in class Scan
Throws:
java.lang.RuntimeException - no action for a Mux is allowed.

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