freemarker.template
Class SimpleScalar

java.lang.Object
  extended by freemarker.template.SimpleScalar
All Implemented Interfaces:
TemplateModel, TemplateScalarModel, java.io.Serializable

public class SimpleScalar
extends java.lang.Object
implements TemplateScalarModel, java.io.Serializable

A synchronized implementation of the TemplateScalarModel interface, using a String or a boolean.

All the public methods in this implementation are synchronized.

Version:
$Id: SimpleScalar.java 1101 2013-04-01 04:17:32Z run2000 $
See Also:
SimpleNumber, SimpleList, SimpleHash, Serialized Form

Field Summary
protected  boolean booleanValue
          The value of this SimpleScalar if it wraps a boolean.
protected  java.lang.String stringValue
          The value of this SimpleScalar if it wraps a String.
 
Constructor Summary
SimpleScalar()
          Constructs an empty SimpleScalar.
SimpleScalar(boolean value)
          Constructs a SimpleScalar containing a boolean value.
SimpleScalar(java.lang.String value)
          Constructs a SimpleScalar containing a string value.
 
Method Summary
 boolean equals(java.lang.Object o)
          Tests this object for equality with the given object.
 java.lang.String getAsString()
          Returns the scalar's value as a String.
 int hashCode()
          Return the hash value for this object.
 boolean isEmpty()
          Is this SimpleScalar empty?
 void setValue(boolean value)
          Sets the boolean value of this SimpleScalar.
 void setValue(java.lang.String value)
          Sets the String value of this SimpleScalar.
 java.lang.String toString()
          Retrieve the String value of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

stringValue

protected java.lang.String stringValue
The value of this SimpleScalar if it wraps a String.


booleanValue

protected boolean booleanValue
The value of this SimpleScalar if it wraps a boolean.

Constructor Detail

SimpleScalar

public SimpleScalar()
Constructs an empty SimpleScalar.


SimpleScalar

public SimpleScalar(java.lang.String value)
Constructs a SimpleScalar containing a string value.

Parameters:
value - the string value.

SimpleScalar

public SimpleScalar(boolean value)
Constructs a SimpleScalar containing a boolean value.

Parameters:
value - the boolean value.
Method Detail

isEmpty

public boolean isEmpty()
                throws TemplateModelException
Is this SimpleScalar empty?

Specified by:
isEmpty in interface TemplateModel
Returns:
true if this object is empty, otherwise false
Throws:
TemplateModelException

getAsString

public java.lang.String getAsString()
                             throws TemplateModelException
Returns the scalar's value as a String.

Specified by:
getAsString in interface TemplateScalarModel
Returns:
the String value of this scalar.
Throws:
TemplateModelException

setValue

public void setValue(java.lang.String value)
Sets the String value of this SimpleScalar.

Parameters:
value - the String value.

setValue

public void setValue(boolean value)
Sets the boolean value of this SimpleScalar.

Parameters:
value - the boolean value.

toString

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

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Tests this object for equality with the given object.

Overrides:
equals in class java.lang.Object
Parameters:
o - the object to be compared against
Returns:
true if the object is equal, otherwise false

hashCode

public int hashCode()
Return the hash value for this object.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code corresponding to the value of this SimpleScalar