public final class Dictionary extends Object implements Identifiable, Mergeable, Cloneable, Serializable
Dictionary can store multiple language Records and Dictionarys.
Dictionary is a main component used within LanguageManager to access actual translations.LanguageManager,
Language,
Record,
TranslationInformation,
Serialized Form| Constructor and Description |
|---|
Dictionary()
Constructs new
Dictionary. |
Dictionary(InputStream inputStream)
Loads
Dictionary from the specified InputStream. |
Dictionary(Resource resource)
Loads
Dictionary from the specified Resource. |
Dictionary(String prefix)
Constructs new
Dictionary. |
Dictionary(String prefix,
String name)
Constructs new
Dictionary. |
public Dictionary()
Dictionary.public Dictionary(@Nullable String prefix)
Dictionary.prefix - Dictionary key prefixpublic Dictionary(@Nullable String prefix, @Nullable String name)
Dictionary.prefix - Dictionary key prefixname - Dictionary namepublic Dictionary(@NotNull Resource resource)
Dictionary from the specified Resource.resource - Resource to load Dictionary frompublic Dictionary(@NotNull InputStream inputStream)
Dictionary from the specified InputStream.inputStream - InputStream to load Dictionary from@NotNull public String getId()
IdentifiableNotNull in futuregetId in interface Identifiable@Nullable public String getName()
Dictionary name.Dictionary namepublic void setName(@Nullable String name)
Dictionary name.name - new Dictionary name@Nullable public String getPrefix()
Dictionary prefix.Dictionary prefixpublic void setPrefix(@Nullable String prefix)
Dictionary prefix.prefix - new Dictionary prefixpublic int recordsCount()
Records in this Dictionary.
Note that this method doesn't count Records from sub-Dictionarys.Records in this Dictionarypublic int totalRecordsCount()
Records in this Dictionary and all sub-Dictionarys@NotNull public List<Record> getRecords()
List of Records this Dictionary containspublic void setRecords(@Nullable List<Record> records)
records - new List of Records for this Dictionary@Nullable public Record getRecord(@NotNull String key, @NotNull Locale locale)
Record for the specified language key.
Search will be perfomed in this Dictionary and all sub-Dictionarys.public void addRecord(@NotNull Record record)
Record into this Dictionary and returns it.record - Record to addpublic void removeRecord(@NotNull Record record)
Record from this Dictionary.record - Record to removepublic void removeRecord(@NotNull String key)
Record with the specified key from this Dictionary.key - key of Record to removepublic void clearRecords()
Records from this Dictionary.@NotNull public Set<String> getKeys()
Set of all Record keys for this Dictionary.
This will include all keys for Records in sub-Dictionarys.Set of all Record keys for this Dictionarypublic int dictionariesCount()
Dictionarys in this Dictionary.Dictionarys in this Dictionary@NotNull public List<Dictionary> getDictionaries()
List of Dictionarys this Dictionary containspublic void setDictionaries(@Nullable List<Dictionary> dictionaries)
dictionaries - new List of Dictionarys for this Dictionarypublic void addDictionary(@NotNull Dictionary dictionary)
Dictionary.dictionary - child Dictionary to addpublic void removeDictionary(@NotNull Dictionary dictionary)
Dictionary.dictionary - child Dictionary to removepublic void clearDictionaries()
Dictionarys.@NotNull public List<TranslationInformation> getTranslations()
List of TranslationInformations contained in this dictionary.List of TranslationInformations contained in this dictionarypublic void setTranslations(@Nullable List<TranslationInformation> translations)
List of TranslationInformations for this dictionary.translations - new List of TranslationInformations for this dictionary@Nullable public TranslationInformation getTranslation(@NotNull Locale locale)
TranslationInformation for the specified Locale.locale - LocaleTranslationInformation for the specified Localepublic void addTranslation(@NotNull TranslationInformation translation)
TranslationInformation for this Dictionary.translation - TranslationInformation to add@NotNull public List<Locale> getAllLocales()
List of all Locale from this Dictionary@NotNull public List<Locale> getSupportedLocales()
List of Locale supported by this Dictionary.
Language codes are used to detect whether or not specific Locale is supported.
We can't say that for instance "en_US" Locale is not supported if we have "en" or "en_GB" translation available.
Even though it is not strict "supported" case it is much better than having fully distinct translation for each country.List of Locale supported by this Dictionary@Nullable protected List<Locale> collectSupportedLocales(@Nullable List<Locale> locales)
Locales from this Dictionary and all sub-Dictionary Records.
Note that Locales intersection is only used across different Dictionarys.
Singke Dictionary can have Record with varying Locales but they will all be counted in for it.
Basically any Locale found within single Dictionary is considered to be supported.locales - List of Locales collected so far, can be nullLocales from this Dictionary and all sub-Dictionary RecordsCopyright © 2020. All rights reserved.