freemarker.template
Class LocalizedString

java.lang.Object
  extended by freemarker.template.LocalizedString
All Implemented Interfaces:
TemplateModel, TemplateScalarModel
Direct Known Subclasses:
ResourceBundleLocalizedString

public abstract class LocalizedString
extends java.lang.Object
implements TemplateScalarModel

An abstract base class for scalars that vary by locale. Here is a silly usage example. TemplateScalarModel localizedYes = new LocalizedString() { public String getLocalizedString(java.util.Locale locale) { String lang = locale.getLanguage(); if "fr".equals(lang) return "oui"; else if "de".equals(lang) return "sí"; else return "yes"; } };

Author:
Jonathan Revusky

Field Summary
 
Fields inherited from interface freemarker.template.TemplateScalarModel
EMPTY_STRING
 
Fields inherited from interface freemarker.template.TemplateModel
NOTHING
 
Constructor Summary
LocalizedString()
           
 
Method Summary
 java.lang.String getAsString()
          Returns the string representation of this model.
abstract  java.lang.String getLocalizedString(java.util.Locale locale)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalizedString

public LocalizedString()
Method Detail

getAsString

public java.lang.String getAsString()
                             throws TemplateModelException
Description copied from interface: TemplateScalarModel
Returns the string representation of this model. In general, avoid returning null. In compatibility mode the engine will convert null into empty string, however in normal mode it will throw an exception if you return null from this method.

Specified by:
getAsString in interface TemplateScalarModel
Throws:
TemplateModelException

getLocalizedString

public abstract java.lang.String getLocalizedString(java.util.Locale locale)
                                             throws TemplateModelException
Throws:
TemplateModelException