Class Localization
- java.lang.Object
-
- org.schabi.newpipe.extractor.localization.Localization
-
- All Implemented Interfaces:
java.io.Serializable
public class Localization extends java.lang.Object implements java.io.Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Localization
DEFAULT
-
Constructor Summary
Constructors Constructor Description Localization(java.lang.String languageCode)
Localization(java.lang.String languageCode, java.lang.String countryCode)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
static Localization
fromLocale(java.util.Locale locale)
static java.util.Optional<Localization>
fromLocalizationCode(java.lang.String localizationCode)
java.lang.String
getCountryCode()
java.lang.String
getLanguageCode()
static java.util.Locale
getLocaleFromThreeLetterCode(java.lang.String code)
Converts a three letter language code (ISO 639-2/T) to a Locale because limits of Java Locale class.java.lang.String
getLocalizationCode()
Return a formatted string in the form of:language-Country
, or justlanguage
if country isnull
.int
hashCode()
static java.util.List<Localization>
listFrom(java.lang.String... localizationCodeList)
java.lang.String
toString()
-
-
-
Field Detail
-
DEFAULT
public static final Localization DEFAULT
-
-
Method Detail
-
listFrom
@Nonnull public static java.util.List<Localization> listFrom(java.lang.String... localizationCodeList)
- Parameters:
localizationCodeList
- a list of localization code, formatted likegetLocalizationCode()
- Returns:
- list of Localization objects
- Throws:
java.lang.IllegalArgumentException
- If any of the localizationCodeList is formatted incorrectly
-
fromLocalizationCode
@Nonnull public static java.util.Optional<Localization> fromLocalizationCode(java.lang.String localizationCode)
- Parameters:
localizationCode
- a localization code, formatted likegetLocalizationCode()
- Returns:
- A Localization, if the code was valid.
-
getLanguageCode
@Nonnull public java.lang.String getLanguageCode()
-
getCountryCode
@Nonnull public java.lang.String getCountryCode()
-
fromLocale
public static Localization fromLocale(@Nonnull java.util.Locale locale)
-
getLocalizationCode
public java.lang.String getLocalizationCode()
Return a formatted string in the form of:language-Country
, or justlanguage
if country isnull
.- Returns:
- A correctly formatted localizationCode for this localization.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getLocaleFromThreeLetterCode
public static java.util.Locale getLocaleFromThreeLetterCode(@Nonnull java.lang.String code) throws ParsingException
Converts a three letter language code (ISO 639-2/T) to a Locale because limits of Java Locale class.- Parameters:
code
- a three letter language code- Returns:
- the Locale corresponding
- Throws:
ParsingException
-
-