org.szegedi.expose.model
Class StaticModel

java.lang.Object
  |
  +--org.szegedi.expose.model.StaticModel
All Implemented Interfaces:
freemarker.template.TemplateHashModel, freemarker.template.TemplateModel

public final class StaticModel
extends java.lang.Object
implements freemarker.template.TemplateHashModel

Wraps the static fields and methods of a class in a TemplateHashModel. Fields are wrapped using ReflectionUtilities.wrap(Object), and methods are wrapped into ReflectionMethodModel instances. Unfortunately, there is currently no support for bean property-style calls of static methods, as in ReflectionObjectModel.

Version:
1.0
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.
 freemarker.template.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
 

Method Detail

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 freemarker.template.TemplateModel get(java.lang.String key)
                                      throws freemarker.template.TemplateModelException
Returns the field or method named by the key parameter.
Specified by:
get in interface freemarker.template.TemplateHashModel

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 freemarker.template.TemplateModel