scanner
Class Transition

java.lang.Object
  extended byscanner.Transition
Direct Known Subclasses:
IsAlphaTransition, IsDigitTransition

public class Transition
extends java.lang.Object

This class defines transitions between states that are used for defining finale state automatas. A transition can then be added to one and only one state.


Constructor Summary
Transition(State state, char character)
           
Transition(State state, char[] characters)
          Constructs a new transition.
 
Method Summary
 void add(char[] characters)
          Adds new characters to this transition to activate it.
 boolean contains(char character)
          Returns true if the given character activate this transition.
 boolean contains(char[] characters)
          Returns true if the given characters activate this transition.
 char[] getChars()
          Returns characters that activate this transition.
 State getSourceState()
          Returns the source state of this transition.
 State getTargetState()
          Returns the target state of this transition.
 char[] intersect(char[] parameter)
          Returns an array containing characters that are activating this transition and that are also contained in the given array.
 boolean isPossible(char character)
          Checks if this transition would be activated with the given character.
 boolean isSelfTransition()
          Returns true if this transition is a self transition.
 void setTargetState(State state)
          Sets the target state of this transition.
 void substract(char[] characters)
          Removes the given characters to the ones activating this transition.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Transition

public Transition(State state,
                  char[] characters)
Constructs a new transition.

Parameters:
state - The new state reached if this transition is activated.
characters - Characters that will activate this transition.

Transition

public Transition(State state,
                  char character)
Method Detail

isPossible

public boolean isPossible(char character)
Checks if this transition would be activated with the given character.

Parameters:
character - The character that may activate this transition.
Returns:
true if the given character would activate the transition, false otherwise.

getChars

public char[] getChars()
Returns characters that activate this transition.

Returns:
Characters that activate this transition.

getTargetState

public State getTargetState()
Returns the target state of this transition.

Returns:
The target state of this transition : the state that is reached if this transition is activated.

getSourceState

public State getSourceState()
Returns the source state of this transition.

Returns:
The source state of this transition : the state to which this transition has been added.

setTargetState

public void setTargetState(State state)
Sets the target state of this transition.

Parameters:
state - the target state of this transition.

isSelfTransition

public boolean isSelfTransition()
Returns true if this transition is a self transition. A transition is a self transition when its source state is equal to its target state.

Returns:
true if this transition is a self transition, false otherwise.

add

public void add(char[] characters)
Adds new characters to this transition to activate it.


intersect

public char[] intersect(char[] parameter)
Returns an array containing characters that are activating this transition and that are also contained in the given array. Characters activating this transition are left unchanged.

Parameters:
parameter - An array of char.
Returns:
An array containing characters that are activating this transition and that are also contained in the given array.

contains

public boolean contains(char[] characters)
Returns true if the given characters activate this transition.

Parameters:
characters - An array of char.
Returns:
true if the given characters activate this transition, false otherwise.

contains

public boolean contains(char character)
Returns true if the given character activate this transition.

Parameters:
character - A character.
Returns:
true if the given character activate this transition, false otherwise.

substract

public void substract(char[] characters)
Removes the given characters to the ones activating this transition.

Parameters:
characters - Characters to be removed from the ones activating this transition.

toString

public java.lang.String toString()