org.pentaho.platform.util.messages
Class LocaleHelper

java.lang.Object
  extended by org.pentaho.platform.util.messages.LocaleHelper

public class LocaleHelper
extends Object


Field Summary
static int FORMAT_FULL
           
static int FORMAT_IGNORE
           
static int FORMAT_LONG
           
static int FORMAT_MEDIUM
           
static int FORMAT_SHORT
           
static String LEFT_TO_RIGHT
           
static String UTF_8
           
 
Constructor Summary
LocaleHelper()
           
 
Method Summary
static String convertEncodedStringToSystemDefaultEncoding(String fromEncoding, String encodedStr)
          This method converts strings from a known encoding into a string encoded by the system default encoding.
static String convertISOStringToSystemDefaultEncoding(String isoString)
          This method is called to convert strings from ISO-8859-1 (post/get parameters for example) into the default system locale.
static String convertStringEncoding(String sourceString, String sourceEncoding, String targetEncoding)
          This method converts strings between various encodings.
static String getClosestLocale(String locale, String[] locales)
           
static NumberFormat getCurrencyFormat()
           
static DateFormat getDateFormat(int dateFormat, int timeFormat)
           
static Locale getDefaultLocale()
           
static DateFormat getFullDateFormat(boolean date, boolean time)
           
static Locale getLocale()
           
static Locale getLocaleOverride()
           
static DateFormat getLongDateFormat(boolean date, boolean time)
           
static DateFormat getMediumDateFormat(boolean date, boolean time)
           
static NumberFormat getNumberFormat()
           
static DateFormat getShortDateFormat(boolean date, boolean time)
           
static String getSystemEncoding()
           
static String getTextDirection()
           
static boolean isAscii(String aString)
           
static boolean isLatin1(String aString)
           
static String isoToUtf8(String isoString)
          This method converts an ISO-8859-1 encoded string to a UTF-8 encoded string.
static boolean isWithinCharset(String aString, String charsetTarget)
           
static void setDefaultLocale(Locale newLocale)
           
static void setLocale(Locale newLocale)
           
static void setLocaleOverride(Locale localeOverride)
           
static void setSystemEncoding(String encoding)
           
static void setTextDirection(String textDirection)
           
static String utf8ToIso(String utf8String)
          This method converts a UTF8-encoded string to ISO-8859-1
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORMAT_SHORT

public static final int FORMAT_SHORT
See Also:
Constant Field Values

FORMAT_MEDIUM

public static final int FORMAT_MEDIUM
See Also:
Constant Field Values

FORMAT_LONG

public static final int FORMAT_LONG
See Also:
Constant Field Values

FORMAT_FULL

public static final int FORMAT_FULL
See Also:
Constant Field Values

FORMAT_IGNORE

public static final int FORMAT_IGNORE
See Also:
Constant Field Values

UTF_8

public static final String UTF_8
See Also:
Constant Field Values

LEFT_TO_RIGHT

public static final String LEFT_TO_RIGHT
See Also:
Constant Field Values
Constructor Detail

LocaleHelper

public LocaleHelper()
Method Detail

setDefaultLocale

public static void setDefaultLocale(Locale newLocale)

getDefaultLocale

public static Locale getDefaultLocale()

setLocaleOverride

public static void setLocaleOverride(Locale localeOverride)

getLocaleOverride

public static Locale getLocaleOverride()

setLocale

public static void setLocale(Locale newLocale)

getLocale

public static Locale getLocale()

setSystemEncoding

public static void setSystemEncoding(String encoding)

setTextDirection

public static void setTextDirection(String textDirection)

getSystemEncoding

public static String getSystemEncoding()

getTextDirection

public static String getTextDirection()

convertISOStringToSystemDefaultEncoding

public static String convertISOStringToSystemDefaultEncoding(String isoString)
This method is called to convert strings from ISO-8859-1 (post/get parameters for example) into the default system locale.

Parameters:
isoString -
Returns:
Re-encoded string

convertEncodedStringToSystemDefaultEncoding

public static String convertEncodedStringToSystemDefaultEncoding(String fromEncoding,
                                                                 String encodedStr)
This method converts strings from a known encoding into a string encoded by the system default encoding.

Parameters:
fromEncoding -
encodedStr -
Returns:
Re-encoded string

isoToUtf8

public static String isoToUtf8(String isoString)
This method converts an ISO-8859-1 encoded string to a UTF-8 encoded string.

Parameters:
isoString -
Returns:
Re-encoded string

utf8ToIso

public static String utf8ToIso(String utf8String)
This method converts a UTF8-encoded string to ISO-8859-1

Parameters:
utf8String -
Returns:
Re-encoded string

convertStringEncoding

public static String convertStringEncoding(String sourceString,
                                           String sourceEncoding,
                                           String targetEncoding)
This method converts strings between various encodings.

Parameters:
sourceString -
sourceEncoding -
targetEncoding -
Returns:
Re-encoded string.

isAscii

public static boolean isAscii(String aString)
Parameters:
aString -
Returns:
true if the provided string is completely within the US-ASCII character set.

isLatin1

public static boolean isLatin1(String aString)
Parameters:
aString -
Returns:
true if the provided string is completely within the Latin-1 character set (ISO-8859-1).

isWithinCharset

public static boolean isWithinCharset(String aString,
                                      String charsetTarget)
Parameters:
aString -
charsetTarget -
Returns:
true if the provided string is completely within the target character set.

getDateFormat

public static DateFormat getDateFormat(int dateFormat,
                                       int timeFormat)

getShortDateFormat

public static DateFormat getShortDateFormat(boolean date,
                                            boolean time)

getMediumDateFormat

public static DateFormat getMediumDateFormat(boolean date,
                                             boolean time)

getLongDateFormat

public static DateFormat getLongDateFormat(boolean date,
                                           boolean time)

getFullDateFormat

public static DateFormat getFullDateFormat(boolean date,
                                           boolean time)

getNumberFormat

public static NumberFormat getNumberFormat()

getCurrencyFormat

public static NumberFormat getCurrencyFormat()

getClosestLocale

public static String getClosestLocale(String locale,
                                      String[] locales)