QJCC homepage

biz.chitec.quarterback.util
Class LocaleConverter

java.lang.Object
  extended bybiz.chitec.quarterback.util.LocaleConverter

public class LocaleConverter
extends java.lang.Object

Converts a Locale into a String representation and vice versa

Version:
$Id: 5bfd23870d1d6181ed794157128efdb7135869f2 $
Author:
cantamen/Dirk Hillbrecht 2004

Field Summary
private static java.util.regex.Pattern localepattern
           
 
Constructor Summary
LocaleConverter()
           
 
Method Summary
static boolean isValidLocale(java.lang.String s)
          Returns whether the given String is a valid locale representation.
static java.lang.String localeToString(java.util.Locale lo)
          Converts a given locale object into a string representation.
static java.util.Locale stringToLocale(java.lang.String s)
          Converts a given String into a locale object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

localepattern

private static final java.util.regex.Pattern localepattern
Constructor Detail

LocaleConverter

public LocaleConverter()
Method Detail

localeToString

public static java.lang.String localeToString(java.util.Locale lo)
Converts a given locale object into a string representation. The returned String representation is of the usual Java "xx_YY(_zz)" syntax.

Parameters:
lo - A locale object
Returns:
String representation of the given locale object

isValidLocale

public static boolean isValidLocale(java.lang.String s)
Returns whether the given String is a valid locale representation. Note that this method does only a syntax check: It looks whether the given String matches the "xx(_YY(_zz))" pattern. It does not test whether the given codes are valid ISO codes.

Parameters:
s - A string to check syntactically for correct locale representation.
Returns:
True if the String is syntactically correct, false if not.

stringToLocale

public static java.util.Locale stringToLocale(java.lang.String s)
Converts a given String into a locale object. The string is not checked for syntactical or semantical correctness. As long as the Locale constructor accepts the data, it can be stored.

Parameters:
s - String (hopefully) representing a locale
Returns:
Locale object

QJCC homepage