com.google.clearsilver.jsilver.compiler
Class VariableTranslator

java.lang.Object
  extended by com.google.clearsilver.jsilver.syntax.analysis.AnalysisAdapter
      extended by com.google.clearsilver.jsilver.syntax.analysis.DepthFirstAdapter
          extended by com.google.clearsilver.jsilver.compiler.VariableTranslator
All Implemented Interfaces:
Analysis, Switch

public class VariableTranslator
extends DepthFirstAdapter

Translates a variable name (e.g. search.results.3.title) into the Java code for use as a key in looking up a variable (e.g. "search.results.3.title"). While it is possible to reuse an instance of this class repeatedly, it is not thread safe or reentrant. Evaluating an expression such as: a.b[c.d] would require two instances.


Constructor Summary
VariableTranslator(ExpressionTranslator expressionTranslator)
           
 
Method Summary
 void caseADecNumberVariable(ADecNumberVariable node)
           
 void caseADescendVariable(ADescendVariable node)
           
 void caseAExpandVariable(AExpandVariable node)
           
 void caseAHexNumberVariable(AHexNumberVariable node)
           
 void caseANameVariable(ANameVariable node)
           
 JavaExpression translate(PVariable csVariable)
          See class description.
 
Methods inherited from class com.google.clearsilver.jsilver.syntax.analysis.DepthFirstAdapter
caseAAddExpression, caseAAltCommand, caseAAndExpression, caseAAutoescapeCommand, caseACallCommand, caseACommaExpression, caseACommentCommand, caseAContentTypeCommand, caseACsOpenPosition, caseADataCommand, caseADecimalExpression, caseADefCommand, caseADivideExpression, caseAEachCommand, caseAEqExpression, caseAEscapeCommand, caseAEvarCommand, caseAExistsExpression, caseAFunctionExpression, caseAGteExpression, caseAGtExpression, caseAHardIncludeCommand, caseAHardLincludeCommand, caseAHexExpression, caseAIfCommand, caseAIncludeCommand, caseAInlineCommand, caseALincludeCommand, caseALoopCommand, caseALoopIncCommand, caseALoopToCommand, caseALteExpression, caseALtExpression, caseALvarCommand, caseAModuloExpression, caseAMultipleCommand, caseAMultiplyExpression, caseANameCommand, caseANeExpression, caseANegativeExpression, caseANoopCommand, caseANoopExpression, caseANotExpression, caseANumericAddExpression, caseANumericEqExpression, caseANumericExpression, caseANumericNeExpression, caseAOrExpression, caseASequenceExpression, caseASetCommand, caseAStringExpression, caseASubtractExpression, caseAUvarCommand, caseAVarCommand, caseAVariableExpression, caseAWithCommand, caseStart, defaultIn, defaultOut, inAAddExpression, inAAltCommand, inAAndExpression, inAAutoescapeCommand, inACallCommand, inACommaExpression, inACommentCommand, inAContentTypeCommand, inACsOpenPosition, inADataCommand, inADecimalExpression, inADecNumberVariable, inADefCommand, inADescendVariable, inADivideExpression, inAEachCommand, inAEqExpression, inAEscapeCommand, inAEvarCommand, inAExistsExpression, inAExpandVariable, inAFunctionExpression, inAGteExpression, inAGtExpression, inAHardIncludeCommand, inAHardLincludeCommand, inAHexExpression, inAHexNumberVariable, inAIfCommand, inAIncludeCommand, inAInlineCommand, inALincludeCommand, inALoopCommand, inALoopIncCommand, inALoopToCommand, inALteExpression, inALtExpression, inALvarCommand, inAModuloExpression, inAMultipleCommand, inAMultiplyExpression, inANameCommand, inANameVariable, inANeExpression, inANegativeExpression, inANoopCommand, inANoopExpression, inANotExpression, inANumericAddExpression, inANumericEqExpression, inANumericExpression, inANumericNeExpression, inAOrExpression, inASequenceExpression, inASetCommand, inAStringExpression, inASubtractExpression, inAUvarCommand, inAVarCommand, inAVariableExpression, inAWithCommand, inStart, outAAddExpression, outAAltCommand, outAAndExpression, outAAutoescapeCommand, outACallCommand, outACommaExpression, outACommentCommand, outAContentTypeCommand, outACsOpenPosition, outADataCommand, outADecimalExpression, outADecNumberVariable, outADefCommand, outADescendVariable, outADivideExpression, outAEachCommand, outAEqExpression, outAEscapeCommand, outAEvarCommand, outAExistsExpression, outAExpandVariable, outAFunctionExpression, outAGteExpression, outAGtExpression, outAHardIncludeCommand, outAHardLincludeCommand, outAHexExpression, outAHexNumberVariable, outAIfCommand, outAIncludeCommand, outAInlineCommand, outALincludeCommand, outALoopCommand, outALoopIncCommand, outALoopToCommand, outALteExpression, outALtExpression, outALvarCommand, outAModuloExpression, outAMultipleCommand, outAMultiplyExpression, outANameCommand, outANameVariable, outANeExpression, outANegativeExpression, outANoopCommand, outANoopExpression, outANotExpression, outANumericAddExpression, outANumericEqExpression, outANumericExpression, outANumericNeExpression, outAOrExpression, outASequenceExpression, outASetCommand, outAStringExpression, outASubtractExpression, outAUvarCommand, outAVarCommand, outAVariableExpression, outAWithCommand, outStart
 
