public class TreeSchema
extends java.lang.Object
Constructor and Description |
---|
TreeSchema(java.lang.Character c)
Constructor that creates a new TreeSchema where the root node should be
named like c
|
Modifier and Type | Method and Description |
---|---|
void |
addSchema(java.lang.Character element,
java.lang.String expreg)
Adds an expreg for the character given.
|
void |
generateMinimalTrees(int max_cost,
boolean minimal)
Generates minimal trees
|
dk.brics.automaton.Automaton |
getAutomaton(char c)
Return the automaton corresponding to the tag c
|
int |
getMinimalTreeCost(java.lang.Character c)
Returns the cost of creation of the minimal tree for the given Header
|
java.util.ArrayList<Tree> |
getMinimalTrees(java.lang.Character c)
Returns an ArrayList containing every MinimalTree for the given Header
|
int |
getPossibleCostMinimalTree(char c)
Compute the cost of the minimal tree having the tag c as root.
|
char |
getRoot() |
boolean |
isDeepValid(Node node)
Checks if the Node is valid and if its children are also
It checks the current node using isValid |
boolean |
isValid(Node node)
Returns true if the Node is locally valid: it doesn't check the validity
of the children
If there isn't any expreg for the given Header, the node should be a leaf to be valid |
boolean |
isValid(Tree tree)
Checks if a Tree is valid by using isDeepValid on the root
|
java.lang.String |
toString() |
public TreeSchema(java.lang.Character c)
c
- Header of the rootpublic void addSchema(java.lang.Character element, java.lang.String expreg) throws addSchemaException, generatedSchemaException, badSchemaException
element
- Header of the elements that should satisfy the expregexpreg
- ExpReg of every elementaddSchemaException
- Throws this Exception if the TreeSchema contains already a
Schema for this headergeneratedSchemaException
- Throws this Exception the minimal trees of the TreeSchema
have already been calculatedbadSchemaException
- Throws this Exception if the Automaton given by the ExpReg
cannot be satisfiedpublic boolean isValid(Node node) throws onlyCharactersException
node
- Node that should be checkedonlyCharactersException
- Throws this Exception if the node hasn't a compatible Headerpublic boolean isDeepValid(Node node) throws onlyCharactersException
node
- Node to checkonlyCharactersException
- Throws this Exception if the Header of a node isn't
compatiblepublic boolean isValid(Tree tree) throws onlyCharactersException
tree
- Tree to checkonlyCharactersException
- Throws this Exception if there is a Node with an uncompatible
Headerpublic int getMinimalTreeCost(java.lang.Character c)
c
- Header of the minimal tree to calculatepublic java.util.ArrayList<Tree> getMinimalTrees(java.lang.Character c)
c
- Header of the root of the minimal treepublic void generateMinimalTrees(int max_cost, boolean minimal) throws generatedSchemaException, generationSchemaException, addNodeException, badAddressException, headerNodeException
max_cost
- Maximum cost of a minimal treegeneratedSchemaException
- Throws this Exception if the minimal trees have already been
generateedgenerationSchemaException
- Throws this Exception if there is an error while generatingaddNodeException
- Throws this Exception if there is an error while creating
nodesbadAddressException
- Throws this Exception if there is an error in the addressesheaderNodeException
- Throws this exception is the header of the new node is ""public java.lang.String toString()
toString
in class java.lang.Object
public char getRoot()
public dk.brics.automaton.Automaton getAutomaton(char c)
c
- public int getPossibleCostMinimalTree(char c)
c
-