Class ASTStringLiteral
- java.lang.Object
-
- org.apache.velocity.runtime.parser.node.SimpleNode
-
- org.apache.velocity.runtime.parser.node.ASTStringLiteral
-
- All Implemented Interfaces:
Node
,Renderable
public class ASTStringLiteral extends SimpleNode
ASTStringLiteral support. Will interpolate!- Version:
- $Id$
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
image
private boolean
interpolate
private SimpleNode
nodeTree
-
Constructor Summary
Constructors Constructor Description ASTStringLiteral(int id)
ASTStringLiteral(Parser p, int id)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
adjTokenLineNums(Node node)
Adjust all the line and column numbers that comprise a node so that they are corrected for the string literals position within the template file.boolean
evaluate(InternalContextAdapter context)
java.lang.Object
init(InternalContextAdapter context, java.lang.Object data)
init : we don't have to do much.boolean
isConstant()
Check to see if this is an interpolated string.java.lang.Object
jjtAccept(ParserVisitor visitor, java.lang.Object data)
private java.lang.String
replaceQuotes(java.lang.String s, char literalQuoteChar)
Replaces double double-quotes with a single double quote ("" to ").static java.lang.String
unescape(java.lang.String string)
java.lang.Object
value(InternalContextAdapter context)
renders the value of the string literal If the properties allow, and the string literal contains a $ or a # the literal is rendered against the context Otherwise, the stringlit is returned.-
Methods inherited from class org.apache.velocity.runtime.parser.node.SimpleNode
childrenAccept, cleanupParserAndTokens, dump, dump, dump, execute, getColumn, getFirstToken, getFirstTokenImage, getInfo, getLastToken, getLastTokenImage, getLine, getLocation, getParser, getRuntimeServices, getTemplate, getTemplateName, getType, isInvalid, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent, literal, render, saveTokenImages, setFirstToken, setInfo, setInvalid, toString, toString
-
-
-
-
Field Detail
-
interpolate
private boolean interpolate
-
nodeTree
private SimpleNode nodeTree
-
image
private java.lang.String image
-
-
Constructor Detail
-
ASTStringLiteral
public ASTStringLiteral(int id)
- Parameters:
id
-
-
ASTStringLiteral
public ASTStringLiteral(Parser p, int id)
- Parameters:
p
-id
-
-
-
Method Detail
-
init
public java.lang.Object init(InternalContextAdapter context, java.lang.Object data) throws TemplateInitException
init : we don't have to do much. Init the tree (there shouldn't be one) and then see if interpolation is turned on.- Specified by:
init
in interfaceNode
- Overrides:
init
in classSimpleNode
- Parameters:
context
-data
-- Returns:
- Init result.
- Throws:
TemplateInitException
- See Also:
Node.init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
-
adjTokenLineNums
public void adjTokenLineNums(Node node)
Adjust all the line and column numbers that comprise a node so that they are corrected for the string literals position within the template file. This is necessary if an exception is thrown while processing the node so that the line and column position reported reflects the error position within the template and not just relative to the error position within the string literal.- Parameters:
node
-
-
replaceQuotes
private java.lang.String replaceQuotes(java.lang.String s, char literalQuoteChar)
Replaces double double-quotes with a single double quote ("" to "). Replaces double single quotes with a single quote ('' to ').- Parameters:
s
- StringLiteral without the surrounding quotesliteralQuoteChar
- char that starts the StringLiteral (" or ')
-
unescape
public static java.lang.String unescape(java.lang.String string)
- Parameters:
string
-- Returns:
- unescaped string
- Since:
- 1.6
-
jjtAccept
public java.lang.Object jjtAccept(ParserVisitor visitor, java.lang.Object data)
- Specified by:
jjtAccept
in interfaceNode
- Overrides:
jjtAccept
in classSimpleNode
- Parameters:
visitor
-data
-- Returns:
- rendered object
- See Also:
SimpleNode.jjtAccept(org.apache.velocity.runtime.parser.node.ParserVisitor, java.lang.Object)
-
isConstant
public boolean isConstant()
Check to see if this is an interpolated string.- Returns:
- true if this is constant (not an interpolated string)
- Since:
- 1.6
-
value
public java.lang.Object value(InternalContextAdapter context)
renders the value of the string literal If the properties allow, and the string literal contains a $ or a # the literal is rendered against the context Otherwise, the stringlit is returned.- Specified by:
value
in interfaceNode
- Overrides:
value
in classSimpleNode
- Parameters:
context
-- Returns:
- result of the rendering.
- See Also:
Node.value(org.apache.velocity.context.InternalContextAdapter)
-
evaluate
public boolean evaluate(InternalContextAdapter context)
- Specified by:
evaluate
in interfaceNode
- Overrides:
evaluate
in classSimpleNode
- Returns:
- The evaluation result.
- See Also:
SimpleNode.evaluate(org.apache.velocity.context.InternalContextAdapter)
-
-