wt.httpgw
Class LanguagePreference

java.lang.Object
  extended by wt.httpgw.LanguagePreference

public class LanguagePreference
extends Object

LanguagePreference contains methods used to parse HTTP Accept-Language strings and retrieve the 'sub-parts' of the strings. These methods are for use when localizing a response to a client HTTP request.

Supported API: true
Extendable: false


Constructor Summary
LanguagePreference()
          Supported API: true
LanguagePreference(String language, double qvalue)
          Supported API: true
 
Method Summary
static Vector getAcceptLanguagePreferences(String HTTPAcceptLanguage)
          getAcceptLanguagePreferences parses the HTTPAcceptLanguage string and builds a Vector of String objects to return.
 String getLanguage()
          Returns the language string of the LanguagePreference object.
static Locale getLocale(String aLanguageList)
          This method will take a String of languages obtained from the request Accept-Language attribute and decide the most appropriate Windchill Supported Locale from the given set of languages.
static Locale getLocale(Vector preferences)
          This method will take a Vector of languages obtained from the request Accept-Language attribute and decide the most appropriate Windchill Supported Locale from the given set of languages.
 double getQualityValue()
          Returns the qualtityValue of the LanguagePreference object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LanguagePreference

public LanguagePreference()
Supported API: true


LanguagePreference

public LanguagePreference(String language,
                          double qvalue)
Supported API: true

Method Detail

getQualityValue

public double getQualityValue()
Returns the qualtityValue of the LanguagePreference object.

Supported API: true


getLanguage

public String getLanguage()
Returns the language string of the LanguagePreference object.

Supported API: true


getAcceptLanguagePreferences

public static Vector getAcceptLanguagePreferences(String HTTPAcceptLanguage)
                                           throws WTException
getAcceptLanguagePreferences parses the HTTPAcceptLanguage string and builds a Vector of String objects to return. The Vector is populated in order of decreasing preference, that is, position 0 holds the most preferred language, position 1 (if present) holds the second preference, etc.

Supported API: true

Parameters:
HTTPAcceptLanguage - String received from an HTTP request holding the Accept-Language value.
Returns:
Vector of String objects.
Throws:
WTException - Thrown if a parsing error occurs.

getLocale

public static Locale getLocale(Vector preferences)
This method will take a Vector of languages obtained from the request Accept-Language attribute and decide the most appropriate Windchill Supported Locale from the given set of languages. If no matching locale if found a locale will be created based on the configured Windchill server locale.

For example, if the Windchill Server is German and the browser language list does not have a support locale, then a German locale will be returned.

See: getLocale(String)

JSP Example:


Supported API: true

Parameters:
preferences - The Vector list of languages from the browsers's Accept-Language attribute.
Returns:
The Windchill locale.

getLocale

public static Locale getLocale(String aLanguageList)
This method will take a String of languages obtained from the request Accept-Language attribute and decide the most appropriate Windchill Supported Locale from the given set of languages. If no matching locale if found a locale will be created based on the configured Windchill server locale.

For example, if the Windchill Server is German and the browser language list does not have a support locale, then a German locale will be returned.

JSP Example:


Supported API: true

Parameters:
aLanguageList - The list of languages from the browsers's Accept-Language attribute.
Returns:
The Windchill locale.