Main Page | Packages | Class List | File List | Class Members

dfabuilder.State Class Reference

List of all members.

Detailed Description

This class represents a single state in a DFA. It also hold all the transition rules that lead out of the state as well as information on the type of the state and its label.

Author:
Iain Robinson
Version:
1.0


Public Member Functions

 State (String name)
 State (String name, int type)
void addRule (char character, State newState)
void addRule (TokenSet set, State newState)
Hashtable getRules ()
Vector getSets ()
TokenSet containsSymbolInSet (Character character)

Public Attributes

String returnValue
String returnType
int type
String name

Static Public Attributes

static final int NORMAL_STATE = 0
static final int GOAL_STATE = 1

Protected Member Functions

boolean compute (String sym)


Constructor & Destructor Documentation

dfabuilder.State.State String  name  ) 
 

Creates a new State object of a NORMAL_STATE type.

Parameters:
name The name to be givenm to the state being created.

dfabuilder.State.State String  name,
int  type
 

Creates a new State object of a specific type - NORMAL_STATE or GOAL_STATE.

Parameters:
name The name to be givenm to the state being created.
type The type of state to be created - use State.NORMAL_STATE or State.GOAL_STATE.


Member Function Documentation

void dfabuilder.State.addRule TokenSet  set,
State  newState
 

This method creates a new rule stating that "if any character in 'a' is encountered then move to state 's'".

Parameters:
set Array of characters triggering a transition to newState.
newState State to be moved to.

void dfabuilder.State.addRule char  character,
State  newState
 

This method creates a new rule stating that "if character 'c' is encountered then move to state 's'".

Parameters:
character character triggering a transition to newState.
newState State to be moved to.

boolean dfabuilder.State.compute String  sym  )  [protected]
 

This method works out if a given character triggers a move to another state from this one. If this is possible it initiates a recursive algorithm by calling the same method in the new state.

Parameters:
sym The string to be analysed.
Returns:
true if there is a transition triggered by the first character of string 'sym' - false if not. Because the method isrecursive the returned value indicates if the input string is valid according to the DFA.

TokenSet dfabuilder.State.containsSymbolInSet Character  character  ) 
 

Checks to see if the specified character is already contained within any TokenSet used by the state.

Parameters:
character The character to be searched for.
Returns:
True if the character is found in a TokenSet, false if not.

Hashtable dfabuilder.State.getRules  ) 
 

Returns a hashtable of all the transition rules for the state in the form Character->Next State.

Returns:
A Hashtable containing the transition rules of the state.

Vector dfabuilder.State.getSets  ) 
 

Returns a vector of all the token groups that trigger transitions from this state.

Returns:
A vector of TokenSets.


Member Data Documentation

final int dfabuilder.State.GOAL_STATE = 1 [static]
 

Constant indicating a goal type of state.

String dfabuilder.State.name
 

The name of the state. As a convention states in a DFA are labeled q0, q1... but this can be adjusted for any purpose.

final int dfabuilder.State.NORMAL_STATE = 0 [static]
 

Constant indicating a standard type of state.

String dfabuilder.State.returnType
 

The return type of the DFA. Can be an arbitrary string indicating the form of the data.

String dfabuilder.State.returnValue
 

If an input string matches the DFA this will hold the part of that string processed by the state.

int dfabuilder.State.type
 

The type of the state - can be GOAL_STATE or NORMAL_STATE.


Generated on Tue Feb 21 11:52:24 2006 for DFA Builder by  doxygen 1.4.1