dk.brics.servletvalidator.grammar
Class Terminal

java.lang.Object
  extended by dk.brics.servletvalidator.grammar.Terminal
All Implemented Interfaces:
AlphabetSymbol, GrammarEntity

public final class Terminal
extends Object
implements AlphabetSymbol

A terminal symbol. A terminal symbol contains a string (typically of length 1 that it derives. It captures the type of the Σ set in the Grammar. A terminal can also be a range of characters in which case the range between min and max should not include >, < or /. In that case it could break the analysis. If the check parameter in the range constructor is set to true, this property will be cheked. The CharRangeSplitter can be used to break char ranges up into a number of char ranges to ensure this invariant. Terminals are immutable.


Constructor Summary
Terminal(char min, char max)
          Constructs a new Terminal by invoking Terminal(char, char, boolean) with (min, max, false)
Terminal(char min, char max, boolean check)
          Constructs a new Terminal.
Terminal(String symbol)
          Constructs a new Terminal with only 1 symbol, namely that given
Terminal(Terminal t)
          Clones the terminal t
 
Method Summary
 void accept(GrammarEntityVisitor visitor)
          Accepts the given grammar entity visitor in a visitor pattern
 boolean equals(Object o)
           
<T> T
getData()
           
 char getMax()
          Returns the maximum character of the terminal range
 char getMin()
          Returns the minimum character of the terminal range
 String getSymbol()
          Returns the symbol if the terminal only has 1 symbol, else return a textual representation of the range.
 int hashCode()
           
 boolean isEpsilon()
          Returns whether this terminal has the language ε.
 boolean isRange()
          Returns whether this terminal represents a range
<T> T
setData(T data)
           
 String toString()
          Returns the same as getSymbol()
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Terminal

public Terminal(char min,
                char max)
Constructs a new Terminal by invoking Terminal(char, char, boolean) with (min, max, false)


Terminal

public Terminal(char min,
                char max,
                boolean check)
Constructs a new Terminal. If min == max then this constructor will behave exactly like Terminal(String)

Parameters:
min - The minimum character in the range
max - The maximum character in the range
check - whether to check that the ranges do not contain <, > or "

Terminal

public Terminal(String symbol)
Constructs a new Terminal with only 1 symbol, namely that given

Parameters:
symbol - Symbol of the Terminal

Terminal

public Terminal(Terminal t)
Clones the terminal t

Parameters:
t -
Method Detail

accept

public void accept(GrammarEntityVisitor visitor)
Description copied from interface: GrammarEntity
Accepts the given grammar entity visitor in a visitor pattern

Specified by:
accept in interface GrammarEntity

equals

public boolean equals(Object o)
Overrides:
equals in class Object

getData

public <T> T getData()

getMax

public char getMax()
Returns the maximum character of the terminal range

Returns:
Maximum character

getMin

public char getMin()
Returns the minimum character of the terminal range

Returns:
Minimum character

getSymbol

public String getSymbol()
Returns the symbol if the terminal only has 1 symbol, else return a textual representation of the range.

Returns:
Terminal symbol

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isEpsilon

public boolean isEpsilon()
Returns whether this terminal has the language ε.

Returns:

isRange

public boolean isRange()
Returns whether this terminal represents a range

Returns:
true if the terminal is a range

setData

public <T> T setData(T data)

toString

public String toString()
Returns the same as getSymbol()

Overrides:
toString in class Object
Returns:
String representation


Copyright © 2008 Mathias Schwarz.