TPTP 4.6.0 Platform Project
Internal API Specification

org.eclipse.hyades.internal.logging.core.internationalization
Class InternationalizationUtilities

java.lang.Object
  extended by org.eclipse.hyades.internal.logging.core.internationalization.InternationalizationUtilities

public final class InternationalizationUtilities
extends java.lang.Object

Internationalization utilities facade class containing operations to eliminate the International Components for Unicode (ICU) dependency in some run-times.


Field Summary
protected static boolean isICUAvailable
          Static flag for quickly determining if the ICU classes are available on the classpath.
 
Constructor Summary
InternationalizationUtilities()
           
 
Method Summary
static char charAt(java.lang.String string, int index)
          Returns the char value at the specified index for a given String.
static java.lang.String format(long milliseconds, java.lang.String dateFormatPattern, com.ibm.icu.util.ULocale locale, java.lang.String timeZoneID)
          Resolves the formatted date string associated with the parameter long representing a Coordinated Universal Time (UTC) date in milliseconds using the parameter date format pattern based on the parameter Locale and time zone ID.
static java.lang.String format(java.lang.String message, java.lang.Object[] arguments)
          Resolves the formatted message associated with the localized parameter message and message parameters based on the default locale.
static java.lang.String format(java.lang.String message, java.lang.Object[] arguments, com.ibm.icu.util.ULocale locale)
          Resolves the formatted message associated with the localized parameter message and message parameters based on the parameter Locale.
static java.lang.String[] tokenize(java.lang.String string)
          Tokenizes the parameter String to an array of tokens based on the following separating token characters: Space (e.g. ' ') Tab (e.g.
static java.lang.String[] tokenize(java.lang.String string, java.lang.String delimiters)
          Tokenizes the parameter String to an array of tokens based on the separating token characters in the delimiters parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isICUAvailable

protected static boolean isICUAvailable
Static flag for quickly determining if the ICU classes are available on the classpath.

By default, the ICU classes are assumed to be available on the classpath.

Constructor Detail

InternationalizationUtilities

public InternationalizationUtilities()
Method Detail

format

public static java.lang.String format(long milliseconds,
                                      java.lang.String dateFormatPattern,
                                      com.ibm.icu.util.ULocale locale,
                                      java.lang.String timeZoneID)
                               throws java.lang.IllegalArgumentException
Resolves the formatted date string associated with the parameter long representing a Coordinated Universal Time (UTC) date in milliseconds using the parameter date format pattern based on the parameter Locale and time zone ID.

When the International Components for Unicode (ICU) JAR(s) are available on the class path at run-time, date formatting is done by the SimpleDateFormat class using the ULocale (parameter Locale converted to a ULocale - see ULocale.forLocale(Locale)), GregorianCalendar and TimeZone (parameter time zone ID converted to a TimeZone - see TimeZone.getTimeZone(String)) classes, otherwise date formatting is done by the SimpleDateFormat class using the Locale, GregorianCalendar and TimeZone classes. That is, if the International Components for Unicode (ICU) JAR(s) are available on the class path at run-time, the parameter date format pattern is based on the syntax and symbols as specified in the class comment header of the SimpleDateFormat class, otherwise the parameter date format pattern is based on the syntax and symbols as specified in the class comment header of the java.util.SimpleDateFormat class. Also, if the International Components for Unicode (ICU) JAR(s) are available on the class path at run-time, the parameter time zone ID is based on the syntax as specified in the class comment header of the TimeZone class, otherwise the parameter time zone ID is based on the syntax as specified in the class comment header of the TimeZone class.

Parameters:
milliseconds - A long representing a Coordinated Universal Time (UTC) time stamp in milliseconds.
dateFormatPattern - The date format pattern.
locale - The Locale for date formatting.
timeZoneID - The time zone ID for date formatting.
Returns:
The date as a formatted string using the parameter date format pattern, locale and time zone ID.
Throws:
java.lang.IllegalArgumentException - If the date format pattern is invalid.
See Also:
SimpleDateFormat, Locale, GregorianCalendar, TimeZone, SimpleDateFormat, ULocale, GregorianCalendar, TimeZone, format(long, String, com.ibm.icu.util.ULocale, String)

format

public static java.lang.String format(java.lang.String message,
                                      java.lang.Object[] arguments)
                               throws java.lang.IllegalArgumentException
Resolves the formatted message associated with the localized parameter message and message parameters based on the default locale.

When the International Components for Unicode (ICU) JAR(s) are available on the class path at run-time, message formatting is done by the MessageFormat class using the ULocale class, otherwise message formatting is done by the MessageFormat class using the Locale class.

Parameters:
message - The localized message to be formatted.
arguments - The array of message parameters for formatting in the localized and formatted message.
Returns:
The localized and formatted message.
Throws:
java.lang.IllegalArgumentException - If the localized message is invalid and cannot be formatted.
See Also:
MessageFormat, Locale, MessageFormat, ULocale, InternationalizationUtilities#format(String, Object[], java.util.Locale), format(String, Object[], com.ibm.icu.util.ULocale)

format

public static java.lang.String format(java.lang.String message,
                                      java.lang.Object[] arguments,
                                      com.ibm.icu.util.ULocale locale)
                               throws java.lang.IllegalArgumentException
Resolves the formatted message associated with the localized parameter message and message parameters based on the parameter Locale.

When the International Components for Unicode (ICU) JAR(s) are available on the class path at run-time, message formatting is done by the MessageFormat class using the ULocale class (parameter Locale converted to a ULocale - see ULocale.forLocale(Locale)), otherwise message formatting is done by the MessageFormat class using the Locale class.

Parameters:
message - The localized message to be formatted.
arguments - The array of message parameters for formatting in the localized and formatted message.
locale - The Locale for message formatting.
Returns:
The localized and formatted message.
Throws:
java.lang.IllegalArgumentException - If the localized message is invalid and cannot be formatted.
See Also:
MessageFormat, Locale, MessageFormat, ULocale, format(String, Object[], com.ibm.icu.util.ULocale)

tokenize

public static java.lang.String[] tokenize(java.lang.String string)
Tokenizes the parameter String to an array of tokens based on the following separating token characters:


tokenize

public static java.lang.String[] tokenize(java.lang.String string,
                                          java.lang.String delimiters)
Tokenizes the parameter String to an array of tokens based on the separating token characters in the delimiters parameter. The separating token characters are not returned.

When the International Components for Unicode (ICU) JAR(s) are available on the class path at run-time, the StringTokenizer class is used, otherwise the StringTokenizer class is used.

Parameters:
string - The String to be tokenized.
delimiters - The separating token characters.
Returns:
Array containing the tokenized parameter String, otherwise null.
See Also:
StringTokenizer, StringTokenizer

charAt

public static char charAt(java.lang.String string,
                          int index)
                   throws java.lang.IndexOutOfBoundsException
Returns the char value at the specified index for a given String.

When the International Components for Unicode (ICU) JAR(s) are available on the class path at run-time, the UTF16 class is used, otherwise the String class is used.

Parameters:
string - The String to get the char value at the specified index from.
index - the index of the char value.
Returns:
the char value at the specified index of this string.
Throws:
java.lang.IndexOutOfBoundsException
See Also:
String, UTF16

TPTP 4.6.0 Platform Project
Internal API Specification