com.google.gwt.i18n.server

## Class GwtLocaleImpl

- java.lang.Object
- - com.google.gwt.i18n.server.GwtLocaleImpl

All Implemented Interfaces:
  GwtLocale, java.lang.Comparable<GwtLocale>

    public class GwtLocaleImpl
    extends java.lang.Object
    implements GwtLocale

Class representing GWT locales and conversion to/from other formats. These locales correspond to BCP47.

### Field Summary

### Fields inherited from interface com.google.gwt.i18n.shared.GwtLocale

`DEFAULT_LOCALE`

### Constructor Summary

Constructors
Constructor and Description
`GwtLocaleImpl(GwtLocaleFactory factory, java.lang.String language, java.lang.String region, java.lang.String script, java.lang.String variant)` Must only be called from a factory to preserve instance caching.

### Method Summary

All Methods Instance Methods Concrete Methods
`int` `compareTo(GwtLocale o)` The default comparison is a lexical ordering.
`boolean` `equals(java.lang.Object obj)`
`java.util.List<GwtLocale>` `getAliases()` Returns the list of aliases for this locale.
`java.lang.String` `getAsString()` Returns the locale as a fixed-format string suitable for use in searching for localized resources.
`GwtLocale` `getCanonicalForm()` Returns this locale in canonical form.
`java.util.List<GwtLocale>` `getCompleteSearchList()` Returns the complete list of locales to search for the current locale.
`java.util.List<GwtLocale>` `getInheritanceChain()` Return a list of locales to search for, in order of preference.
`java.lang.String` `getLanguage()` Returns the language portion of the locale, or null if none.
`java.lang.String` `getLanguageNotNull()` Returns the language portion of the locale, or the empty string if none.
`java.lang.String` `getRegion()` Returns the region portion of the locale, or null if none.
`java.lang.String` `getRegionNotNull()` Returns the region portion of the locale, or the empty string if none.
`java.lang.String` `getScript()` Returns the script portion of the locale, or null if none.
`java.lang.String` `getScriptNotNull()` Returns the script portion of the locale, or the empty string if none.
`java.lang.String` `getVariant()` Returns the variant portion of the locale, or null if none.
`java.lang.String` `getVariantNotNull()` Returns the variant portion of the locale, or the empty string if none.
`int` `hashCode()`
`boolean` `inheritsFrom(GwtLocale parent)` Return true if this locale inherits from the specified locale.
`boolean` `isDefault()` Returns true if this is the default or root locale.
`java.lang.String` `toString()` Returns a human readable string -- "default" or the same as getAsString().
`boolean` `usesSameScript(GwtLocale other)` Checks if this locale uses the same script as another locale, taking into account default scripts.

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### GwtLocaleImpl

    GwtLocaleImpl(GwtLocaleFactory factory,
                  java.lang.String language,
                  java.lang.String region,
                  java.lang.String script,
                  java.lang.String variant)

Must only be called from a factory to preserve instance caching.

### Method Detail

#### compareTo

    public int compareTo(GwtLocale o)

Description copied from interface: `GwtLocale`
The default comparison is a lexical ordering.

Specified by:
  `compareTo` in interface `GwtLocale`
Specified by:
  `compareTo` in interface `java.lang.Comparable<GwtLocale>`

#### equals

    public boolean equals(java.lang.Object obj)

Overrides:
  `equals` in class `java.lang.Object`

#### getAliases

    public java.util.List<GwtLocale> getAliases()

Description copied from interface: `GwtLocale`
Returns the list of aliases for this locale. The canonical form of the current locale is always first on the list. Language/region codes have changed over time, so some systems continue to use the older codes. Aliases allow GWT to use the official Unicode CLDR locales while still interoperating with such systems.

Specified by:
  `getAliases` in interface `GwtLocale`
Returns:
  alias list

#### getAsString

    public java.lang.String getAsString()

Description copied from interface: `GwtLocale`
Returns the locale as a fixed-format string suitable for use in searching for localized resources. The format is language_Script_REGION_VARIANT, where language is a 2-8 letter code (possibly with 3-letter extensions), script is a 4-letter code with an initial capital letter, region is a 2-character country code or a 3-digit region code, and variant is a 5-8 character (may be 4 if the first character is numeric) code. If a component is missing, its preceding _ is also omitted. If this is the default locale, the empty string will be returned.

