Package com.suncode.pwfl.translation
Class AbstractTranslator
java.lang.Object
com.suncode.pwfl.translation.AbstractTranslator
- All Implemented Interfaces:
ClassLoaderTranslator,PackageTranslator,Translator
- Direct Known Subclasses:
EmptyTranslator,PropertiesTranslator
@Api
public abstract class AbstractTranslator
extends Object
implements PackageTranslator, ClassLoaderTranslator
Common Translator implementation.
- Author:
- Cezary Kozar 11 sie 2015
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTranslatedPackage(String packageName) Adds package, that contains classes which should be translated with this translator.booleangetLocalizedString(String key) Creates LocalizedString with given key.getLocalizedString(String key, Object... args) Creates LocalizedString with given key and message arguments.getLocalizedString(String key, String defaultValue) Creates LocalizedString with given key and default value.getLocalizedString(String key, String[] fallbackKeys, String defaultValue) Creates LocalizedString with given key, fallback keys and default value.getLocalizedString(String key, String[] fallbackKeys, String defaultValue, Locale locale, Object... args) Creates LocalizedString.getLocalizedString(String key, String defaultValue, Object... args) Creates LocalizedString with given key, default value and message arguments.getLocalizedString(String key, String defaultValue, Locale locale) Creates LocalizedString with given key, locale and default value.getLocalizedString(String key, String defaultValue, Locale locale, Object... args) Creates LocalizedString with given key, default value, locale and message arguments.getLocalizedString(String key, Locale locale) Creates LocalizedString with given key and locale.getLocalizedString(String key, Locale locale, Object... args) Creates LocalizedString with given key, locale and message arguments.getMessage(String key) Return translated message for given key using current user locale.getMessage(String key, Object... args) Return translated message for given key and arguments using current user locale.getMessage(String key, Locale locale) Return translated message for given key and locale.getMessage(String key, Locale locale, Object... args) Return translated message for given key, locale and arguments.inthashCode()protected abstract StringresolveMessage(String key, Locale locale, Object... args) voidsetParent(Translator parent) Sets this translator parent.voidsetTranslatedClassLoader(ClassLoader classLoader) ClassLoader, for which this translator will be registered.Packages, for which this translator will be registered.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.suncode.pwfl.translation.Translator
getMessages
-
Constructor Details
-
AbstractTranslator
public AbstractTranslator() -
AbstractTranslator
-
-
Method Details
-
addTranslatedPackage
Adds package, that contains classes which should be translated with this translator.- Parameters:
packageName- package name
-
setTranslatedClassLoader
-
setParent
Sets this translator parent. -
getParent
-
resolveMessage
protected abstract String resolveMessage(String key, Locale locale, Object... args) throws NoTranslationException - Throws:
NoTranslationException
-
translatedPackages
Description copied from interface:PackageTranslatorPackages, for which this translator will be registered.- Specified by:
translatedPackagesin interfacePackageTranslator
-
translatedClassLoader
Description copied from interface:ClassLoaderTranslatorClassLoader, for which this translator will be registered.- Specified by:
translatedClassLoaderin interfaceClassLoaderTranslator
-
getMessage
Description copied from interface:TranslatorReturn translated message for given key, locale and arguments.- Specified by:
getMessagein interfaceTranslator- Parameters:
key- message keylocale- localeargs- optional placeholder arguments (e.g. {0} {1})- Returns:
- translated message for given key
- Throws:
NoTranslationException
-
getMessage
Description copied from interface:TranslatorReturn translated message for given key using current user locale.- Specified by:
getMessagein interfaceTranslator- Throws:
NoTranslationException- See Also:
-
getMessage
Description copied from interface:TranslatorReturn translated message for given key and locale.- Specified by:
getMessagein interfaceTranslator- Throws:
NoTranslationException- See Also:
-
getMessage
Description copied from interface:TranslatorReturn translated message for given key and arguments using current user locale.- Specified by:
getMessagein interfaceTranslator- Throws:
NoTranslationException- See Also:
-
getLocalizedString
Description copied from interface:TranslatorCreates LocalizedString with given key.- Specified by:
getLocalizedStringin interfaceTranslator- See Also:
-
getLocalizedString
Description copied from interface:TranslatorCreates LocalizedString with given key and default value.- Specified by:
getLocalizedStringin interfaceTranslator- See Also:
-
getLocalizedString
Description copied from interface:TranslatorCreates LocalizedString with given key, fallback keys and default value.- Specified by:
getLocalizedStringin interfaceTranslator- See Also:
-
getLocalizedString
Description copied from interface:TranslatorCreates LocalizedString with given key and locale.- Specified by:
getLocalizedStringin interfaceTranslator- See Also:
-
getLocalizedString
Description copied from interface:TranslatorCreates LocalizedString with given key, locale and default value.- Specified by:
getLocalizedStringin interfaceTranslator- See Also:
-
getLocalizedString
Description copied from interface:TranslatorCreates LocalizedString with given key and message arguments.- Specified by:
getLocalizedStringin interfaceTranslator- See Also:
-
getLocalizedString
Description copied from interface:TranslatorCreates LocalizedString with given key, default value and message arguments.- Specified by:
getLocalizedStringin interfaceTranslator- See Also:
-
getLocalizedString
Description copied from interface:TranslatorCreates LocalizedString with given key, locale and message arguments.- Specified by:
getLocalizedStringin interfaceTranslator- See Also:
-
getLocalizedString
public LocalizedString getLocalizedString(String key, String defaultValue, Locale locale, Object... args) Description copied from interface:TranslatorCreates LocalizedString with given key, default value, locale and message arguments.- Specified by:
getLocalizedStringin interfaceTranslator- See Also:
-
getLocalizedString
public LocalizedString getLocalizedString(String key, String[] fallbackKeys, String defaultValue, Locale locale, Object... args) Description copied from interface:TranslatorCreates LocalizedString.- Specified by:
getLocalizedStringin interfaceTranslator- Parameters:
key- message keyfallbackKeys- fallback keysdefaultValue- default value returned when no translation could be foundlocale- localeargs- optional message arguments (e.g. {0} {1})- Returns:
- LocalizedString
- See Also:
-
equals
-
hashCode
public int hashCode()
-