Package wt.httpgw

Class LanguagePreference

java.lang.Object
wt.util.BaseLanguagePreference
wt.httpgw.LanguagePreference

public final class LanguagePreference extends wt.util.BaseLanguagePreference
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 Details

    • LanguagePreference

      @Deprecated public LanguagePreference()
      Deprecated.
      Supported API: true
    • LanguagePreference

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

    • getQualityValue

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

      Supported API: true
      Overrides:
      getQualityValue in class wt.util.BaseLanguagePreference
    • getLanguage

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

      Supported API: true
      Overrides:
      getLanguage in class wt.util.BaseLanguagePreference
    • getAcceptLanguagePreferences

      @Deprecated public static Vector getAcceptLanguagePreferences(String acceptLanguageString) throws WTException
      Deprecated.
      Parses an HTTP Accept-Language string and returns a Vector of String representations of languages in order of decreasing preference.

      Supported API: true
      Parameters:
      acceptLanguageString - Language preferences expressed in HTTP Accept-Language header value format
      Returns:
      Vector of String representations of languages in order of descending preference
      Throws:
      IEException - Never actually thrown; declared purely for backwards compilation compatibility
      WTException
      See Also:
    • getAcceptLanguageLocales

      public static List<Locale> getAcceptLanguageLocales(String acceptLanguageString)
      Parses an HTTP Accept-Language header string and returns a list of Locale objects in order of decreasing preference,

      Supported API: true
      Parameters:
      acceptLanguageString - Language preferences expressed in HTTP Accept-Language header value format
      Returns:
      List of Locale objects in order of decreasing preference
    • getLocale

      @Deprecated public static Locale getLocale(Vector<?> preferences)
      Deprecated.
      This method takes a Vector of languages obtained from the request Accept-Language attribute and returns the most appropriate Windchill supported locale from the given set of languages.

      If no supported language if found in the Vector, the root locale is returned.

      See: getLocale(String)

      JSP Example:

        getLocale( getAcceptLanguagePreferences( request.getHeader("Accept-Language") ) );


      Supported API: true
      Parameters:
      preferences - A Vector of languages from an HTTP request's Accept-Language header as provided by getAcceptLanguageLocales(java.lang.String) or getAcceptLanguagePreferences(java.lang.String)
      Returns:
      The Windchill locale.
      See Also:
    • getLocale

      public static Locale getLocale(Collection<?> preferences)
      This method takes an ordered collection of languages obtained from the request Accept-Language attribute and returns the most appropriate Windchill supported locale from the given set of languages.

      If no supported language if found in the collection, the root locale is returned.

      See: getLocale(String)

      JSP Example:

        getLocale( getAcceptLanguageLocales( request.getHeader("Accept-Language") ) );


      Supported API: true
      Parameters:
      preferences - An ordered collection of languages from an HTTP request's Accept-Language header as provided by getAcceptLanguageLocales(java.lang.String) or getAcceptLanguagePreferences(java.lang.String)
      Returns:
      The Windchill locale.
    • getLocale

      public static Locale getLocale(String acceptLanguageString)
      This method takes a String of languages obtained from the request Accept-Language attribute and returns the most appropriate Windchill supported locale from the given set of languages.

      If no supported language if found in the String, the root locale is returned.

      JSP Example:

        getLocale( request.getHeader("Accept-Language") );


      Supported API: true
      Parameters:
      acceptLanguageString - An HTTP request's Accept-Language header value.
      Returns:
      The Windchill locale.