Package com.yetanalytics.xapi.model
Class LangTag
- java.lang.Object
-
- com.yetanalytics.xapi.model.LangTag
-
public class LangTag extends Object
Class representation of RFC 5646 Language Tags allowing for retrieval of both the original String and the corresponding Locale.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object langTag)
Checks that this LangTag is equal to the langTag based on the orignal String (NOT the Locale).int
hashCode()
Hashes the LangTag based on its original String value (NOT the Locale).static LangTag
parse(String langTag)
Static method to create a LangTag instance from the langTag string.Locale
toLocale()
Returns the java.util.Locale instance corresponding to the LangTag.String
toString()
Returns the original String version of the LangTag.
-
-
-
Constructor Detail
-
LangTag
public LangTag(String langTagStr) throws IllformedLocaleException
This constructor takes a RFC 5646 formatted String and converts it to a LangTag object consisting of a java.util.Locale object and the original String.- Parameters:
langTagStr
- The language tag String from an xAPI Statement language map.- Throws:
IllformedLocaleException
- when the String is not a valid language tag.
-
-
Method Detail
-
parse
public static LangTag parse(String langTag) throws IllformedLocaleException
Static method to create a LangTag instance from the langTag string.- Parameters:
langTag
- - The String language tag.- Returns:
- The new LangTag instance.
- Throws:
IllformedLocaleException
- when the String is not a valid language tag.- See Also:
Locale.forLanguageTag(String str)
-
toString
public String toString()
Returns the original String version of the LangTag.
-
toLocale
public Locale toLocale()
Returns the java.util.Locale instance corresponding to the LangTag.- Returns:
- The Locale.
-
equals
public boolean equals(Object langTag)
Checks that this LangTag is equal to the langTag based on the orignal String (NOT the Locale).
-
-