dk.brics.servletvalidator.grammar
Class NonTerminal

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

public class NonTerminal
extends Object
implements AlphabetSymbol

A Nonterminal in the grammar. It captures the type of the contents of the set V in the Grammar. Nonterminals are mutable but the set of productions can be iterated safely while adding and removing using the methods in this class. The list being iterated remains the same while the productions are updated. The set of productions is a set in the sense that the same production can only be in this set once. The productions are however note required immutable or to have a fixed hash code or equals result.


Constructor Summary
NonTerminal()
          Constructs a fresh non terminal
NonTerminal(NonTerminal n)
          Constructs a new nonterminal that will play the same role as n in the grammar, thus inheriting code locations and other meta information
 
Method Summary
 void accept(GrammarEntityVisitor visitor)
          Accepts the given grammar entity visitor in a visitor pattern
 void addAll(Collection<Production> productions)
          Adds all productions in the list to the set of productions in
 void addProduction(Production production)
          Adds a production to the set of productions.
 void ensureSet()
          Ensure that there are no duplicate productions in the set of productions.
 CodeLocation getLocation()
           
 List<Production> getProductions()
          Returns a list of all productions from this nonterminal.
 boolean isTaint()
           
 void removeProduction(Production production)
          Removes a production from the set of productions
 void setLocation(CodeLocation location)
           
 void setProductions(Collection<Production> productions)
          Sets the set of productions the the contents of the given collection
 void setTaint(boolean taint)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NonTerminal

public NonTerminal()
Constructs a fresh non terminal


NonTerminal

public NonTerminal(NonTerminal n)
Constructs a new nonterminal that will play the same role as n in the grammar, thus inheriting code locations and other meta information

Parameters:
n -
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

addAll

public void addAll(Collection<Production> productions)
Adds all productions in the list to the set of productions in

Parameters:
productions -

addProduction

public void addProduction(Production production)
Adds a production to the set of productions. If the production already belongs to another nonterminal, the production is cloned.

Parameters:
production -

ensureSet

public void ensureSet()
Ensure that there are no duplicate productions in the set of productions. Such duplicates may arise when the list of symbols in a production is changed.


getLocation

public CodeLocation getLocation()

getProductions

public List<Production> getProductions()
Returns a list of all productions from this nonterminal. This list is unmodifiable. Use the methods on NonTerminal to change the set of productions.

Returns:

isTaint

public boolean isTaint()

removeProduction

public void removeProduction(Production production)
Removes a production from the set of productions

Parameters:
production -

setLocation

public void setLocation(CodeLocation location)

setProductions

public void setProductions(Collection<Production> productions)
Sets the set of productions the the contents of the given collection

Parameters:
productions -

setTaint

public void setTaint(boolean taint)


Copyright © 2008 Mathias Schwarz.