ASTReference (Velocity 1.4 API)
Keywords: org.apache.velocity.runtime.parser.node.ASTReference class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.velocity.runtime.parser.node
Class ASTReference

    java.lang.Object
      org.apache.velocity.runtime.parser.node.SimpleNode
          org.apache.velocity.runtime.parser.node.ASTReference

All Implemented Interfaces:
  Node

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
  `private boolean` | `computableReference`
  `private boolean` | `escaped`
  `private java.lang.String` | `escPrefix`
  `private static int` | `FORMAL_REFERENCE`
  `private java.lang.String` | `identifier`
  `private java.lang.String` | `literal`
  `private java.lang.String` | `morePrefix`
  `private static int` | `NORMAL_REFERENCE`
  `private java.lang.String` | `nullString`
  `private int` | `numChildren`
  `private static int` | `QUIET_REFERENCE`
  `private int` | `referenceType`
  `private java.lang.String` | `rootString`
  `private static int` | `RUNT`
  `protected Info` | `uberInfo`

  Fields inherited from class org.apache.velocity.runtime.parser.node.SimpleNode
  `children, first, id, info, invalid, last, parent, parser, rsvc, state`

  Constructor Summary
  `ASTReference(int id)`
  `ASTReference(Parser p, int id)`

  Method Summary
  `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
  `java.lang.Object` | `execute(java.lang.Object o, InternalContextAdapter context)` gets an Object that 'is' the value of the reference
  `private java.lang.String` | `getRoot()`
  `java.lang.String` | `getRootString()` Returns the 'root string', the reference key
  `java.lang.Object` | `getVariableValue(Context context, java.lang.String variable)`
  `java.lang.Object` | `init(InternalContextAdapter context, java.lang.Object data)`
  `java.lang.Object` | `jjtAccept(ParserVisitor visitor, java.lang.Object data)` Accept the visitor.
  `java.lang.String` | `literal()` Override of the SimpleNode method literal() Returns the literal representation of the node.
  `boolean` | `render(InternalContextAdapter context, java.io.Writer writer)` gets the value of the reference and outputs it to the writer.
  `void` | `setLiteral(java.lang.String literal)` Routine to allow the literal representation to be externally overridden.
  `boolean` | `setValue(InternalContextAdapter context, java.lang.Object value)` Sets the value of a complex reference (something like $foo.bar) Currently used by ASTSetReference()
  `java.lang.Object` | `value(InternalContextAdapter context)`

  Methods inherited from class org.apache.velocity.runtime.parser.node.SimpleNode
  `childrenAccept, dump, getColumn, getFirstToken, getInfo, getLastToken, getLine, getType, isInvalid, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent, setFirstToken, setInfo, setInvalid, toString`

  Methods inherited from class java.lang.Object
  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  Field Detail

  ### NORMAL_REFERENCE

      private static final int NORMAL_REFERENCE

  See Also:
    Constant Field Values

  ### FORMAL_REFERENCE

      private static final int FORMAL_REFERENCE

  See Also:
    Constant Field Values

  ### QUIET_REFERENCE

      private static final int QUIET_REFERENCE

  See Also:
    Constant Field Values

  ### RUNT

      private static final int RUNT

  See Also:
    Constant Field Values

  ### referenceType

      private int referenceType

  ### nullString

      private java.lang.String nullString

  ### rootString

      private java.lang.String rootString

  ### escaped

      private boolean escaped

  ### computableReference

      private boolean computableReference

  ### escPrefix

      private java.lang.String escPrefix

  ### morePrefix

      private java.lang.String morePrefix

  ### identifier

      private java.lang.String identifier

  ### literal

      private java.lang.String literal

  ### numChildren

      private int numChildren

  ### uberInfo

      protected Info uberInfo

  Constructor Detail

  ### ASTReference

      public ASTReference(int id)

  ### ASTReference

      public ASTReference(Parser p,
                          int id)

  Method Detail

  ### jjtAccept

      public java.lang.Object jjtAccept(ParserVisitor visitor,
                                        java.lang.Object data)

    Accept the visitor.

    Specified by:
      `jjtAccept` in interface `Node`
    Overrides:
      `jjtAccept` in class `SimpleNode`

  ### init

      public java.lang.Object init(InternalContextAdapter context,
                                   java.lang.Object data)
                            throws java.lang.Exception

    Specified by:
      `init` in interface `Node`
    Overrides:
      `init` in class `SimpleNode`
    Throws:
      `java.lang.Exception`

  ### getRootString

      public java.lang.String getRootString()

    Returns the 'root string', the reference key

  ### execute

      public java.lang.Object execute(java.lang.Object o,
                                      InternalContextAdapter context)
                               throws MethodInvocationException

    gets an Object that 'is' the value of the reference

    Specified by:
      `execute` in interface `Node`
    Overrides:
      `execute` in class `SimpleNode`
    Parameters:
      `o` - unused Object parameter
      `context` - context used to generate value
    Throws:
      `MethodInvocationException`

  ### render

      public boolean render(InternalContextAdapter context,
                            java.io.Writer writer)
                     throws java.io.IOException,
                            MethodInvocationException

    gets the value of the reference and outputs it to the writer.

    Specified by:
      `render` in interface `Node`
    Overrides:
      `render` in class `SimpleNode`
    Parameters:
      `context` - context of data to use in getting value
      `writer` - writer to render to
    Throws:
      `java.io.IOException`
      `MethodInvocationException`

  ### evaluate

      public boolean evaluate(InternalContextAdapter context)
                       throws MethodInvocationException

    Computes boolean value of this reference Returns the actual value of reference return type boolean, and 'true' if value is not null

    Specified by:
      `evaluate` in interface `Node`
    Overrides:
      `evaluate` in class `SimpleNode`
    Parameters:
      `context` - context to compute value with
    Throws:
      `MethodInvocationException`

  ### value

      public java.lang.Object value(InternalContextAdapter context)
                             throws MethodInvocationException

    Specified by:
      `value` in interface `Node`
    Overrides:
      `value` in class `SimpleNode`
    Throws:
      `MethodInvocationException`

  ### setValue

      public boolean setValue(InternalContextAdapter context,
                              java.lang.Object value)
                       throws MethodInvocationException

    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
    Throws:
      `MethodInvocationException`
    See Also:
      `ASTSetDirective`

  ### getRoot

      private java.lang.String getRoot()

  ### getVariableValue

      public java.lang.Object getVariableValue(Context context,
                                               java.lang.String variable)

  ### setLiteral

      public void setLiteral(java.lang.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

  ### literal

      public java.lang.String literal()

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

    Specified by:
      `literal` in interface `Node`
    Overrides:
      `literal` in class `SimpleNode`

  Overview | Package | Class | Use | Tree | Deprecated | Index | Help
  PREV CLASS NEXT CLASS | FRAMES NO FRAMES
  SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

  Copyright © 2002 Apache Software Foundation. All Rights Reserved.