Class Localization

java.lang.Object
org.schabi.newpipe.extractor.localization.Localization
All Implemented Interfaces:
Serializable

public class Localization extends Object implements Serializable
See Also:
  • Field Details

  • Constructor Details

    • Localization

      public Localization(@Nonnull String languageCode, @Nullable String countryCode)
    • Localization

      public Localization(@Nonnull String languageCode)
  • Method Details

    • listFrom

      @Nonnull public static List<Localization> listFrom(String... localizationCodeList)
      Parameters:
      localizationCodeList - a list of localization code, formatted like getLocalizationCode()
      Returns:
      list of Localization objects
      Throws:
      IllegalArgumentException - If any of the localizationCodeList is formatted incorrectly
    • fromLocalizationCode

      @Nonnull public static Optional<Localization> fromLocalizationCode(String localizationCode)
      Parameters:
      localizationCode - a localization code, formatted like getLocalizationCode()
      Returns:
      A Localization, if the code was valid.
    • getLanguageCode

      @Nonnull public String getLanguageCode()
    • getCountryCode

      @Nonnull public String getCountryCode()
    • fromLocale

      public static Localization fromLocale(@Nonnull Locale locale)
    • getLocalizationCode

      public String getLocalizationCode()
      Return a formatted string in the form of: language-Country, or just language if country is null.
      Returns:
      A correctly formatted localizationCode for this localization.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getLocaleFromThreeLetterCode

      public static Locale getLocaleFromThreeLetterCode(@Nonnull 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