freemarker.template.expression
Class BooleanLiteral

java.lang.Object
  extended by freemarker.template.expression.BooleanLiteral
All Implemented Interfaces:
Expression, java.io.Serializable

public final class BooleanLiteral
extends java.lang.Object
implements Expression, java.io.Serializable

Represents a boolean literal in a FM-Classic template.

Since:
1.8
Version:
$Id: BooleanLiteral.java 1101 2013-04-01 04:17:32Z run2000 $
See Also:
Serialized Form

Field Summary
static BooleanLiteral FALSE
          The false instance of this class.
static BooleanLiteral TRUE
          The true instance of this class.
 
Method Summary
 TemplateModel getAsTemplateModel(TemplateWriteableHashModel modelRoot)
          Retrieve the value of this BooleanLiteral as a TemplateModel.
static BooleanLiteral getInstance(boolean isTrue)
          Factory method for retrieving instances of a BooleanLiteral.
 java.util.Set<ExpressionUtils.ExpressionType> getType()
          Determine the type of result that can be calculated by this expression.
 boolean isComplete()
          Does the BooleanLiteral have a value?
 boolean isConstant()
          Determine whether result calculated by this expression is a constant value.
 Expression resolveExpression()
          Resolves the current expression, possibly into a different expression object.
 java.lang.String toString()
          Retrieve the value of this object as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TRUE

public static final BooleanLiteral TRUE
The true instance of this class.


FALSE

public static final BooleanLiteral FALSE
The false instance of this class.

Method Detail

getAsTemplateModel

public TemplateModel getAsTemplateModel(TemplateWriteableHashModel modelRoot)
                                 throws TemplateException
Retrieve the value of this BooleanLiteral as a TemplateModel.

Specified by:
getAsTemplateModel in interface Expression
Parameters:
modelRoot - the template model that will be evaluated by the expression
Throws:
TemplateException - the expression could not be evaluated for some reason

isComplete

public boolean isComplete()
Does the BooleanLiteral have a value?

Specified by:
isComplete in interface Expression
Returns:
true if there is a value, otherwise false

getType

public java.util.Set<ExpressionUtils.ExpressionType> 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

isConstant

public boolean isConstant()
Determine whether result calculated by this expression is a constant value.

Specified by:
isConstant in interface Expression

getInstance

public static BooleanLiteral getInstance(boolean isTrue)
Factory method for retrieving instances of a BooleanLiteral.

Parameters:
isTrue - true if we want a True instance, otherwise false to retrieve a False instance
Returns:
a True instance if isTrue is set, otherwise a False instance

toString

public java.lang.String toString()
Retrieve the value of this object as a String.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of this expression

resolveExpression

public Expression resolveExpression()
Resolves the current expression, possibly into a different expression object. This is loosely equivalent to the serialization protocol's readResolve method. Situations where this may be used are:

Specified by:
resolveExpression in interface Expression