net.sourceforge.chaperon.process
Class PatternAutomaton

java.lang.Object
  extended bynet.sourceforge.chaperon.process.PatternAutomaton
All Implemented Interfaces:
java.io.Serializable

public class PatternAutomaton
extends java.lang.Object
implements java.io.Serializable

This class represents automaton to recognized text pattern.

Version:
CVS $Id: PatternAutomaton.java,v 1.8 2004/01/08 11:30:52 benedikta Exp $
Author:
Stephan Michels
See Also:
Serialized Form

Field Summary
static int TYPE_BOL
          Begin of line
static int TYPE_EOL
          End of line
static int TYPE_EXMATCH
          If the characher shouldn't match
static int TYPE_GROUPEND
          End of group
static int TYPE_GROUPSTART
          Start of group
static int TYPE_MATCH
          If the character should match
static int TYPE_MATCHANY
          Match all characters
static int TYPE_NOMATCH
          A simple transition without matching
 
Constructor Summary
PatternAutomaton(int statecount)
          Create a new pattern automaton.
 
Method Summary
 void addTransition(int state, int nextstate)
          Add a state as destination to the transition.
 int getFinalState()
          Returns the index of the final state
 int getFirstState()
          Return the first state of the automaton.
 int getGroupCount()
          Return the count of groups.
 int getGroupIndex(int state)
          Return the index of a group for a transition.
 char getIntervalBegin(int state)
          Return the begin of the character interval.
 char getIntervalEnd(int state)
          Return the end of the character interval.
 int getStateCount()
          Returns the count of states
 int[] getTransitions(int state)
          Returns the destinations of the transition.
 int getType(int state)
          Return the type of transition.
 boolean isFinalState(int state)
          Test if the state is the final state
 void setFinalState(int finalstate)
          Set the final state.
 void setFirstState(int firststate)
          Set the first state of the automaton.
 void setGroupCount(int groupcount)
          Set the count of groups.
 void setGroupIndex(int state, int groupindex)
          Set the group index for a transition.
 void setInterval(int state, char begin, char end)
          Set the character interval, which the processor should matches against.
 void setTransitions(int state, int[] transitions)
          Set the destination states for a transition.
 void setType(int state, int type)
          Set the of of transition.
 java.lang.String toString()
          Return a string representation of the automaton.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_NOMATCH

public static final int TYPE_NOMATCH
A simple transition without matching

See Also:
Constant Field Values

TYPE_MATCH

public static final int TYPE_MATCH
If the character should match

See Also:
Constant Field Values

TYPE_EXMATCH

public static final int TYPE_EXMATCH
If the characher shouldn't match

See Also:
Constant Field Values

TYPE_MATCHANY

public static final int TYPE_MATCHANY
Match all characters

See Also:
Constant Field Values

TYPE_BOL

public static final int TYPE_BOL
Begin of line

See Also:
Constant Field Values

TYPE_EOL

public static final int TYPE_EOL
End of line

See Also:
Constant Field Values

TYPE_GROUPSTART

public static final int TYPE_GROUPSTART
Start of group

See Also:
Constant Field Values

TYPE_GROUPEND

public static final int TYPE_GROUPEND
End of group

See Also:
Constant Field Values
Constructor Detail

PatternAutomaton

public PatternAutomaton(int statecount)
Create a new pattern automaton.

Parameters:
statecount - Count of states.
Method Detail

setType

public void setType(int state,
                    int type)
Set the of of transition.

Parameters:
state - Index of state.
type - Type of transition.

getType

public int getType(int state)
Return the type of transition.

Parameters:
state - Index of state.
Returns:
Type of transition.

setInterval

public void setInterval(int state,
                        char begin,
                        char end)
Set the character interval, which the processor should matches against.

Parameters:
state - Index of state.
begin - Begin of the character interval.
end - End of the character interval.

getIntervalBegin

public char getIntervalBegin(int state)
Return the begin of the character interval.

Parameters:
state - Index of state.
Returns:
Begin of the character interval.

getIntervalEnd

public char getIntervalEnd(int state)
Return the end of the character interval.

Parameters:
state - Index of state.
Returns:
End of the character interval.

setGroupIndex

public void setGroupIndex(int state,
                          int groupindex)
Set the group index for a transition.

Parameters:
state - Index of state.
groupindex - Index of group.

getGroupIndex

public int getGroupIndex(int state)
Return the index of a group for a transition.

Parameters:
state - Index of state.
Returns:
Index of group.

setGroupCount

public void setGroupCount(int groupcount)
Set the count of groups.

Parameters:
groupcount - Count of groups.

getGroupCount

public int getGroupCount()
Return the count of groups.

Returns:
Count of groups.

setTransitions

public void setTransitions(int state,
                           int[] transitions)
Set the destination states for a transition.

Parameters:
state - Index of state.
transitions - Destination states.

getTransitions

public int[] getTransitions(int state)
Returns the destinations of the transition.

Parameters:
state - Index of the state
Returns:
Destinations of the transition.

addTransition

public void addTransition(int state,
                          int nextstate)
Add a state as destination to the transition.

Parameters:
state - Index of transition.
nextstate - Destination state.

setFirstState

public void setFirstState(int firststate)
Set the first state of the automaton.

Parameters:
firststate - First state of the automaton.

getFirstState

public int getFirstState()
Return the first state of the automaton.

Returns:
First state of the automaton.

setFinalState

public void setFinalState(int finalstate)
Set the final state. If the automaton reaches this state, the automate was successful

Parameters:
finalstate - Final state

getFinalState

public int getFinalState()
Returns the index of the final state

Returns:
Index of the final state

isFinalState

public boolean isFinalState(int state)
Test if the state is the final state

Parameters:
state - Index of the state
Returns:
True, if the state is the final state

getStateCount

public int getStateCount()
Returns the count of states

Returns:
Count of states

toString

public java.lang.String toString()
Return a string representation of the automaton.

Returns:
String representation of the automaton.


Copyright ? 2003 Chaperon project. All Rights Reserved.