Package com.complexible.common.rdf.rio
Class LowercaseBCP47LanguageHandler
- java.lang.Object
-
- com.complexible.common.rdf.rio.LowercaseBCP47LanguageHandler
-
- All Implemented Interfaces:
LanguageHandler
public final class LowercaseBCP47LanguageHandler extends java.lang.Object implements LanguageHandler
- Author:
- Evren Sirin
-
-
Field Summary
Fields Modifier and Type Field Description static BCP47LanguageHandler
BCP47
static LanguageHandler
INSTANCE
-
Fields inherited from interface com.stardog.stark.io.LanguageHandler
RFC3066, RFC4646
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isRecognizedLanguage(java.lang.String theLang)
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.java.lang.String
key()
A unique key for this language handlerLiteral
normalizeLanguage(java.lang.String theValue, java.lang.String theLang)
Normalize both the language tag and the language if appropriate.java.lang.String
normalizeLanguageTag(java.lang.String theLang)
Normalize the language tag.boolean
verifyLanguage(java.lang.String theValue, java.lang.String theLang)
Verifies that the language tag is valid, optionally including an automated check on the literal value.
-
-
-
Field Detail
-
INSTANCE
public static final LanguageHandler INSTANCE
-
BCP47
public static final BCP47LanguageHandler BCP47
-
-
Method Detail
-
isRecognizedLanguage
public boolean isRecognizedLanguage(@Nonnull java.lang.String theLang)
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.- Specified by:
isRecognizedLanguage
in interfaceLanguageHandler
- Parameters:
theLang
- The language tag to check.- Returns:
- True if the language tag is syntactically valid and could be used with
LanguageHandler.verifyLanguage(String, String)
andLanguageHandler.normalizeLanguage(String, String)
.
-
verifyLanguage
public boolean verifyLanguage(@Nonnull java.lang.String theValue, @Nonnull java.lang.String theLang) throws InvalidLiteral
Verifies that the language tag is valid, optionally including an automated check on the literal value.This method must only be called after verifying that
LanguageHandler.isRecognizedLanguage(String)
returns true for the given language tag.- Specified by:
verifyLanguage
in interfaceLanguageHandler
- Parameters:
theValue
- Literal value matching the given language tag.theLang
- 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:
InvalidLiteral
- If the language tag was not recognized.
-
normalizeLanguage
@Nonnull public Literal normalizeLanguage(@Nonnull java.lang.String theValue, @Nonnull java.lang.String theLang) throws InvalidLiteral
Normalize both the language tag and the language if appropriate.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:
normalizeLanguage
in interfaceLanguageHandler
- Parameters:
theValue
- Required literal value to use in the normalization process and to provide the value for the resulting literal.theLang
- The language tag which is to be normalized. This tag is available in normalized form from the result usingLiteral.lang()
.- Returns:
- A
Literal
containing the normalized literal value and language tag. - Throws:
InvalidLiteral
- If the language tag was not recognized or verified, or the literal value could not be normalized due to an error.
-
normalizeLanguageTag
@Nonnull public java.lang.String normalizeLanguageTag(@Nonnull java.lang.String theLang) throws InvalidLiteral
Description copied from interface:LanguageHandler
Normalize the language tag. This function _may_ work even if the language tag is invalid. UseLanguageHandler.verifyLanguage(String, String)
to ensure the language is valid.- Specified by:
normalizeLanguageTag
in interfaceLanguageHandler
- Parameters:
theLang
- The language tag which is to be normalized.- Returns:
- A normalized language tag.
- Throws:
InvalidLiteral
-
key
@Nonnull public java.lang.String key()
A unique key for this language handler- Specified by:
key
in interfaceLanguageHandler
- Returns:
- A unique `String` key.
-
-