public class RFC3066LanguageHandler extends Object implements LanguageHandler
This language handler normalises language tags to lower-case if
normalizeLanguage(String, String, ValueFactory)
is used.
Modifier and Type | Field and Description |
---|---|
protected Pattern |
matcher
Language tag is RFC3066-conformant if it matches this regex: [a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*
|
BCP47, RFC3066, RFC4646
Constructor and Description |
---|
RFC3066LanguageHandler()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
String |
getKey()
A unique key for this language handler to identify it in the LanguageHandlerRegistry.
|
boolean |
isRecognizedLanguage(String languageTag)
Checks if the given language tag is recognized by this language handler, including cases where the language tag
is recognized, but is not yet normalized.
|
Literal |
normalizeLanguage(String literalValue,
String languageTag,
ValueFactory valueFactory)
Normalize both the language tag and the language if appropriate, and use the given value factory to generate a
literal matching the literal value and language tag.
|
boolean |
verifyLanguage(String literalValue,
String languageTag)
Verifies that the language tag is valid, optionally including an automated check on the literal value.
|
protected final Pattern matcher
public boolean isRecognizedLanguage(String languageTag)
LanguageHandler
isRecognizedLanguage
in interface LanguageHandler
languageTag
- The language tag to check.LanguageHandler.verifyLanguage(String, String)
and LanguageHandler.normalizeLanguage(String, String, ValueFactory)
.public boolean verifyLanguage(String literalValue, String languageTag) throws LiteralUtilException
LanguageHandler
This method must only be called after verifying that LanguageHandler.isRecognizedLanguage(String)
returns true for the
given language tag.
verifyLanguage
in interface LanguageHandler
literalValue
- Literal value matching the given language tag.languageTag
- A language tag that matched with LanguageHandler.isRecognizedLanguage(String)
.LiteralUtilException
- If the language tag was not recognized.public Literal normalizeLanguage(String literalValue, String languageTag, ValueFactory valueFactory) throws LiteralUtilException
LanguageHandler
This method must only be called after verifying that LanguageHandler.isRecognizedLanguage(String)
returns true for the
given language tag, and LanguageHandler.verifyLanguage(String, String)
also returns true for the given language and
literal value.
normalizeLanguage
in interface LanguageHandler
literalValue
- Required literal value to use in the normalization process and to provide the value for the
resulting literal.languageTag
- The language tag which is to be normalized. This tag is available in normalized form from the
result using Literal.getLanguage()
.valueFactory
- The ValueFactory
to use to create the result literal.Literal
containing the normalized literal value and language tag.LiteralUtilException
- If the language tag was not recognized or verified, or the literal value could not
be normalized due to an error.public String getKey()
LanguageHandler
getKey
in interface LanguageHandler
Copyright © 2015-2020 Eclipse Foundation. All Rights Reserved.