Class BasicTranslationPackage
- java.lang.Object
- 
- com.inductiveautomation.ignition.common.i18n.translation.BasicTranslationPackage
 
- 
- All Implemented Interfaces:
- MutableTranslationPackage,- TranslationPackage,- java.io.Serializable
 - Direct Known Subclasses:
- TranslationPackageDiff
 
 public class BasicTranslationPackage extends java.lang.Object implements MutableTranslationPackage A translation package holds the keys and one or more translations for the keys.- See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected classBasicTranslationPackage.TranslationIterator
 - 
Constructor SummaryConstructors Constructor Description BasicTranslationPackage()BasicTranslationPackage(TranslationPackage copy)BasicTranslationPackage(java.util.Locale baseLocale, KeyHashRule hashRule)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTerm(java.lang.String key)Ensures that the specified key is in the translation package.voidaddTranslation(java.lang.String term, java.util.Locale targetLocale, java.lang.String translation)Sets a translation for the specified key and locale.voidaddTranslations(java.lang.String key, TranslationMap translations)Sets all of the translations for a specific key.voidapplyPackage(TranslationPackage tp)Can merge an existing translation package into this one.TranslationPackageDiffcreateDiff()voidensureLocaleExists(java.util.Locale locale)Verifies that the locale is present, adding it if necessary.booleanequals(java.lang.Object obj)java.lang.Stringget(java.util.Locale locale, java.lang.String key)Returns the translation of the key for the requested locale, or the key, if the translation is not available.java.util.Iterator<Translation>getAllTranslations()java.util.Collection<java.lang.String>getAvailableKeys()java.util.Collection<java.util.Locale>getAvailableLocales()java.util.LocalegetBaseLocale()TranslationBundlegetBundle(java.util.Locale l)java.util.Map<java.lang.String,TermKey>getIndex()KeyHashRulegetKeyHashRule()The key hash rule dictates how term equivalency is calculated.TranslationBundlegetOrCreateBundle(java.util.Locale l)protected TermKeygetOrCreateTermKey(java.lang.String term)protected java.lang.StringgetOrNull(java.util.List<java.util.Locale> locales, java.lang.String key)Returns the translation, or null.java.lang.StringgetStrict(java.util.Locale locale, java.lang.String key)protected TermKeygetTermKey(java.lang.String term)TranslationMapgetTranslationsFor(java.lang.String key)protected java.lang.StringhashKey(java.lang.String term)Returns the hashKey for the term *booleanisDefined(java.lang.String key)Returns whether the key is defined in the package.booleanisDefined(java.lang.String key, java.util.Locale l)Returns whether there is a translation defined for the given key in the given locale.booleanremoveKey(java.lang.String key)Removes the specific key, and any translations.voidremoveLocale(java.util.Locale locale)voidremoveTranslation(java.lang.String term, java.util.Locale locale)Removes a translation for a specified key and locale.voidsetBaseLocale(java.util.Locale baseLocale)voidsetIndex(java.util.Map<java.lang.String,TermKey> index)voidsetKeyHashRule(KeyHashRule rule)voidupdateIndex(java.util.Collection<java.lang.String> keys)
 
- 
- 
- 
Constructor Detail- 
BasicTranslationPackagepublic BasicTranslationPackage(TranslationPackage copy) 
 - 
BasicTranslationPackagepublic BasicTranslationPackage() 
 - 
BasicTranslationPackagepublic BasicTranslationPackage(java.util.Locale baseLocale, KeyHashRule hashRule)
 
- 
 - 
Method Detail- 
hashKeyprotected java.lang.String hashKey(java.lang.String term) Returns the hashKey for the term *
 - 
getTermKeyprotected TermKey getTermKey(java.lang.String term) 
 - 
getOrCreateTermKeyprotected TermKey getOrCreateTermKey(java.lang.String term) 
 - 
getIndexpublic java.util.Map<java.lang.String,TermKey> getIndex() 
 - 
setIndexpublic void setIndex(java.util.Map<java.lang.String,TermKey> index) 
 - 
getKeyHashRulepublic KeyHashRule getKeyHashRule() Description copied from interface:TranslationPackageThe key hash rule dictates how term equivalency is calculated. Though this field should not be used to look up terms, it's important that derived translation packages use the same rule.- Specified by:
- getKeyHashRulein interface- TranslationPackage
 
 - 
setKeyHashRulepublic void setKeyHashRule(KeyHashRule rule) 
 - 
getBaseLocalepublic java.util.Locale getBaseLocale() - Specified by:
- getBaseLocalein interface- TranslationPackage
- Returns:
- the "base" locale, the language in which the terms are defined.
 
 - 
setBaseLocalepublic void setBaseLocale(java.util.Locale baseLocale) 
 - 
