Package es.situm.sdk.model
Class I18nString
- java.lang.Object
-
- es.situm.sdk.model.I18nString
-
- All Implemented Interfaces:
android.os.Parcelable
public final class I18nString extends Object implements android.os.Parcelable
A string with a different value depending of the language. It's recommended to support a default valuedefaultValue()(optional) for non supported languages.ISO 639-2 is used to identify the languages.
- See Also:
Locale.getISO3Language()
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classI18nString.BuilderAllows creating a I18nString in a handier way.
-
Field Summary
Fields Modifier and Type Field Description static StringANY_LANGUAGESpecial code, non ISO 693-2, to denote value to use by default.static android.os.Parcelable.Creator<I18nString>CREATORstatic I18nStringEMPTY
-
Constructor Summary
Constructors Constructor Description I18nString(Map<String,String> values)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringdefaultValue()intdescribeContents()booleanequals(Object o)Stringget(String language)Obtains the string in the provided language.Stringget(Locale locale)Obtains the string in the provided Locale's language Wrapsget(String), usingLocale.getISO3Language()to take language code.booleanhas(String language)Check if the language is supported by this I18nStringinthashCode()StringtoString()voidwriteToParcel(android.os.Parcel dest, int flags)
-
-
-
Field Detail
-
EMPTY
public static final I18nString EMPTY
-
ANY_LANGUAGE
public static final String ANY_LANGUAGE
Special code, non ISO 693-2, to denote value to use by default.- See Also:
- Constant Field Values
-
CREATOR
public static final android.os.Parcelable.Creator<I18nString> CREATOR
-
-
Method Detail
-
get
@NonNull public String get(@NonNull String language)
Obtains the string in the provided language. If there is no value for that language, return value forANY_LANGUAGE- Parameters:
language- ISO 639-2 language name representation, orANY_LANGUAGE. If is null, will check for ANY_LANGUAGE- Returns:
String. Empty if there is no value for this language, or if provided language is null or empty.
-
get
@NonNull public String get(@NonNull Locale locale)
Obtains the string in the provided Locale's language Wrapsget(String), usingLocale.getISO3Language()to take language code.- Parameters:
locale- itsLocale.getISO3Language()stands for the language.- Returns:
String. Empty if there is no value for this language.- Throws:
IllegalArgumentException- if locale is null
-
defaultValue
@NonNull public String defaultValue()
-
has
public boolean has(@NonNull String language)Check if the language is supported by this I18nString- Parameters:
language- ISO 639-2 language name representation. Not null.- Returns:
- true if there is some value for this string, false otherwise.
-
describeContents
public int describeContents()
- Specified by:
describeContentsin interfaceandroid.os.Parcelable
-
writeToParcel
public void writeToParcel(android.os.Parcel dest, int flags)- Specified by:
writeToParcelin interfaceandroid.os.Parcelable
-
-