dk.brics.automaton
Class CustomRunAutomaton

java.lang.Object
  extended by dk.brics.automaton.RunAutomaton
      extended by dk.brics.automaton.CustomRunAutomaton
All Implemented Interfaces:
java.io.Serializable

public class CustomRunAutomaton
extends dk.brics.automaton.RunAutomaton
implements java.io.Serializable

Finite-state automaton with fast run operation. This is a modified version of RunAutomaton from the BRICS automaton package. Modified such that regular expressions can be assigned IDs that are used to differentiate joined automatons.

Author:
Anders Møller <amoeller@brics.dk>, Martin Gerner;
See Also:
Serialized Form

Field Summary
static char delimiter
          This delimiter char is used to separate regular expressions from their IDs.
private static long serialVersionUID
           
 
Fields inherited from class dk.brics.automaton.RunAutomaton
accept, classmap, initial, points, size, transitions
 
Constructor Summary
CustomRunAutomaton(dk.brics.automaton.Automaton a, boolean tableize)
          Constructs a new RunAutomaton from a deterministic Automaton.
 
Method Summary
 java.util.ArrayList<java.lang.Character> getValidChars(int state)
           
 boolean isAcceptDelimited(int state, char delimiter)
           
static CustomRunAutomaton load(java.io.InputStream stream)
          Retrieves a serialized RunAutomaton from a stream.
static CustomRunAutomaton load(java.net.URL url)
          Retrieves a serialized RunAutomaton located by a URL.
 CustomAutomatonMatcher newCustomMatcher(java.lang.CharSequence s)
          Creates a new automaton matcher for the given input.
 CustomAutomatonMatcher newCustomMatcher(java.lang.CharSequence s, int startOffset, int endOffset)
          Creates a new automaton matcher for the given input.
 
Methods inherited from class dk.brics.automaton.RunAutomaton
getCharClass, getCharIntervals, getInitialState, getSize, isAccept, newMatcher, newMatcher, run, run, setAlphabet, step, store, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

delimiter

public static final char delimiter
This delimiter char is used to separate regular expressions from their IDs. A regular expression on the form something-delimiter-id will match "something", and will be returned together with the associated id.

See Also:
Constant Field Values
Constructor Detail

CustomRunAutomaton

public CustomRunAutomaton(dk.brics.automaton.Automaton a,
                          boolean tableize)
Constructs a new RunAutomaton from a deterministic Automaton. If the given automaton is not deterministic, it is determinized first.

Parameters:
a - an automaton
tableize - if true, a transition table is created which makes the run method faster in return of a higher memory usage
Method Detail

getValidChars

public java.util.ArrayList<java.lang.Character> getValidChars(int state)

load

public static CustomRunAutomaton load(java.net.URL url)
                               throws java.io.IOException,
                                      java.io.OptionalDataException,
                                      java.lang.ClassCastException,
                                      java.lang.ClassNotFoundException,
                                      java.io.InvalidClassException
Retrieves a serialized RunAutomaton located by a URL.

Parameters:
url - URL of serialized automaton
Throws:
java.io.IOException - if input/output related exception occurs
java.io.OptionalDataException - if the data is not a serialized object
java.io.InvalidClassException - if the class serial number does not match
java.lang.ClassCastException - if the data is not a serialized RunAutomaton
java.lang.ClassNotFoundException - if the class of the serialized object cannot be found

load

public static CustomRunAutomaton load(java.io.InputStream stream)
                               throws java.io.IOException,
                                      java.io.OptionalDataException,
                                      java.lang.ClassCastException,
                                      java.lang.ClassNotFoundException,
                                      java.io.InvalidClassException
Retrieves a serialized RunAutomaton from a stream.

Parameters:
stream - input stream with serialized automaton
Throws:
java.io.IOException - if input/output related exception occurs
java.io.OptionalDataException - if the data is not a serialized object
java.io.InvalidClassException - if the class serial number does not match
java.lang.ClassCastException - if the data is not a serialized RunAutomaton
java.lang.ClassNotFoundException - if the class of the serialized object cannot be found

newCustomMatcher

public CustomAutomatonMatcher newCustomMatcher(java.lang.CharSequence s)
Creates a new automaton matcher for the given input.

Parameters:
s - the CharSequence to search
Returns:
A new automaton matcher for the given input

newCustomMatcher

public CustomAutomatonMatcher newCustomMatcher(java.lang.CharSequence s,
                                               int startOffset,
                                               int endOffset)
Creates a new automaton matcher for the given input.

Parameters:
s - the CharSequence to search
startOffset - the starting offset of the given character sequence
endOffset - the ending offset of the given character sequence
Returns:
A new automaton matcher for the given input

isAcceptDelimited

public boolean isAcceptDelimited(int state,
                                 char delimiter)
Parameters:
state -
delimiter -
Returns:
whether a given state is an accept state, if delimiter is used to separate regular expressions and IDs