freemarker.ext.beans
Class StaticModel
java.lang.Object
|
+--freemarker.ext.beans.StaticModel
- All Implemented Interfaces:
- TemplateHashModel, TemplateModel
- public final class StaticModel
- extends java.lang.Object
- implements TemplateHashModel
Wraps the static fields and methods of a class in a TemplateHashModel
.
Fields are wrapped using BeansWrapper.wrap(Object)
, and
methods are wrapped into MethodModel
instances.
Unfortunately, there is currently no support for bean property-style
calls of static methods, as in ObjectModel
.
- Version:
- $Id: StaticModel.java,v 1.4 2003/10/20 13:49:02 run2000 Exp $
- Author:
- Attila Szegedi, attila@szegedi.org
Method Summary |
static StaticModel |
create(java.lang.Class clazz)
Creates a model representing the static fields and
methods of the passed class. |
TemplateModel |
get(java.lang.String key)
Returns the field or method named by the key
parameter. |
boolean |
isEmpty()
Returns true if there is at least one public static
field or method in the underlying class. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
create
public static final StaticModel create(java.lang.Class clazz)
- Creates a model representing the static fields and
methods of the passed class. Models are cached, meaning
that calling create twice with a same class parameter
will yield the same object.
get
public TemplateModel get(java.lang.String key)
throws TemplateModelException
- Returns the field or method named by the
key
parameter.
- Specified by:
get
in interface TemplateHashModel
- Following copied from interface:
freemarker.template.TemplateHashModel
- Parameters:
key
- the name by which the TemplateModel
is identified in the template.- Returns:
- the
TemplateModel
referred to by the key,
or null
if not found.
isEmpty
public boolean isEmpty()
- Returns true if there is at least one public static
field or method in the underlying class.
- Specified by:
isEmpty
in interface TemplateModel
- Following copied from interface:
freemarker.template.TemplateModel
- Returns:
true
if this object is empty, otherwise false