|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfreemarker.ext.beans.BeanModel
freemarker.ext.beans.ResourceBundleModel
public class ResourceBundleModel
A hash model that wraps a resource bundle. Makes it convenient to store
localized content in the data model. It also acts as a method model that will
take a resource key and arbitrary number of arguments and will apply
MessageFormat
with arguments on the string represented by the key.
Typical usages:
Field Summary |
---|
Fields inherited from class freemarker.ext.beans.BeanModel |
---|
object, wrapper |
Fields inherited from interface freemarker.template.TemplateModel |
---|
NOTHING |
Constructor Summary | |
---|---|
ResourceBundleModel(java.util.ResourceBundle bundle,
BeansWrapper wrapper)
|
Method Summary | |
---|---|
java.lang.Object |
exec(java.util.List arguments)
Takes first argument as a resource key, looks up a string in resource bundle with this key, then applies a MessageFormat.format on the string with the rest of the arguments. |
java.lang.String |
format(java.lang.String key,
java.lang.Object[] params)
Provides direct access to caching format engine from code (instead of from script). |
java.util.ResourceBundle |
getBundle()
|
protected TemplateModel |
invokeGenericGet(java.util.Map keyMap,
java.lang.Class clazz,
java.lang.String key)
Overridden to invoke the getObject method of the resource bundle. |
boolean |
isEmpty()
Returns true if this bundle contains no objects. |
protected java.util.Set |
keySet()
Helper method to support TemplateHashModelEx. |
int |
size()
|
Methods inherited from class freemarker.ext.beans.BeanModel |
---|
get, getAdaptedObject, getWrappedObject, hasPlainGetMethod, keys, toString, unwrap, values, wrap |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ResourceBundleModel(java.util.ResourceBundle bundle, BeansWrapper wrapper)
Method Detail |
---|
protected TemplateModel invokeGenericGet(java.util.Map keyMap, java.lang.Class clazz, java.lang.String key) throws TemplateModelException
invokeGenericGet
in class BeanModel
TemplateModelException
public boolean isEmpty()
isEmpty
in interface TemplateHashModel
isEmpty
in class BeanModel
public int size()
size
in interface TemplateHashModelEx
size
in class BeanModel
protected java.util.Set keySet()
BeanModel
keySet
in class BeanModel
public java.lang.Object exec(java.util.List arguments) throws TemplateModelException
exec
in interface TemplateMethodModel
exec
in interface TemplateMethodModelEx
arguments
- a List of TemplateModel
objects
containing the values of the arguments passed to the method. If the
implementation wishes to operate on POJOs that might be underlying the
models, it can use the static utility methods in the DeepUnwrap
class to easily obtain them.
TemplateModel
, it will be automatically
wrapped using the environment
object wrapper
.
TemplateModelException
public java.lang.String format(java.lang.String key, java.lang.Object[] params) throws java.util.MissingResourceException
java.util.MissingResourceException
public java.util.ResourceBundle getBundle()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |