public class Transducer extends Visitor
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.| Modifier and Type | Field and Description |
|---|---|
protected Printer |
printer
The printer.
|
protected int |
varcount
The temporary variable count.
|
protected java.util.Map<java.lang.String,java.lang.String> |
variables
The mapping from pattern variable names to their types.
|
| Constructor and Description |
|---|
Transducer(Printer printer)
Create a new transducer.
|
Transducer(Printer printer,
java.util.Map<java.lang.String,java.lang.String> variables)
Create a new transducer.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getVariableName(Node n)
Get the pattern variable's name.
|
java.lang.String |
getVariableType(Node n)
Get the pattern variable's type.
|
boolean |
isListType(java.lang.String t)
Determine whether the specified type is a list type.
|
boolean |
isPatternVariable(Node n)
Determine whether the specified node represents a pattern variable.
|
void |
process(java.lang.String method,
Node n)
Process the specified node.
|
java.lang.String |
toLiteral(java.lang.Object o,
java.lang.String var)
Convert the specified object to a literal.
|
GNode |
toPatternVariable(Node n)
Ensure that the specified node is a well-formed pattern variable.
|
java.lang.String |
visit(GNode n)
Visit the specified generic node.
|
dispatch, equals, hashCode, iterate, map, mapInPlace, unableToVisit, visitprotected final Printer printer
protected final java.util.Map<java.lang.String,java.lang.String> variables
protected int varcount
public Transducer(Printer printer)
printer - The printer.public Transducer(Printer printer, java.util.Map<java.lang.String,java.lang.String> variables)
null) to indicate
that all tree nodes are literal, i.e., do not contain any "holes"
that are filled during creation.printer - The printer.variables - The mapping from node names representing pattern
variables to their values' types.public boolean isPatternVariable(Node n)
n - The node.true if it represents a pattern variable.public GNode toPatternVariable(Node n)
n - The node.java.lang.IllegalArgumentException - Signals that the specified node
is not a pattern variable or is a malformed pattern variable.public java.lang.String getVariableName(Node n)
n - The node.java.lang.IllegalArgumentException - Signals that the node does not
represent a pattern variable or is malformed.public java.lang.String getVariableType(Node n)
n - The node.java.lang.IllegalArgumentException - Signals that the node does not
represent a pattern variable or is malformed.public boolean isListType(java.lang.String t)
t - The type.true if the specified type is a list type.public java.lang.String toLiteral(java.lang.Object o,
java.lang.String var)
null and the object is a node, the
object must be a pattern variable.o - The object.var - The variable name for nodes that are not pattern
variables.java.lang.IllegalArgumentException - Signals that the specified object
is not recognized.public void process(java.lang.String method,
Node n)
method - The method name.n - The node.java.lang.IllegalArgumentException - Signals that the specified is
not a generic node or that it is a pattern variable.public java.lang.String visit(GNode n)
Copyright © 2014. All Rights Reserved.