org.jaxen.function.ext
Class LocaleFunctionSupport

java.lang.Object
  |
  +--org.jaxen.function.ext.LocaleFunctionSupport
All Implemented Interfaces:
Function
Direct Known Subclasses:
LowerFunction, UpperFunction

public abstract class LocaleFunctionSupport
extends Object
implements Function

An abastract base class for Locale-specific extension functions. This class provides convenience methods that can be inherited, specifically to find a Locale from an XPath function argument value.

Author:
James Strachan

Constructor Summary
LocaleFunctionSupport()
           
 
Method Summary
protected  Locale findLocale(String localeText)
          Tries to find a Locale instance by name using xml:lang style encodings like 'en', 'en-US', 'en-US-Brooklyn'.
protected  Locale findLocaleForLanguage(String language)
          Finds the locale with the given language name with no country or variant, such as Locale.ENGLISH or Locale.FRENCH
protected  Locale getLocale(Object value, Navigator navigator)
          Attempts to convert the given function argument value into a Locale either via casting, extracting it from a List or looking up the named Locale using reflection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jaxen.Function
call
 

Constructor Detail

LocaleFunctionSupport

public LocaleFunctionSupport()
Method Detail

getLocale

protected Locale getLocale(Object value,
                           Navigator navigator)
Attempts to convert the given function argument value into a Locale either via casting, extracting it from a List or looking up the named Locale using reflection.
Parameters:
value - is either a Locale, a List containing a Locale or a String containing the name of a Locale as defined by the Locale static members.
Returns:
the Locale for the value or null if one could not be deduced

findLocale

protected Locale findLocale(String localeText)
Tries to find a Locale instance by name using xml:lang style encodings like 'en', 'en-US', 'en-US-Brooklyn'.
Parameters:
localeText - is the xml:lang encoding of a Locale
Returns:
the Locale for the given text or null if one could not be found

findLocaleForLanguage

protected Locale findLocaleForLanguage(String language)
Finds the locale with the given language name with no country or variant, such as Locale.ENGLISH or Locale.FRENCH
Parameters:
language - is the language code to look for
Returns:
the Locale for the given language or null if one could not be found


Copyright © 2002 bob mcwhirter & James Strachan. All Rights Reserved. Hosted by

SourceForge Logo