Package com.apicatalog.jsonld.lang
Class LanguageTag
- java.lang.Object
-
- com.apicatalog.jsonld.lang.LanguageTag
-
public final class LanguageTag extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLanguageTag.Extension
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddExtension(LanguageTag.Extension extension)protected voidaddLanguageExtension(String languageExtension)protected voidaddPrivateUse(String privateTag)protected voidaddVariant(String variant)static LanguageTagcreate(String languageTag)Creates a language tag by parsing the given string as defined by RFC 5646.booleanequals(Object obj)Collection<LanguageTag.Extension>getExtensions()Collection of extension sub-tags.StringgetLanguage()Language as shortest ISO 639 code or reserved code for future use or registered language subtag code.Collection<String>getLanguageExtensions()Collection of ISO 639 codes.Collection<String>getPrivateUse()Collection of private sub-tags.StringgetRegion()Region as ISO 3166-1 or UN M.49 codeStringgetScript()Script as ISO 15924 code.Collection<String>getVariants()Collection of registered variant codes.inthashCode()static booleanisWellFormed(String languageTag)Language tags are used to help identify languages and are defined byRFC 5646protected voidsetLanguage(String language)protected voidsetRegion(String region)protected voidsetScript(String script)StringtoString()
-
-
-
Method Detail
-
isWellFormed
public static boolean isWellFormed(String languageTag)
Language tags are used to help identify languages and are defined byRFC 5646- Parameters:
languageTag- to check- Returns:
trueif the provided value is well-formed language tag- See Also:
- RFC 5643 - 2.1 Syntax
-
create
public static LanguageTag create(String languageTag)
Creates a language tag by parsing the given string as defined by RFC 5646.- Parameters:
languageTag- the string to be parsed into a language tag- Returns:
- The new language tag
- Throws:
IllegalArgumentException- if the given string is not well-formed
-
getLanguage
public String getLanguage()
Language as shortest ISO 639 code or reserved code for future use or registered language subtag code.- Returns:
- the language code
-
getLanguageExtensions
public Collection<String> getLanguageExtensions()
Collection of ISO 639 codes.- Returns:
- the extension codes
-
getScript
public String getScript()
Script as ISO 15924 code.- Returns:
- the script name code
-
getRegion
public String getRegion()
Region as ISO 3166-1 or UN M.49 code- Returns:
- the region code
-
getVariants
public Collection<String> getVariants()
Collection of registered variant codes.- Returns:
- the variant codes
-
getExtensions
public Collection<LanguageTag.Extension> getExtensions()
Collection of extension sub-tags.- Returns:
- a collection of sub-tags
-
getPrivateUse
public Collection<String> getPrivateUse()
Collection of private sub-tags.- Returns:
- a collection of private sub-tags
-
setLanguage
protected void setLanguage(String language)
-
addLanguageExtension
protected void addLanguageExtension(String languageExtension)
-
setScript
protected void setScript(String script)
-
setRegion
protected void setRegion(String region)
-
addVariant
protected void addVariant(String variant)
-
addExtension
protected void addExtension(LanguageTag.Extension extension)
-
addPrivateUse
protected void addPrivateUse(String privateTag)
-
-