wt.httpgw
Class LanguagePreference

java.lang.Object
  extended bywt.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


Field Summary
private static String cvLocalizedResource
          The resource to be utilized to determine the Windchill Supported Locales
private  String lang
           
private  double qualityValue
           
private static String RESOURCE
           
private static String versionID
           
 
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.
static Locale getDefaultLocale(Vector preferences)
          This method is used to construct a Locale object based solely on the accept_language header sent by the browser.
 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.
static void main(String[] args)
          Supported API: false
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionID

private static final String versionID
See Also:
Constant Field Values

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

cvLocalizedResource

private static final String cvLocalizedResource
The resource to be utilized to determine the Windchill Supported Locales

See Also:
Constant Field Values

lang

private String lang

qualityValue

private double qualityValue
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.

getDefaultLocale

public static Locale getDefaultLocale(Vector preferences)
                               throws WTException
This method is used to construct a Locale object based solely on the accept_language header sent by the browser.

Throws:
WTException

main

public static void main(String[] args)
Supported API: false