getAvailableKeyspublic java.util.Collection<java.lang.String> getAvailableKeys() - Specified by:
- getAvailableKeysin interface- TranslationPackage
- Returns:
- all of the defined keys.
 
 - 
getAvailableLocalespublic java.util.Collection<java.util.Locale> getAvailableLocales() - Specified by:
- getAvailableLocalesin interface- TranslationPackage
- Returns:
- the locales for which translations are available. This will include the base locale.
 
 - 
ensureLocaleExistspublic void ensureLocaleExists(java.util.Locale locale) Description copied from interface:MutableTranslationPackageVerifies that the locale is present, adding it if necessary.- Specified by:
- ensureLocaleExistsin interface- MutableTranslationPackage
 
 - 
isDefinedpublic boolean isDefined(java.lang.String key) Description copied from interface:TranslationPackageReturns whether the key is defined in the package. A key can be defined without any particular translations.- Specified by:
- isDefinedin interface- TranslationPackage
 
 - 
isDefinedpublic boolean isDefined(java.lang.String key, java.util.Locale l)Description copied from interface:TranslationPackageReturns whether there is a translation defined for the given key in the given locale.- Specified by:
- isDefinedin interface- TranslationPackage
 
 - 
getpublic java.lang.String get(java.util.Locale locale, java.lang.String key)Returns the translation of the key for the requested locale, or the key, if the translation is not available.- Specified by:
- getin interface- TranslationPackage
- key- the key to find a match for, or return value if no value found
- Returns:
- the translation of the key for the requested locale, or the key, if the translation is not available.
 
 - 
getStrictpublic java.lang.String getStrict(java.util.Locale locale, java.lang.String key)- Specified by:
- getStrictin interface- TranslationPackage
- Parameters:
- locale- the locale to find a value for
- key- the key to find a match for
- Returns:
- the translation, or null if the translation doesn't exist.
 
 - 
getOrNullprotected java.lang.String getOrNull(java.util.List<java.util.Locale> locales, java.lang.String key)Returns the translation, or null. This is true even for the base locale, in which case we would be trying to look up the "alternate".
 - 
getBundlepublic TranslationBundle getBundle(java.util.Locale l) 
 - 
getOrCreateBundlepublic TranslationBundle getOrCreateBundle(java.util.Locale l) 
 - 
updateIndexpublic void updateIndex(java.util.Collection<java.lang.String> keys) 
 - 
createDiffpublic TranslationPackageDiff createDiff() - Specified by:
- createDiffin interface- TranslationPackage
- Returns:
- an empty, modifiable diff that respects the same rules as the translation package.
 
 - 
applyPackagepublic void applyPackage(TranslationPackage tp) Can merge an existing translation package into this one. Also, if tp is a TranslationPackageDiff, will remove the removed terms as well.
 - 
getTranslationsForpublic TranslationMap getTranslationsFor(java.lang.String key) - Specified by:
- getTranslationsForin interface- TranslationPackage
- Returns:
- a map of all of the translations available for a given key.
 
 - 
getAllTranslationspublic java.util.Iterator<Translation> getAllTranslations() - Specified by:
- getAllTranslationsin interface- TranslationPackage
- Returns:
- an iterator that goes through all of the translations. Does not include defined keys that have no translations.
 
 - 
addTranslationpublic void addTranslation(java.lang.String term, java.util.Locale targetLocale, java.lang.String translation)Description copied from interface:MutableTranslationPackageSets a translation for the specified key and locale.- Specified by:
- addTranslationin interface- MutableTranslationPackage
 
 - 
removeTranslationpublic void removeTranslation(java.lang.String term, java.util.Locale locale)Description copied from interface:MutableTranslationPackageRemoves a translation for a specified key and locale. Used when someone had a translation and blanks it out.- Specified by:
- removeTranslationin interface- MutableTranslationPackage
 
 - 
addTermpublic void addTerm(java.lang.String key) Description copied from interface:MutableTranslationPackageEnsures that the specified key is in the translation package.- Specified by:
- addTermin interface- MutableTranslationPackage
 
 - 
addTranslationspublic void addTranslations(java.lang.String key, TranslationMap translations)Description copied from interface:MutableTranslationPackageSets all of the translations for a specific key. Translation map can be null, in which case the key will simply be registered in the index.- Specified by:
- addTranslationsin interface- MutableTranslationPackage
 
 - 
removeKeypublic boolean removeKey(java.lang.String key) Description copied from interface:MutableTranslationPackageRemoves the specific key, and any translations.- Specified by:
- removeKeyin interface- MutableTranslationPackage
- Returns:
- true if key was present
 
 - 
removeLocalepublic void removeLocale(java.util.Locale locale) - Specified by:
- removeLocalein interface- MutableTranslationPackage
 
 - 
equalspublic boolean equals(java.lang.Object obj) - Overrides:
- equalsin class- java.lang.Object
 
 
- 
 
-