Package com.stardog.stark.io.language

# Class RFC3066LanguageHandler

java.lang.Object
com.stardog.stark.io.language.RFC3066LanguageHandler

All Implemented Interfaces:
  `LanguageHandler`

public final class RFC3066LanguageHandler extends Object implements LanguageHandler
A language handler that can verify RFC3066 formatted language tags.

This language handler normalises language tags to lower-case if `normalizeLanguage(String, String)` is used.

Author:
  Peter Ansell
See Also:
  - RFC 3066

- ## Field Summary

  ### Fields inherited from interface com.stardog.stark.io.LanguageHandler

  `BCP47, RFC3066, RFC4646`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RFC3066LanguageHandler()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `isRecognizedLanguage(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.
  `String`
  `key()`
  A unique key for this language handler
  `Literal`
  `normalizeLanguage(String theValue, String theLang)`
  Normalize both the language tag and the language if appropriate.
  `String`
  `normalizeLanguageTag(String theLang)`
  Normalize the language tag.
  `boolean`
  `verifyLanguage(String theValue, String theLang)`
  Verifies that the language tag is valid, optionally including an automated check on the literal value.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### RFC3066LanguageHandler

    public RFC3066LanguageHandler()

- ## Method Details

  - ### isRecognizedLanguage

    public boolean isRecognizedLanguage(@Nonnull 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 interface `LanguageHandler`
    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)` and `LanguageHandler.normalizeLanguage(String, String)`.

  - ### verifyLanguage

    public boolean verifyLanguage(@Nonnull String theValue, @Nonnull 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 interface `LanguageHandler`
    Parameters:
      `theValue` - Literal value matching the given language tag.
      `theLang` - 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:
      `InvalidLiteral` - If the language tag was not recognized.

  - ### normalizeLanguage

    @Nonnull public Literal normalizeLanguage(@Nonnull String theValue, @Nonnull 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, and `LanguageHandler.verifyLanguage(String, String)` also returns true for the given language and literal value.

    Specified by:
      `normalizeLanguage` in interface `LanguageHandler`
    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 using `Literal.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 String normalizeLanguageTag(@Nonnull String theLang)
    Description copied from interface: `LanguageHandler`
    Normalize the language tag. This function _may_ work even if the language tag is invalid. Use `LanguageHandler.verifyLanguage(String, String)` to ensure the language is valid.
    Specified by:
      `normalizeLanguageTag` in interface `LanguageHandler`
    Parameters:
      `theLang` - The language tag which is to be normalized.
    Returns:
      A normalized language tag.

  - ### key

    @Nonnull public String key()
    A unique key for this language handler
    Specified by:
      `key` in interface `LanguageHandler`
    Returns:
      A unique `String` key.