freemarker.template
Class FastScalar

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

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

An unsynchronized, immutable variation of the SimpleScalar class. This avoids the need for synchronization, since we no longer have any situations where the underlying value changes. This means that FastScalar should be significantly faster in some cases.

Since:
1.7.5
Version:
$Id: FastScalar.java 1101 2013-04-01 04:17:32Z run2000 $
See Also:
FastBoolean, FastHash, FastList, FastNumber, Serialized Form

Constructor Summary
FastScalar(java.lang.String stringValue)
          Constructs an instance of this object with an initial 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 the scalar value empty?
 java.lang.String toString()
          Return the value of this object as a String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FastScalar

public FastScalar(java.lang.String stringValue)
Constructs an instance of this object with an initial value.

Parameters:
stringValue - the value to store
Method Detail

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

isEmpty

public boolean isEmpty()
                throws TemplateModelException
Is the scalar value empty?

Specified by:
isEmpty in interface TemplateModel
Returns:
true if this String is empty or null, otherwise false.
Throws:
TemplateModelException

toString

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

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 compare against
Returns:
true if the objects are 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 object's value