|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object freemarker.ext.beans.ObjectModelBase freemarker.ext.beans.ResourceBundleModel
freemarker.ext.beans2
package
public final 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:
bundle.resourceKey
will retrieve the object from resource bundle
with key resourceKey
bundle("patternKey", arg1, arg2, arg3)
will retrieve the string
from resource bundle with key patternKey
, and will use it as a pattern
for MessageFormat with arguments arg1, arg2 and arg3
Field Summary |
---|
Fields inherited from class freemarker.ext.beans.ObjectModelBase |
---|
object |
Constructor Summary | |
---|---|
ResourceBundleModel(java.util.ResourceBundle bundle)
Deprecated. |
Method Summary | |
---|---|
TemplateModel |
exec(java.util.List<java.lang.String> arguments)
Deprecated. 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)
Deprecated. Provides direct access to caching format engine from code (instead of from script). |
TemplateModel |
get(java.lang.String key)
Deprecated. Retrieves the object with specified key from resource bundle, and returns it wrapped in an appropriate TemplateModel. |
java.util.ResourceBundle |
getBundle()
Deprecated. |
static ResourceBundleModel |
getInstance(java.util.ResourceBundle object)
Deprecated. Returns a model wrapping the specified resource bundle object. |
freemarker.ext.beans.ObjectModelBase.ModelType |
getType()
Deprecated. Returns the type of this object (which is TYPE_RESOURCE_BUNDLE) |
boolean |
isEmpty()
Deprecated. Returns true if this bundle contains no objects. |
Methods inherited from class freemarker.ext.beans.ObjectModelBase |
---|
getAsObject, getAsString, getInstance |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ResourceBundleModel(java.util.ResourceBundle bundle)
Method Detail |
---|
public static final ResourceBundleModel getInstance(java.util.ResourceBundle object)
WeakReference
objects. The caching can be turned
off by setting the expose.reflection.nocache system property to
true. In this case calling this method is equivalent to constructing a new model.
object
- the resource bundle to wrap into a model.
public freemarker.ext.beans.ObjectModelBase.ModelType getType()
getType
in class ObjectModelBase
public TemplateModel get(java.lang.String key) throws TemplateModelException
get
in interface TemplateHashModel
key
- the name by which the TemplateModel
is identified in the template.
TemplateModel
referred to by the key,
or null
if not found.
TemplateModelException
- there was a problem getting the value
for the given keypublic boolean isEmpty()
isEmpty
in interface TemplateModel
isEmpty
in class ObjectModelBase
true
if this object is empty, otherwise false
public TemplateModel exec(java.util.List<java.lang.String> arguments) throws TemplateModelException
exec
in interface TemplateMethodModel
arguments
- a List
of String
objects
containing the values of the arguments passed to the method.
TemplateModel
produced by the method, or null
.
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 |