Class RFC3066LanguageHandler

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.regex.Pattern matcher
      Language tag is RFC3066-conformant if it matches this regex: [a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getKey()
      A unique key for this language handler to identify it in the LanguageHandlerRegistry.
      boolean isRecognizedLanguage​(java.lang.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.
      Literal normalizeLanguage​(java.lang.String literalValue, java.lang.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​(java.lang.String literalValue, java.lang.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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • matcher

        protected final java.util.regex.Pattern matcher
        Language tag is RFC3066-conformant if it matches this regex: [a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*
    • Constructor Detail

      • RFC3066LanguageHandler

        public RFC3066LanguageHandler()
        Default constructor.
    • Method Detail

      • verifyLanguage

        public boolean verifyLanguage​(java.lang.String literalValue,
                                      java.lang.String languageTag)
                               throws LiteralUtilException
        Description copied from interface: LanguageHandler
        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.

        This method must only be called after verifying that LanguageHandler.isRecognizedLanguage(String) returns true for the given language tag.

        Specified by:
        verifyLanguage in interface LanguageHandler
        Parameters:
        literalValue - Literal value matching the given language tag.
        languageTag - A language tag that matched with LanguageHandler.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​(java.lang.String literalValue,
                                         java.lang.String languageTag,
                                         ValueFactory valueFactory)
                                  throws LiteralUtilException
        Description copied from interface: LanguageHandler
        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.

        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.

        Specified by:
        normalizeLanguage in interface LanguageHandler
        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 using Literal.getLanguage().
        valueFactory - The ValueFactory to use to create the result literal.
        Returns:
        A Literal containing 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

        public java.lang.String getKey()
        Description copied from interface: LanguageHandler
        A unique key for this language handler to identify it in the LanguageHandlerRegistry.
        Specified by:
        getKey in interface LanguageHandler
        Returns:
        A unique string key.