Package com.stardog.stark.io.datatypes

# Class XMLSchemaDatatypeHandler

java.lang.Object
com.stardog.stark.io.datatypes.XMLSchemaDatatypeHandler

All Implemented Interfaces:
  `DatatypeHandler`

public final class XMLSchemaDatatypeHandler extends Object implements DatatypeHandler
An implementation of a datatype handler that can process `XSD` datatypes.

Implemented using `XMLDatatypes`.

Since:
  1.0
Version:
  1.0
Author:
  Peter Ansell, Michael Grove

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `XMLSchemaDatatypeHandler()`
  Default constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `isRecognizedDatatype(IRI datatypeUri)`
  Checks if the given datatype `IRI` is recognized by this `DatatypeHandler`.
  `String`
  `key()`
  A unique key for this datatype handler to identify it in the
  `Literal`
  `normalizeDatatype(String theValue, Datatype theDatatype)`
  Normalize both the datatype and the literal value if appropriate, and generate a literal with the provided value and datatype.
  `boolean`
  `verifyDatatype(String theValue, Datatype theDatatype)`
  Verifies that the datatype is valid, including a check on the structure of the literal value.

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

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

- ## Constructor Details

  - ### XMLSchemaDatatypeHandler

    public XMLSchemaDatatypeHandler()
    Default constructor.

- ## Method Details

  - ### isRecognizedDatatype

    public boolean isRecognizedDatatype(@Nonnull IRI datatypeUri)
    Checks if the given datatype `IRI` is recognized by this `DatatypeHandler`.
    Specified by:
      `isRecognizedDatatype` in interface `DatatypeHandler`
    Parameters:
      `datatypeUri` - The datatype URI to check.
    Returns:
      `true` if the datatype is syntactically valid and could be used with `DatatypeHandler.verifyDatatype(String, Datatype)` and `DatatypeHandler.normalizeDatatype(String, Datatype)`.

  - ### verifyDatatype

    public boolean verifyDatatype(@Nonnull String theValue, @Nonnull Datatype theDatatype)
    Verifies that the datatype is valid, including a check on the structure of the literal value.

    This method must only be called after verifying that `DatatypeHandler.isRecognizedDatatype(IRI)` returns true for the given datatype URI.

    Specified by:
      `verifyDatatype` in interface `DatatypeHandler`
    Parameters:
      `theValue` - Literal value matching the given datatype URI.
      `theDatatype` - A datatype that matched with `DatatypeHandler.isRecognizedDatatype(IRI)`
    Returns:
      True if the datatype URI is recognized by this datatype handler, and it is verified to be syntactically valid. An implementation may throw `InvalidLiteral` exception if the datatype is not recognized

  - ### normalizeDatatype

    @Nonnull public Literal normalizeDatatype(@Nonnull String theValue, @Nonnull Datatype theDatatype) throws InvalidLiteral
    Normalize both the datatype and the literal value if appropriate, and generate a literal with the provided value and datatype. This method must only be called after verifying that `DatatypeHandler.isRecognizedDatatype(IRI)` returns true for the given datatype URI, and `DatatypeHandler.verifyDatatype(String, Datatype)` also returns true for the given datatype and literal value.
    Specified by:
      `normalizeDatatype` in interface `DatatypeHandler`
    Parameters:
      `theValue` - Required literal value to use in the normalization process and to provide the value for the resulting literal.
      `theDatatype` - The datatype which is to be normalized. It is available in normalized form from the result using `Literal.datatype()`.
    Returns:
      A `Literal` containing the normalized literal value and datatype URI. An implementation may throw `InvalidLiteral` exception if the datatype is not recognized or cannot be normalized for any reason, e.g. its value is not legal for its datatype.
    Throws:
      `InvalidLiteral`

  - ### key

    public String key()
    A unique key for this datatype handler to identify it in the
    Specified by:
      `key` in interface `DatatypeHandler`
    Returns:
      A unique string key.