Methods inherited from class com.google.clearsilver.jsilver.syntax.analysis.AnalysisAdapter
caseEOF, caseTAlt, caseTAnd, caseTArgWhitespace, caseTAssignment, caseTAutoescape, caseTBang, caseTBracketClose, caseTBracketOpen, caseTCall, caseTComma, caseTCommandDelimiter, caseTComment, caseTCommentStart, caseTContentType, caseTCsClose, caseTCsOpen, caseTData, caseTDecNumber, caseTDef, caseTDollar, caseTDot, caseTEach, caseTElse, caseTElseIf, caseTEq, caseTEscape, caseTEvar, caseTGt, caseTGte, caseTHardDelimiter, caseTHash, caseTHexNumber, caseTIf, caseTInclude, caseTInline, caseTLinclude, caseTLoop, caseTLt, caseTLte, caseTLvar, caseTMinus, caseTName, caseTNe, caseTOr, caseTParenClose, caseTParenOpen, caseTPercent, caseTPlus, caseTQuestion, caseTSet, caseTSlash, caseTStar, caseTString, caseTUvar, caseTVar, caseTWith, caseTWord, defaultCase, getIn, getOut, setIn, setOut
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VariableTranslator

public VariableTranslator(ExpressionTranslator expressionTranslator)
Method Detail

translate

public JavaExpression translate(PVariable csVariable)
See class description.

Parameters:
csVariable - Variable node in template's AST.
Returns:
Appropriate code (as JavaExpression).

caseANameVariable

public void caseANameVariable(ANameVariable node)
Specified by:
caseANameVariable in interface Analysis
Overrides:
caseANameVariable in class DepthFirstAdapter

caseADecNumberVariable

public void caseADecNumberVariable(ADecNumberVariable node)
Specified by:
caseADecNumberVariable in interface Analysis
Overrides:
caseADecNumberVariable in class DepthFirstAdapter

caseAHexNumberVariable

public void caseAHexNumberVariable(AHexNumberVariable node)
Specified by:
caseAHexNumberVariable in interface Analysis
Overrides:
caseAHexNumberVariable in class DepthFirstAdapter

caseADescendVariable

public void caseADescendVariable(ADescendVariable node)
Specified by:
caseADescendVariable in interface Analysis
Overrides:
caseADescendVariable in class DepthFirstAdapter

caseAExpandVariable

public void caseAExpandVariable(AExpandVariable node)
Specified by:
caseAExpandVariable in interface Analysis
Overrides:
caseAExpandVariable in class DepthFirstAdapter


Copyright © 2010-2012 Google. All Rights Reserved.