Home » freemarker-2.3.13 » freemarker.ext.beans » [javadoc | source]
freemarker.ext.beans
public class: ResourceBundleModel [javadoc | source]
java.lang.Object
   freemarker.ext.beans.BeanModel
      freemarker.ext.beans.ResourceBundleModel

All Implemented Interfaces:
    TemplateMethodModelEx, AdapterTemplateModel, WrapperTemplateModel, TemplateHashModelEx

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
static final  ModelFactory FACTORY     
Fields inherited from freemarker.ext.beans.BeanModel:
object,  wrapper,  FACTORY
Constructor:
 public ResourceBundleModel(ResourceBundle bundle,
    BeansWrapper wrapper) 
Method from freemarker.ext.beans.ResourceBundleModel Summary:
exec,   format,   getBundle,   invokeGenericGet,   isEmpty,   keySet,   size
Methods from freemarker.ext.beans.BeanModel:
get,   getAdaptedObject,   getWrappedObject,   hasPlainGetMethod,   invokeGenericGet,   isEmpty,   keySet,   keys,   size,   toString,   unwrap,   values,   wrap
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from freemarker.ext.beans.ResourceBundleModel Detail:
 public Object exec(List arguments) throws TemplateModelException 
    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.
 public String format(String key,
    Object[] params) throws MissingResourceException 
    Provides direct access to caching format engine from code (instead of from script).
 public ResourceBundle getBundle() 
 protected TemplateModel invokeGenericGet(Map keyMap,
    Class clazz,
    String key) throws TemplateModelException 
    Overridden to invoke the getObject method of the resource bundle.
 public boolean isEmpty() 
    Returns true if this bundle contains no objects.
 protected Set keySet() 
 public int size()