com.starbase.starteam
Class Translations

java.lang.Object
  |
  +--com.starbase.starteam.Translations

public class Translations
extends java.lang.Object

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.


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)
           
 Translations copy()
           
 boolean equals(java.lang.Object source)
          returns true if this object instance is equal to the source
 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 all instances of this type
 boolean isEqualTo(Translations other)
           
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 toDebugString()
           
 java.lang.String toString()
           
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
 

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.


getLocaleNames

public java.lang.String[] getLocaleNames()
Return all of 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)

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="")

toDebugString

public java.lang.String toDebugString()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isEqualTo

public boolean isEqualTo(Translations other)

copy

public Translations copy()

equals

public boolean equals(java.lang.Object source)
returns true if this object instance is equal to the source

Overrides:
equals in class java.lang.Object
Parameters:
source - Object the source to comapre with
Returns:
boolean true if this object is equal to the source

hashCode

public int hashCode()
returns a unique hash for all instances of this type

Overrides:
hashCode in class java.lang.Object
Returns:
int a unique hash for all instances of this type


StarTeam SDK 10.4, Build 36
Copyright © 2003-2008 Borland Software Corporation. All rights reserved.