freemarker.template
Class SimpleScalar

java.lang.Object
  |
  +--freemarker.template.SimpleScalar
All Implemented Interfaces:
java.io.Serializable, TemplateModel, TemplateScalarModel

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

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

All the public methods in this implementation are synchronized.

Version:
$Id: SimpleScalar.java,v 1.20 2003/11/27 07:07:09 run2000 Exp $
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

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.

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