Specified by:
  `getAsString` in interface `GwtLocale`
Returns:
  String representing locale

#### getCanonicalForm

    public GwtLocale getCanonicalForm()

Returns this locale in canonical form. Changes for canonical form are:

- Deprecated language/region tags are replaced with official versions

Specified by:
  `getCanonicalForm` in interface `GwtLocale`
Returns:
  GwtLocale instance

#### getCompleteSearchList

    public java.util.List<GwtLocale> getCompleteSearchList()

Description copied from interface: `GwtLocale`
Returns the complete list of locales to search for the current locale. This list will always start with the canonical form of this locale, and end with "default", and include all appropriate aliases along the way.

Specified by:
  `getCompleteSearchList` in interface `GwtLocale`
Returns:
  search list

#### getInheritanceChain

    public java.util.List<GwtLocale> getInheritanceChain()

Return a list of locales to search for, in order of preference. The current locale is always first on the list. Aliases are not included in the list -- use `getAliases()` to expand those.

Specified by:
  `getInheritanceChain` in interface `GwtLocale`
Returns:
  inheritance list

#### getLanguage

    public java.lang.String getLanguage()

Description copied from interface: `GwtLocale`
Returns the language portion of the locale, or null if none.

Specified by:
  `getLanguage` in interface `GwtLocale`

#### getLanguageNotNull

    public java.lang.String getLanguageNotNull()

Description copied from interface: `GwtLocale`
Returns the language portion of the locale, or the empty string if none.

Specified by:
  `getLanguageNotNull` in interface `GwtLocale`

#### getRegion

    public java.lang.String getRegion()

Description copied from interface: `GwtLocale`
Returns the region portion of the locale, or null if none.

Specified by:
  `getRegion` in interface `GwtLocale`

#### getRegionNotNull

    public java.lang.String getRegionNotNull()

Description copied from interface: `GwtLocale`
Returns the region portion of the locale, or the empty string if none.

Specified by:
  `getRegionNotNull` in interface `GwtLocale`

#### getScript

    public java.lang.String getScript()

Description copied from interface: `GwtLocale`
Returns the script portion of the locale, or null if none.

Specified by:
  `getScript` in interface `GwtLocale`

#### getScriptNotNull

    public java.lang.String getScriptNotNull()

Description copied from interface: `GwtLocale`
Returns the script portion of the locale, or the empty string if none.

Specified by:
  `getScriptNotNull` in interface `GwtLocale`

#### getVariant

    public java.lang.String getVariant()

Description copied from interface: `GwtLocale`
Returns the variant portion of the locale, or null if none.

Specified by:
  `getVariant` in interface `GwtLocale`

#### getVariantNotNull

    public java.lang.String getVariantNotNull()

Description copied from interface: `GwtLocale`
Returns the variant portion of the locale, or the empty string if none.

Specified by:
  `getVariantNotNull` in interface `GwtLocale`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `java.lang.Object`

#### inheritsFrom

    public boolean inheritsFrom(GwtLocale parent)

Return true if this locale inherits from the specified locale. Note that locale.inheritsFrom(locale) is false -- if you want that to be true, you should just use locale.getInheritanceChain().contains(x).

Specified by:
  `inheritsFrom` in interface `GwtLocale`
Parameters:
  `parent` - locale to test against
Returns:
  true if parent is an ancestor of this locale

#### isDefault

    public boolean isDefault()

Description copied from interface: `GwtLocale`
Returns true if this is the default or root locale.

Specified by:
  `isDefault` in interface `GwtLocale`

#### toString

    public java.lang.String toString()

Description copied from interface: `GwtLocale`
Returns a human readable string -- "default" or the same as getAsString().

Specified by:
  `toString` in interface `GwtLocale`
Overrides:
  `toString` in class `java.lang.Object`

#### usesSameScript

    public boolean usesSameScript(GwtLocale other)

Checks if this locale uses the same script as another locale, taking into account default scripts.

Specified by:
  `usesSameScript` in interface `GwtLocale`
Parameters:
  `other` -
Returns:
  true if the scripts are the same