freemarker.template.expression
Class Identifier

java.lang.Object
  |
  +--freemarker.template.expression.Identifier
All Implemented Interfaces:
Expression, ExpressionElement, java.io.Serializable, Variable

public final class Identifier
extends java.lang.Object
implements Variable, java.io.Serializable

An identifer in a variable. Can be used stand-alone to represent a variable in the root model, or combined with the Dot operator to represent models contained within hash models.

Version:
$Id: Identifier.java,v 1.25 2003/11/27 11:36:45 run2000 Exp $
See Also:
Serialized Form

Method Summary
 boolean equals(java.lang.Object o)
          Tests the equality of two Identifiers.
 TemplateModel getAsTemplateModel(TemplateModelRoot modelRoot)
          Gets the identifier's referent in modelRoot.
static Identifier getInstance(java.lang.String name)
          Retrieve a canonical instance of the identifier for the given name.
 java.lang.String getName()
          Retrieve the name of the identifier.
 java.lang.String getName(TemplateModelRoot modelRoot)
          Retrieve the name of this Identifier.
 int getType()
          Determine the type of result that can be calculated by this expression.
 int hashCode()
          Returns a hash code value for the Identifier.
 boolean isComplete()
          Has the identifier's name been assigned?
 java.lang.String toString()
          Returns the name of the identifier as a String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static Identifier getInstance(java.lang.String name)
Retrieve a canonical instance of the identifier for the given name. A weak hash map is used as a backing store, so identifiers are unique only when garbage collection hasn't caused the map to be reclaimed.
Parameters:
name - the name of the identifier
Returns:
a new Identifier for the given name
Throws:
java.lang.IllegalArgumentException - Identifier name was null

getName

public java.lang.String getName()
Retrieve the name of the identifier.
Returns:
the name of the identifier

getName

public java.lang.String getName(TemplateModelRoot modelRoot)
Retrieve the name of this Identifier.
Specified by:
getName in interface Variable
Parameters:
modelRoot - the TemplateModelRoot used to evaluate the name of the identifier
Returns:
the name of the identifier

isComplete

public boolean isComplete()
Has the identifier's name been assigned?
Specified by:
isComplete in interface Expression
Returns:
true if the identifier is named, otherwise false

getType

public int getType()
Determine the type of result that can be calculated by this expression. This is in the form of an integer constant ored together from values in the ExpressionUtils class.
Specified by:
getType in interface Expression

getAsTemplateModel

public TemplateModel getAsTemplateModel(TemplateModelRoot modelRoot)
                                 throws TemplateException
Gets the identifier's referent in modelRoot.
Specified by:
getAsTemplateModel in interface Expression
Parameters:
modelRoot - the root node of the data model.
Returns:
the TemplateModel that the variable refers to.

toString

public java.lang.String toString()
Returns the name of the identifier as a String.
Overrides:
toString in class java.lang.Object
Returns:
the name of the identifier.

equals

public boolean equals(java.lang.Object o)
Tests the equality of two Identifiers.
Overrides:
equals in class java.lang.Object
Returns:
true if the identifiers are equal, otherwise false

hashCode

public int hashCode()
Returns a hash code value for the Identifier.
Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this Identifier.