org.apache.velocity.runtime.parser.node

Class ASTReference

public class ASTReference extends SimpleNode

This class is responsible for handling the references in VTL ($foo). Please look at the Parser.jjt file which is what controls the generation of this class.

Version: $Id: ASTReference.java,v 1.49.4.1 2004/03/03 23:22:59 geirm Exp $

Author: Jason van Zyl Geir Magnusson Jr. Christoph Reck Field Summary booleancomputableReference

booleanescaped
StringescPrefix
static intFORMAL_REFERENCE
Stringidentifier
Stringliteral
StringmorePrefix
StringnullString
intnumChildren
static intNORMAL_REFERENCE
static intQUIET_REFERENCE
intreferenceType
StringrootString
static intRUNT
protected InfouberInfo
Constructor Summary
ASTReference(int id)
ASTReference(Parser p, int id)
Method Summary
booleanevaluate(InternalContextAdapter context)
Computes boolean value of this reference Returns the actual value of reference return type boolean, and 'true' if value is not null
Objectexecute(Object o, InternalContextAdapter context)
gets an Object that 'is' the value of the reference
StringgetRoot()
StringgetRootString()
Returns the 'root string', the reference key
ObjectgetVariableValue(Context context, String variable)
Objectinit(InternalContextAdapter context, Object data)
ObjectjjtAccept(ParserVisitor visitor, Object data)
Accept the visitor.
Stringliteral()
Override of the SimpleNode method literal() Returns the literal representation of the node.
booleanrender(InternalContextAdapter context, Writer writer)
gets the value of the reference and outputs it to the writer.
voidsetLiteral(String literal)
Routine to allow the literal representation to be externally overridden.
booleansetValue(InternalContextAdapter context, Object value)
Sets the value of a complex reference (something like $foo.bar) Currently used by ASTSetReference()
Objectvalue(InternalContextAdapter context)

Field Detail

computableReference

private boolean computableReference

escaped

private boolean escaped

escPrefix

private String escPrefix

FORMAL_REFERENCE

private static final int FORMAL_REFERENCE

identifier

private String identifier

literal

private String literal

morePrefix

private String morePrefix

nullString

private String nullString

numChildren

private int numChildren

NORMAL_REFERENCE

private static final int NORMAL_REFERENCE

QUIET_REFERENCE

private static final int QUIET_REFERENCE

referenceType

private int referenceType

rootString

private String rootString

RUNT

private static final int RUNT

uberInfo

protected Info uberInfo

Constructor Detail

ASTReference

public ASTReference(int id)

ASTReference

public ASTReference(Parser p, int id)

Method Detail

evaluate

public boolean evaluate(InternalContextAdapter context)
Computes boolean value of this reference Returns the actual value of reference return type boolean, and 'true' if value is not null

Parameters: context context to compute value with

execute

public Object execute(Object o, InternalContextAdapter context)
gets an Object that 'is' the value of the reference

Parameters: o unused Object parameter context context used to generate value

getRoot

private String getRoot()

getRootString

public String getRootString()
Returns the 'root string', the reference key

getVariableValue

public Object getVariableValue(Context context, String variable)

init

public Object init(InternalContextAdapter context, Object data)

jjtAccept

public Object jjtAccept(ParserVisitor visitor, Object data)
Accept the visitor. *

literal

public String literal()
Override of the SimpleNode method literal() Returns the literal representation of the node. Should be something like $.

render

public boolean render(InternalContextAdapter context, Writer writer)
gets the value of the reference and outputs it to the writer.

Parameters: context context of data to use in getting value writer writer to render to

setLiteral

public void setLiteral(String literal)
Routine to allow the literal representation to be externally overridden. Used now in the VM system to override a reference in a VM tree with the literal of the calling arg to make it work nicely when calling arg is null. It seems a bit much, but does keep things consistant. Note, you can only set the literal once...

Parameters: literal String to render to when null

setValue

public boolean setValue(InternalContextAdapter context, Object value)
Sets the value of a complex reference (something like $foo.bar) Currently used by ASTSetReference()

Parameters: context context object containing this reference value Object to set as value

Returns: true if successful, false otherwise

See Also:

value

public Object value(InternalContextAdapter context)
Copyright B) 2002 Apache Software Foundation. All Rights Reserved.