Package net.emustudio.edigen.nodes
Class Rule
- java.lang.Object
-
- net.emustudio.edigen.nodes.TreeNode
-
- net.emustudio.edigen.nodes.Rule
-
public class Rule extends TreeNode
Instruction decoder rule node.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(Visitor visitor)Accepts the visitor.booleanequals(java.lang.Object o)java.lang.StringgetFieldName()Returns a field name of this rule (key).java.lang.StringgetFieldName(java.lang.String ruleName)Returns a field name which should be generated for this rule (key).java.lang.StringgetLabel()Returns a human-readable label of this rule - a name or a list of names separated by commas.java.lang.StringgetMethodName()Returns a name of the method which should be generated for this rule.java.util.List<java.lang.String>getNames()Returns a list of all names of this rule.java.lang.StringgetRootRuleName()Get root rule name (if this rule is root).inthashCode()booleanhasOnlyOneName()Returns true if this rule has only one name (not a list of names separated by commas).booleanisRoot()Determines if it is a root ruleRulesetRoot(boolean isRoot, java.lang.String rootRuleName)Sets if this rule is a root rule.TreeNodeshallowCopy()java.lang.StringtoString()Returns a string representation of the object containing a rule name.-
Methods inherited from class net.emustudio.edigen.nodes.TreeNode
acceptChildren, addChild, addChildren, addChildren, childCount, copy, dump, getChild, getChildren, getLine, getParent, remove, setLine
-
-
-
-
Method Detail
-
getNames
public java.util.List<java.lang.String> getNames()
Returns a list of all names of this rule.- Returns:
- the list of names
-
hasOnlyOneName
public boolean hasOnlyOneName()
Returns true if this rule has only one name (not a list of names separated by commas).- Returns:
- true if the rule has only one name, false otherwise
-
getMethodName
public java.lang.String getMethodName()
Returns a name of the method which should be generated for this rule.- Returns:
- the method name
-
getFieldName
public java.lang.String getFieldName(java.lang.String ruleName)
Returns a field name which should be generated for this rule (key).- Parameters:
ruleName- the particular rule name (one rule can have multiple names - keys)- Returns:
- the name of a constant for the given key
-
getFieldName
public java.lang.String getFieldName()
Returns a field name of this rule (key). If the rule has more names, return the key of the root rule name.- Returns:
- the name of a constant for the given key
-
getLabel
public java.lang.String getLabel()
Returns a human-readable label of this rule - a name or a list of names separated by commas.- Returns:
- the label
-
isRoot
public boolean isRoot()
Determines if it is a root rule- Returns:
- true if it is a root rule, false otherwise
-
getRootRuleName
public java.lang.String getRootRuleName()
Get root rule name (if this rule is root).- Returns:
- root rule name if this rule is root; null otherwise
-
setRoot
public Rule setRoot(boolean isRoot, java.lang.String rootRuleName)
Sets if this rule is a root rule.- Parameters:
isRoot- true if it is a root rule, false otherwiserootRuleName- root rule name used in root rules declaration- Returns:
- this
-
accept
public void accept(Visitor visitor) throws SemanticException
Accepts the visitor.- Overrides:
acceptin classTreeNode- Parameters:
visitor- the visitor object- Throws:
SemanticException- depends on the specific visitor
-
toString
public java.lang.String toString()
Returns a string representation of the object containing a rule name.- Overrides:
toStringin classjava.lang.Object- Returns:
- the string
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
shallowCopy
public TreeNode shallowCopy()
- Specified by:
shallowCopyin classTreeNode
-
-