com.starteam
Class Translations

java.lang.Object
  extended by com.starteam.Translations
All Implemented Interfaces:
java.io.Serializable

public final class Translations
extends java.lang.Object
implements java.io.Serializable

The Translations class defines the possible localized translations of a particular resource. There is the notion of a default translation which should be used when no translation exists for a particular language. In addition to the default there may be any number of specific localizations defined on a per-locale basis.

See Also:
Serialized Form

Field Summary
static Translations FALSE
          Known translations of "false".
static Translations NO
          Known translations of "no".
static Translations OFF
          Known translations of "off".
static Translations ON
          Known translations of "on".
static Translations TRUE
          Known translations of "true".
static Translations YES
          Known translations of "yes".
 
Constructor Summary
Translations()
          Create a new Translations object with only a default set to the empty string.
Translations(java.lang.String defaultValue)
          Create a new Translations object with the default set to the specified string.
 
Method Summary
 java.util.Locale closestDefined(java.util.Locale locale)
          The closest locale defined for the specified locale
 Translations copy()
          Makes a copy of the specified translation
 boolean equals(java.lang.Object o)
          compare two Translations for equality
 java.lang.String getDebugString()
          return a string representation of the Locale, useful for debugging
 java.lang.String getDefault()
          Return the default translation.
 java.lang.String[] getLocaleNames()
          Return all of the locale names for which a translation exists.
 java.util.Locale[] getLocales()
          Return all of the locales for which a translation exists.
 java.lang.String getTranslation(java.util.Locale locale)
          Return the translation for the specified locale.
 java.lang.String getTranslation(java.lang.String locale)
          Return the translation for the specified locale.
 int hashCode()
          returns a unique hash for this instance
 boolean isEqualTo(Translations other)
          compares two translations
static java.util.Locale parseLocale(java.lang.String pattern)
          Parse the locale pattern and return the corresponding locale.
 void removeLocale(java.util.Locale locale)
          Remove the translation for the specified locale.
 void removeLocale(java.lang.String locale)
          Remove this the translation for the specified locale.
 void setDefault(java.lang.String value)
          Change the default translation.
 java.lang.String setTranslation(java.util.Locale locale, java.lang.String value)
          Create or modify an existing translation.
 java.lang.String setTranslation(java.lang.String locale, java.lang.String value)
          Create or modify an existing translation.
 java.lang.String toString()
          return a string representation of the Locale, useful for debugging
static java.lang.String toString(java.util.Locale locale)
          Returns a string prepresentation of the specified locale.
 java.lang.String translate()
          Returns the most appropriate translation for this resource based on the default locale.
 java.lang.String translate(java.util.Locale locale)
          Returns the most appropriate translation for this resource for the specified locale.
 java.lang.String translate(java.lang.String locale)
          Returns the most appropriate translation for this resource for the specified locale.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TRUE

public static final Translations TRUE
Known translations of "true".


FALSE

public static final Translations FALSE
Known translations of "false".


YES

public static final Translations YES
Known translations of "yes".


NO

public static final Translations NO
Known translations of "no".


ON

public static final Translations ON
Known translations of "on".


OFF

public static final Translations OFF
Known translations of "off".

Constructor Detail

Translations

public Translations()
Create a new Translations object with only a default set to the empty string.


Translations

public Translations(java.lang.String defaultValue)
Create a new Translations object with the default set to the specified string.

Parameters:
defaultValue - the default display name. May not be null.
Method Detail

getDefault

public java.lang.String getDefault()
Return the default translation. Will not return null because a default translation must always exist.


setDefault

public void setDefault(java.lang.String value)
Change the default translation. The value may not be null.

Parameters:
value - the new default translation, may not be null.

getLocales

public java.util.Locale[] getLocales()
Return all of the locales for which a translation exists.

Returns:
the locales for which a translation exists

getLocaleNames

public java.lang.String[] getLocaleNames()
Return all of the locale names for which a translation exists.

