org.apache.commons.jelly.tags.fmt
Class SetLocaleTag

java.lang.Object
  extended byorg.apache.commons.jelly.TagSupport
      extended byorg.apache.commons.jelly.tags.fmt.SetLocaleTag
All Implemented Interfaces:
org.apache.commons.jelly.Tag

public class SetLocaleTag
extends org.apache.commons.jelly.TagSupport

Support for tag handlers for <setLocale>, the locale setting tag in JSTL.

Version:
1.2
Author:
Willie Vu

Field Summary
private static char HYPHEN
           
private  java.lang.String scope
           
private static char UNDERSCORE
           
private  org.apache.commons.jelly.expression.Expression value
           
private  org.apache.commons.jelly.expression.Expression variant
           
 
Fields inherited from class org.apache.commons.jelly.TagSupport
body, context, hasTrimmed, parent, shouldTrim
 
Constructor Summary
SetLocaleTag()
          Creates a new instance of SetLocaleTag
 
Method Summary
 void doTag(org.apache.commons.jelly.XMLOutput output)
          Evaluates this tag after all the tags properties have been initialized.
private static java.util.Locale findFormattingMatch(java.util.Locale pref, java.util.Locale[] avail)
           
(package private) static java.util.Locale getFormattingLocale(org.apache.commons.jelly.JellyContext jc, org.apache.commons.jelly.Tag fromTag, boolean format, java.util.Locale[] avail)
           
(package private) static java.util.Locale getLocale(org.apache.commons.jelly.JellyContext jc, java.lang.String name)
          Returns the locale specified by the named scoped attribute or context configuration parameter.
static java.util.Locale parseLocale(java.lang.String locale)
          See parseLocale(String, String) for details.
static java.util.Locale parseLocale(java.lang.String locale, java.lang.String variant)
          Parses the given locale string into its language and (optionally) country components, and returns the corresponding java.util.Locale object.
 void setScope(java.lang.String scope)
           
 void setValue(org.apache.commons.jelly.expression.Expression value)
           
 void setVariant(org.apache.commons.jelly.expression.Expression variant)
           
 
Methods inherited from class org.apache.commons.jelly.TagSupport
findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, getBody, getBodyText, getBodyText, getContext, getParent, invokeBody, isEscapeText, isTrim, setBody, setContext, setEscapeText, setParent, setTrim, trimBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HYPHEN

private static final char HYPHEN
See Also:
Constant Field Values

UNDERSCORE

private static final char UNDERSCORE
See Also:
Constant Field Values

value

private org.apache.commons.jelly.expression.Expression value

variant

private org.apache.commons.jelly.expression.Expression variant

scope

private java.lang.String scope
Constructor Detail

SetLocaleTag

public SetLocaleTag()
Creates a new instance of SetLocaleTag

Method Detail

doTag

public void doTag(org.apache.commons.jelly.XMLOutput output)
           throws org.apache.commons.jelly.JellyTagException
Evaluates this tag after all the tags properties have been initialized.

Throws:
org.apache.commons.jelly.JellyTagException

setValue

public void setValue(org.apache.commons.jelly.expression.Expression value)

setVariant

public void setVariant(org.apache.commons.jelly.expression.Expression variant)

setScope

public void setScope(java.lang.String scope)

parseLocale

public static java.util.Locale parseLocale(java.lang.String locale)
See parseLocale(String, String) for details.


parseLocale

public static java.util.Locale parseLocale(java.lang.String locale,
                                           java.lang.String variant)
Parses the given locale string into its language and (optionally) country components, and returns the corresponding java.util.Locale object. If the given locale string is null or empty, the runtime's default locale is returned.

Parameters:
locale - the locale string to parse
variant - the variant
Returns:
java.util.Locale object corresponding to the given locale string, or the runtime's default locale if the locale string is null or empty
Throws:
java.lang.IllegalArgumentException - if the given locale does not have a language component or has an empty country component

getLocale

static java.util.Locale getLocale(org.apache.commons.jelly.JellyContext jc,
                                  java.lang.String name)
Returns the locale specified by the named scoped attribute or context configuration parameter.

The named scoped attribute is searched in the page, request, session (if valid), and application scope(s) (in this order). If no such attribute exists in any of the scopes, the locale is taken from the named context configuration parameter.

Parameters:
jc - the page in which to search for the named scoped attribute or context configuration parameter
name - the name of the scoped attribute or context configuration parameter
Returns:
the locale specified by the named scoped attribute or context configuration parameter, or null if no scoped attribute or configuration parameter with the given name exists

getFormattingLocale

static java.util.Locale getFormattingLocale(org.apache.commons.jelly.JellyContext jc,
                                            org.apache.commons.jelly.Tag fromTag,
                                            boolean format,
                                            java.util.Locale[] avail)

findFormattingMatch

private static java.util.Locale findFormattingMatch(java.util.Locale pref,
                                                    java.util.Locale[] avail)