| java.lang.Object xtc.tree.Visitor xtc.tree.Transducer
Transducer | public class Transducer extends Visitor (Code) | | Visitor to convert trees of generic nodes into methods that
programmatically create the trees. Trees may contain generic nodes
that represent pattern variables. During transduction, pattern
variable are replaced with method arguments of the same names. In
general, a variable represents a single child of a newly created
generic node. However, if the variable's type is
List<T> , all of the list's elements are directly
added as children to the newly created generic node. Any node
representing a pattern variable must have exactly one child that is
a string representing the variable's name.
author: Robert Grimm version: $Revision: 1.5 $ |
varcount | protected int varcount(Code) | | The temporary variable count.
|
variables | final protected Map<String, String> variables(Code) | | The mapping from pattern variable names to their types.
|
Transducer | public Transducer(Printer printer)(Code) | | Create a new transducer. The newly created transducer treats all
trees as literals, without pattern variables.
Parameters: printer - The printer. |
Transducer | public Transducer(Printer printer, Map<String, String> variables)(Code) | | Create a new transducer. The mapping from pattern variable names
to types may be empty (but not null ) to indicate
that all tree nodes are literal, i.e., do not contain any "holes"
that are filled during creation.
Parameters: printer - The printer. Parameters: variables - The mapping from node names representing patternvariables to their values' types. |
getVariableName | public String getVariableName(Node n)(Code) | | Get the pattern variable's name.
Parameters: n - The node. The corresponding variable name. throws: IllegalArgumentException - Signals that the node does notrepresent a pattern variable or is malformed. |
getVariableType | public String getVariableType(Node n)(Code) | | Get the pattern variable's type.
Parameters: n - The node. The corresponding variable type. throws: IllegalArgumentException - Signals that the node does notrepresent a pattern variable or is malformed. |
isListType | public boolean isListType(String t)(Code) | | Determine whether the specified type is a list type.
Parameters: t - The type. true if the specified type is a list type. |
isPatternVariable | public boolean isPatternVariable(Node n)(Code) | | Determine whether the specified node represents a pattern variable.
Parameters: n - The node. true if it represents a pattern variable. |
process | public void process(String method, Node n)(Code) | | Process the specified node.
Parameters: method - The method name. Parameters: n - The node. throws: IllegalArgumentException - Signals that the specified isnot a generic node or that it is a pattern variable. |
toLiteral | public String toLiteral(Object o, String var)(Code) | | Convert the specified object to a literal. If the specified
variable name is null and the object is a node, the
object must be a pattern variable.
Parameters: o - The object. Parameters: var - The variable name for nodes that are not patternvariables. The corresponding literal. throws: IllegalArgumentException - Signals that the specified objectis not recognized. |
toPatternVariable | public GNode toPatternVariable(Node n)(Code) | | Ensure that the specified node is a well-formed pattern variable.
Parameters: n - The node. The node as a pattern variable. throws: IllegalArgumentException - Signals that the specified nodeis not a pattern variable or is a malformed pattern variable. |
|
|