Returns:
the locale names for which a translation exists.

removeLocale

public void removeLocale(java.util.Locale locale)
Remove the translation for the specified locale. The defailt (invariant) locale (lang="", country="" and variant="") can not be removed.

Parameters:
locale - the locale to be removed

removeLocale

public void removeLocale(java.lang.String locale)
Remove this the translation for the specified locale.

Parameters:
locale - the locale to be removed

setTranslation

public java.lang.String setTranslation(java.util.Locale locale,
                                       java.lang.String value)
Create or modify an existing translation.

Parameters:
locale - the locale for the new translation
value - the locale specific translation
Returns:
the previous translation or null if there was none.

setTranslation

public java.lang.String setTranslation(java.lang.String locale,
                                       java.lang.String value)
Create or modify an existing translation.

Parameters:
locale - the locale for the new translation
value - the locale specific translation
Returns:
the previous translation or null if there was none.

getTranslation

public java.lang.String getTranslation(java.util.Locale locale)
Return the translation for the specified locale.

Parameters:
locale - the locale of the desired translation. May not be null.
Returns:
returns the translation for the specified locale or null if none exists.

getTranslation

public java.lang.String getTranslation(java.lang.String locale)
Return the translation for the specified locale.

Parameters:
locale - the locale of the desired translation. May not be null.
Returns:
returns the translation for the specified locale or null if none exists.

translate

public java.lang.String translate(java.util.Locale locale)
Returns the most appropriate translation for this resource for the specified locale. The algorithm for looking up the translation begins with the specified locale. If a translation for that locale exists then it will be returned. If not, then a translation for the locale comprising only the language and country of the locale will be return if it exists. If not, then it checks for a translation based only on the language and failing that will return the default value.

Parameters:
locale - the locale of the desired translation. A null value will return the default translation.
See Also:
Translations.getDefault()

closestDefined

public java.util.Locale closestDefined(java.util.Locale locale)
The closest locale defined for the specified locale

Parameters:
locale - the specified locale
Returns:
closest locale defined for the specified locale

translate

public java.lang.String translate(java.lang.String locale)
Returns the most appropriate translation for this resource for the specified locale.

Parameters:
locale - the locale of the desired translation. A null value will return the default translation.

translate

public java.lang.String translate()
Returns the most appropriate translation for this resource based on the default locale.

See Also:
Locale.getDefault()

toString

public static java.lang.String toString(java.util.Locale locale)
Returns a string prepresentation of the specified locale.

Parameters:
locale - the locale. A null parameter will return the empty string.

parseLocale

public static java.util.Locale parseLocale(java.lang.String pattern)
Parse the locale pattern and return the corresponding locale. The pattern is "language-country-variant". E.g "en", "en-US", "en-US-SoCal".

Parameters:
pattern - the locale pattern. A null pattern will return the "invariant" locale (language="", country="", variant="")
Returns:
the Locale based on the specified pattern

getDebugString

public java.lang.String getDebugString()
return a string representation of the Locale, useful for debugging

Returns:
a string representation of the Locale, useful for debugging

toString

public java.lang.String toString()
return a string representation of the Locale, useful for debugging

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the Locale, useful for debugging

equals

public boolean equals(java.lang.Object o)
compare two Translations for equality

Overrides:
equals in class java.lang.Object
Parameters:
o - the other Translation
Returns:
true if the two translations are considered equal

hashCode

public int hashCode()
returns a unique hash for this instance

Overrides:
hashCode in class java.lang.Object
Returns:
a unique hash for this instance

isEqualTo

public boolean isEqualTo(Translations other)
compares two translations

Parameters:
other - the other translation
Returns:
true if the two translations are considered equal

copy

public Translations copy()
Makes a copy of the specified translation

Returns:
a copy of the given translation


StarTeam SDK 14.0, Build 21
Copyright © 2003-2012 Borland Software Corporation. All rights reserved.