freemarker.ext.beans
Class ResourceBundleModel

java.lang.Object
  extended by freemarker.ext.beans.ObjectModelBase
      extended by freemarker.ext.beans.ResourceBundleModel
All Implemented Interfaces:
TemplateHashModel, TemplateMethodModel, TemplateModel, TemplateObjectModel, TemplateScalarModel, java.io.Serializable

Deprecated. this class is deprecated in favour of the classes in the freemarker.ext.beans2 package

public final class ResourceBundleModel
extends ObjectModelBase
implements TemplateHashModel, TemplateMethodModel

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:

Version:
$Id: ResourceBundleModel.java 1101 2013-04-01 04:17:32Z run2000 $
Author:
Attila Szegedi, attila@szegedi.org
See Also:
Serialized Form

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

ResourceBundleModel

public ResourceBundleModel(java.util.ResourceBundle bundle)
Deprecated. 
Method Detail

getInstance

public static final ResourceBundleModel getInstance(java.util.ResourceBundle object)
Deprecated. 
Returns a model wrapping the specified resource bundle object. If there is already a cached model instance for this resource bundle, returns the cached model instance. Models are cached using 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.

Parameters:
object - the resource bundle to wrap into a model.
Returns:
the model for the resource bundle

getType

public freemarker.ext.beans.ObjectModelBase.ModelType getType()
Deprecated. 
Returns the type of this object (which is TYPE_RESOURCE_BUNDLE)

Overrides:
getType in class ObjectModelBase

get

public TemplateModel get(java.lang.String key)
                  throws TemplateModelException
Deprecated. 
Retrieves the object with specified key from resource bundle, and returns it wrapped in an appropriate TemplateModel.

Specified by:
get in interface 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.
Throws:
TemplateModelException - there was a problem getting the value for the given key

isEmpty

public boolean isEmpty()
Deprecated. 
Returns true if this bundle contains no objects.

Specified by:
isEmpty in interface TemplateModel
Overrides:
isEmpty in class ObjectModelBase
Returns:
true if this object is empty, otherwise false

exec

public TemplateModel exec(java.util.List<java.lang.String> arguments)
                   throws TemplateModelException
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. The created MessageFormats are cached for later reuse.

Specified by:
exec in interface TemplateMethodModel
Parameters:
arguments - a List of String objects containing the values of the arguments passed to the method.
Returns:
the TemplateModel produced by the method, or null.
Throws:
TemplateModelException

format

public java.lang.String format(java.lang.String key,
                               java.lang.Object[] params)
                        throws java.util.MissingResourceException
Deprecated. 
Provides direct access to caching format engine from code (instead of from script).

Throws:
java.util.MissingResourceException

getBundle

public java.util.ResourceBundle getBundle()
Deprecated.