|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object freemarker.template.FastBoolean
public final class FastBoolean
An unsynchronised, immutable variation of the SimpleScalar
class to handle boolean values. This avoids the need for synchronization,
since we no longer have any situations where the underlying value changes.
This means that FastBoolean
should be significantly faster in
some cases.
As of 1.8, this class also implements the TemplateNumberModel
interface, in order to simplify casting of boolean literals to numbers.
Note:
Unlike the other Fast classes, FastBoolean
uses a factory method
to create instances. This can dramatically reduce the amount of garbage
generated by reusing the same objects when possible.
FastHash
,
FastList
,
FastScalar
,
FastNumber
,
Serialized FormField Summary | |
---|---|
static FastBoolean |
FALSE
Represents a false boolean expression. |
static FastBoolean |
TRUE
Represents a true boolean expression. |
Method Summary | |
---|---|
long |
getAsNumber()
Returns the boolean value as a long . |
java.lang.Object |
getAsObject()
Return the model as a Boolean object. |
java.lang.String |
getAsString()
Returns the boolean value as a String . |
static boolean |
getBoolean(java.lang.Object value)
Returns true if the passed object is the TRUE instance. |
static FastBoolean |
getInstance(boolean isTrue)
Factory method for retrieving instances of a FastBoolean . |
boolean |
isEmpty()
Is the model empty? |
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 |
---|
public static final FastBoolean TRUE
public static final FastBoolean FALSE
Method Detail |
---|
public java.lang.String getAsString() throws TemplateModelException
String
.
getAsString
in interface TemplateScalarModel
String
value of this scalar.
TemplateModelException
public long getAsNumber() throws TemplateModelException
long
.
getAsNumber
in interface TemplateNumberModel
long
value of this scalar.
TemplateModelException
public boolean isEmpty() throws TemplateModelException
isEmpty
in interface TemplateModel
true
if this object is empty, otherwise false
TemplateModelException
public java.lang.Object getAsObject() throws TemplateModelException
getAsObject
in interface TemplateObjectModel
Boolean.TRUE
if this object is true, otherwise
Boolean.FALSE
TemplateModelException
- the object could not be returnedpublic static FastBoolean getInstance(boolean isTrue)
FastBoolean
.
isTrue
- true
if we want a True instance,
otherwise false
to retrieve a False instance
isTrue
is set, otherwise a False instancepublic static boolean getBoolean(java.lang.Object value)
value
- the value to compare against the TRUE instance
true
if this is the TRUE instance, otherwise false
public java.lang.String toString()
String
.
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |