|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.velocity.tools.generic.NullTool
public class NullTool
Tool for working with null
in Velocity templates.
It provides a method to set a VTL reference back to null
.
Also provides methods to check if a VTL reference is null
or not.
NOTE: These examples assume you have placed an instance of the current context within itself as 'ctx'. And, of course, the NullTool is assumed to be available as 'null'.
Example uses: $foo -> bar $null.isNull($foo) -> false $null.isNotNull($foo) -> true $null.setNull($ctx, "foo") $foo -> $foo (null) $null.isNull($foo) -> true $null.isNotNull($foo) -> false $null.set($ctx, $foo, "hoge") $foo -> hoge $null.set($ctx, $foo, $null.null) $foo -> $foo (null)
This tool is entirely threadsafe, and has no instance members. It may be used in any scope (request, session, or application).
Constructor Summary | |
---|---|
NullTool()
Default constructor. |
Method Summary | |
---|---|
java.lang.Object |
getNull()
A convinient method which returns null . |
boolean |
isNotNull(java.lang.Object object)
Checks if a VTL reference is not null . |
boolean |
isNull(java.lang.Object object)
Checks if a VTL reference is null . |
void |
set(org.apache.velocity.context.Context context,
java.lang.String key,
java.lang.Object value)
Sets the given VTL reference to the given value. |
void |
setNull(org.apache.velocity.context.Context context,
java.lang.String key)
Sets the given VTL reference back to null . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NullTool()
Method Detail |
---|
public void setNull(org.apache.velocity.context.Context context, java.lang.String key)
null
.
context
- the current Contextkey
- the VTL reference to set back to null
.public void set(org.apache.velocity.context.Context context, java.lang.String key, java.lang.Object value)
null
,
the VTL reference is set to null
.
context
- the current Contextkey
- the VTL reference to set.value
- the value to set the VTL reference to.public boolean isNull(java.lang.Object object)
null
.
object
- the VTL reference to check.
true
if the VTL reference is null
,
false
if otherwise.public boolean isNotNull(java.lang.Object object)
null
.
object
- the VTL reference to check.
true
if the VTL reference is not null
,
false
if otherwise.public java.lang.Object getNull()
null
.
Actually, this tool will work the same without this method,
because Velocity treats non-existing methods as null. :)
null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |