org.webmacro.servlet
Class LocaleTool
java.lang.Object
|
+--org.webmacro.servlet.LocaleTool
- All Implemented Interfaces:
- Bag, ContextTool
- public class LocaleTool
- extends java.lang.Object
- implements ContextTool, Bag
Provide Template with access to Locales. Also gives access to the static
fields e.g., Locale.US
Field Summary |
static java.lang.String |
RCS
|
Method Summary |
static java.util.Locale |
buildLocale(java.lang.String field)
access to the static members such as Locale.US, etc
If that field doesn't exist try to construct a locale
from a string so templates can have $Locale.en_GB. |
void |
destroy(java.lang.Object o)
At the end of processing this method will be called to
return the object generated by init(), in case it needs
to be recycled or otherwise cleaned up. |
java.lang.Object |
get(java.lang.String field)
access method used by $Locale.xxxxx => LocaleTool.get("xxxxx") |
java.util.Locale |
getDefault()
return the default locale for this JVM |
java.util.Locale |
getLocale(java.lang.String country)
wrappers around the 3 constructors for Locale |
java.util.Locale |
getLocale(java.lang.String country,
java.lang.String language)
|
java.util.Locale |
getLocale(java.lang.String country,
java.lang.String language,
java.lang.String variant)
|
java.lang.Object |
init(Context context)
A new tool object will be instantiated per-request by calling
this method. |
void |
put(java.lang.String key,
java.lang.Object value)
Unsupported |
void |
remove(java.lang.String key)
Unsupported |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RCS
public static final java.lang.String RCS
LocaleTool
public LocaleTool()
init
public java.lang.Object init(Context context)
throws PropertyException
- Description copied from interface:
ContextTool
- A new tool object will be instantiated per-request by calling
this method. A ContextTool is effectively a factory used to
create objects for use in templates. Some tools may simply return
themselves from this method; others may instantiate new objects
to hold the per-request state.
- Specified by:
init
in interface ContextTool
getDefault
public final java.util.Locale getDefault()
- return the default locale for this JVM
getLocale
public final java.util.Locale getLocale(java.lang.String country)
- wrappers around the 3 constructors for Locale
getLocale
public final java.util.Locale getLocale(java.lang.String country,
java.lang.String language)
getLocale
public final java.util.Locale getLocale(java.lang.String country,
java.lang.String language,
java.lang.String variant)
get
public final java.lang.Object get(java.lang.String field)
- access method used by $Locale.xxxxx => LocaleTool.get("xxxxx")
- Specified by:
get
in interface Bag
buildLocale
public static final java.util.Locale buildLocale(java.lang.String field)
- access to the static members such as Locale.US, etc
If that field doesn't exist try to construct a locale
from a string so templates can have $Locale.en_GB.
This may not be the right thing to do, though, in case of typos
e.g., $Locale.ENGLISH => Locale.ENGLISH
but $Locale.ENGLSH => Locale("ENGLSH","","")
Could argue that typos aren't caught in the latter anyway
(surprisingly?)
put
public final void put(java.lang.String key,
java.lang.Object value)
throws UnsettableException
- Unsupported
- Specified by:
put
in interface Bag
remove
public final void remove(java.lang.String key)
throws UnsettableException
- Unsupported
- Specified by:
remove
in interface Bag
destroy
public void destroy(java.lang.Object o)
- Description copied from interface:
ContextTool
- At the end of processing this method will be called to
return the object generated by init(), in case it needs
to be recycled or otherwise cleaned up.
- Specified by:
destroy
in interface ContextTool