Package com.helger.commons.text
Class AbstractReadOnlyMapBasedMultilingualText
- java.lang.Object
-
- com.helger.commons.text.AbstractHasText
-
- com.helger.commons.text.AbstractReadOnlyMapBasedMultilingualText
-
- All Implemented Interfaces:
IHasText,IHasTextWithArgs,IMultilingualText,Serializable
- Direct Known Subclasses:
AbstractMapBasedMultilingualText,ReadOnlyMultilingualText
public abstract class AbstractReadOnlyMapBasedMultilingualText extends AbstractHasText implements IMultilingualText, Serializable
AMapbased implementation ofIMultilingualTextthat does not provide writing methods to the outside and is only to be used as a non-abstract base class.- Author:
- Philip Helger
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractReadOnlyMapBasedMultilingualText()protectedAbstractReadOnlyMapBasedMultilingualText(ICommonsOrderedMap<Locale,String> aMapToUse)Protected constructor that specifies the underlyingMapto use.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsLocaleWithFallback(Locale aContentLocale)Check if the passed locale is directly or by fallback contained.booleanequals(Object o)inthashCode()protected voidinternalAddText(Locale aContentLocale, String sValue)protected voidinternalAddText(Map.Entry<Locale,String> aEntry)protected LocaleinternalGetLocaleToUseWithFallback(Locale aContentLocale)Determine the locale to use.protected StringinternalGetText(Locale aContentLocale)Main text resolving.protected voidinternalSetText(Locale aContentLocale, String sValue)static booleanisPerformConsistencyChecks()static voidsetPerformConsistencyChecks(boolean bPerformConsistencyChecks)Enable or disable the internal consistency checks.ICommonsOrderedMap<Locale,String>texts()StringtoString()-
Methods inherited from class com.helger.commons.text.AbstractHasText
getText
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.helger.commons.text.IHasText
getAsHasDisplayText, getText
-
Methods inherited from interface com.helger.commons.text.IHasTextWithArgs
getAsHasDisplayTextWithArgs, getTextWithArgs, getTextWithArgs
-
-
-
-
Constructor Detail
-
AbstractReadOnlyMapBasedMultilingualText
protected AbstractReadOnlyMapBasedMultilingualText()
-
AbstractReadOnlyMapBasedMultilingualText
protected AbstractReadOnlyMapBasedMultilingualText(@Nonnull ICommonsOrderedMap<Locale,String> aMapToUse)
Protected constructor that specifies the underlyingMapto use. Use this constructor to e.g. provide a concurrentHashMapor similar.- Parameters:
aMapToUse- The map to use. Must not benulland must be writable.
-
-
Method Detail
-
setPerformConsistencyChecks
public static void setPerformConsistencyChecks(boolean bPerformConsistencyChecks)
Enable or disable the internal consistency checks.- Parameters:
bPerformConsistencyChecks-trueto enable them,falseto disable them.
-
isPerformConsistencyChecks
public static boolean isPerformConsistencyChecks()
- Returns:
trueif consistency checks are enabled,falseif not. The default value isGlobalDebug.isDebugMode().
-
internalAddText
protected final void internalAddText(@Nonnull Locale aContentLocale, @Nullable String sValue)
-
internalSetText
protected final void internalSetText(@Nonnull Locale aContentLocale, @Nullable String sValue)
-
internalGetText
@Nullable protected final String internalGetText(@Nonnull Locale aContentLocale)
Description copied from class:AbstractHasTextMain text resolving. Get the text in the passed locale.- Specified by:
internalGetTextin classAbstractHasText- Parameters:
aContentLocale- Locale to use. This is the locale resolved internally. Nevernull.- Returns:
nullif no such text present in the passed locale
-
internalGetLocaleToUseWithFallback
@Nullable protected final Locale internalGetLocaleToUseWithFallback(@Nonnull Locale aContentLocale)
Description copied from class:AbstractHasTextDetermine the locale to use.- Overrides:
internalGetLocaleToUseWithFallbackin classAbstractHasText- Parameters:
aContentLocale- Requested locale. Nevernull.- Returns:
- The locale to use. May be
null.
-
containsLocaleWithFallback
public final boolean containsLocaleWithFallback(@Nullable Locale aContentLocale)
Description copied from interface:IMultilingualTextCheck if the passed locale is directly or by fallback contained. The implementation class MUST add locale-generalisation when resolving the text ("de_DE" => "de" => default).- Specified by:
containsLocaleWithFallbackin interfaceIMultilingualText- Parameters:
aContentLocale- The locale to check. May benull.- Returns:
trueif the locale is contained,falseif not.
-
texts
@Nonnull @ReturnsMutableObject public final ICommonsOrderedMap<Locale,String> texts()
- Specified by:
textsin interfaceIMultilingualText- Returns:
- The Locale to text map. Never
null.
-
equals
@OverridingMethodsMustInvokeSuper public boolean equals(Object o)
-
hashCode
@OverridingMethodsMustInvokeSuper public int hashCode()
-
toString
@OverridingMethodsMustInvokeSuper public String toString()
-
-