Class RFC3066LanguageHandler
- All Implemented Interfaces:
LanguageHandler
This language handler normalises language tags to lower-case if
normalizeLanguage(String, String, ValueFactory) is used.
- Author:
- Peter Ansell
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final PatternLanguage tag is RFC3066-conformant if it matches this regex: [a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*Fields inherited from interface LanguageHandler
BCP47, RFC3066, RFC4646Modifier and TypeFieldDescriptionstatic final StringIdentifier for the language tag format defined by BCP47, which is referenced by the RDF-1.1 specification.static final StringIdentifier for the language tag format defined by RFC3066, which is referenced by the RDF-1.0 specification.static final StringIdentifier for the language tag format defined by RFC4646, which obsoletes RFC3066, but which is not referenced by the RDF specification. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetKey()A unique key for this language handler to identify it in the LanguageHandlerRegistry.booleanisRecognizedLanguage(String languageTag) Checks if the given language tag is recognized by this language handler, including cases where the language tag is considered syntactically well-formed, but is not yet normalized.normalizeLanguage(String literalValue, String languageTag, Literal.BaseDirection baseDir, 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.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.booleanverifyLanguage(String literalValue, String languageTag) Verifies that the language tag is syntactically well-formed, optionally including an automated check on the literal value being a match for the given tag.
-
Field Details
-
matcher
Language tag is RFC3066-conformant if it matches this regex: [a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*
-
-
Constructor Details
-
RFC3066LanguageHandler
public RFC3066LanguageHandler()Default constructor.
-
-
Method Details
-
isRecognizedLanguage
Description copied from interface:LanguageHandlerChecks if the given language tag is recognized by this language handler, including cases where the language tag is considered syntactically well-formed, but is not yet normalized.- Specified by:
isRecognizedLanguagein interfaceLanguageHandler- Parameters:
languageTag- The language tag to check.- Returns:
- True if the language tag is syntactically well-formed and could be used with
LanguageHandler.verifyLanguage(String, String)andLanguageHandler.normalizeLanguage(String, String, ValueFactory).
-
verifyLanguage
Description copied from interface:LanguageHandlerVerifies that the language tag is syntactically well-formed, optionally including an automated check on the literal value being a match for the given tag.This method must only be called after verifying that
LanguageHandler.isRecognizedLanguage(String)returns true for the given language tag.- Specified by:
verifyLanguagein interfaceLanguageHandler- Parameters:
literalValue- Literal value matching the given language tag.languageTag- A language tag that matched withLanguageHandler.isRecognizedLanguage(String).- Returns:
- True if the language tag is recognized by this language handler, and it is verified to be syntactically valid.
- Throws:
LiteralUtilException- If the language tag was not recognized.
-
normalizeLanguage
public Literal normalizeLanguage(String literalValue, String languageTag, ValueFactory valueFactory) throws LiteralUtilException Description copied from interface:LanguageHandlerNormalize 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.This method must only be called after verifying that
LanguageHandler.isRecognizedLanguage(String)returns true for the given language tag, andLanguageHandler.verifyLanguage(String, String)also returns true for the given language and literal value.- Specified by:
normalizeLanguagein interfaceLanguageHandler- Parameters:
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 usingLiteral.getLanguage().valueFactory- TheValueFactoryto use to create the result literal.- Returns:
- A
Literalcontaining the normalized literal value and language tag. - Throws:
LiteralUtilException- If the language tag was not recognized or verified, or the literal value could not be normalized due to an error.
-
normalizeLanguage
public Literal normalizeLanguage(String literalValue, String languageTag, Literal.BaseDirection baseDir, ValueFactory valueFactory) throws LiteralUtilException Description copied from interface:LanguageHandlerNormalize 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.This method must only be called after verifying that
LanguageHandler.isRecognizedLanguage(String)returns true for the given language tag, andLanguageHandler.verifyLanguage(String, String)also returns true for the given language and literal value.- Specified by:
normalizeLanguagein interfaceLanguageHandler- Parameters:
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 usingLiteral.getLanguage().baseDir-valueFactory- TheValueFactoryto use to create the result literal.- Returns:
- A
Literalcontaining the normalized literal value and language tag. - Throws:
LiteralUtilException- If the language tag was not recognized or verified, or the literal value could not be normalized due to an error.
-
getKey
Description copied from interface:LanguageHandlerA unique key for this language handler to identify it in the LanguageHandlerRegistry.- Specified by:
getKeyin interfaceLanguageHandler- Returns:
- A unique string key.
-