Class XSDDatatype

All Implemented Interfaces:
Direct Known Subclasses:
XSDAbstractDateTimeType, XSDBaseNumericType, XSDBaseStringType, XSDbinary, XSDDatatype.XSDGenericType, XSDDouble, XSDFloat, XSDPlainType

public class XSDDatatype extends BaseDatatype
Representation of an XSD datatype based on the Xerces-2 XSD implementation.
  • Field Details

    • XSD

      public static final String XSD
      The xsd namespace
      See Also:
    • XSDfloat

      public static final XSDDatatype XSDfloat
      Datatype representing xsd:float
    • XSDdouble

      public static final XSDDatatype XSDdouble
      Datatype representing xsd:double
    • XSDint

      public static final XSDDatatype XSDint
      Datatype representing xsd:int
    • XSDlong

      public static final XSDDatatype XSDlong
      Datatype representing xsd:long
    • XSDshort

      public static final XSDDatatype XSDshort
      Datatype representing xsd:short
    • XSDbyte

      public static final XSDDatatype XSDbyte
      Datatype representing xsd:byte
    • XSDunsignedByte

      public static final XSDDatatype XSDunsignedByte
      Datatype representing xsd:unsignedByte
    • XSDunsignedShort

      public static final XSDDatatype XSDunsignedShort
      Datatype representing xsd:unsignedShort
    • XSDunsignedInt

      public static final XSDDatatype XSDunsignedInt
      Datatype representing xsd:unsignedInt
    • XSDunsignedLong

      public static final XSDDatatype XSDunsignedLong
      Datatype representing xsd:unsignedLong
    • XSDdecimal

      public static final XSDDatatype XSDdecimal
      Datatype representing xsd:decimal
    • XSDinteger

      public static final XSDDatatype XSDinteger
      Datatype representing xsd:integer
    • XSDnonPositiveInteger

      public static final XSDDatatype XSDnonPositiveInteger
      Datatype representing xsd:nonPositiveInteger
    • XSDnonNegativeInteger

      public static final XSDDatatype XSDnonNegativeInteger
      Datatype representing xsd:nonNegativeInteger
    • XSDpositiveInteger

      public static final XSDDatatype XSDpositiveInteger
      Datatype representing xsd:positiveInteger
    • XSDnegativeInteger

      public static final XSDDatatype XSDnegativeInteger
      Datatype representing xsd:negativeInteger
    • XSDboolean

      public static final XSDDatatype XSDboolean
      Datatype representing xsd:boolean
    • XSDstring

      public static final XSDDatatype XSDstring
      Datatype representing xsd:string
    • XSDnormalizedString

      public static final XSDDatatype XSDnormalizedString
      Datatype representing xsd:normalizedString
    • XSDanyURI

      public static final XSDDatatype XSDanyURI
      Datatype representing xsd:anyURI
    • XSDtoken

      public static final XSDDatatype XSDtoken
      Datatype representing xsd:token
    • XSDName

      public static final XSDDatatype XSDName
      Datatype representing xsd:Name
    • XSDQName

      public static final XSDDatatype XSDQName
      Datatype representing xsd:QName
    • XSDlanguage

      public static final XSDDatatype XSDlanguage
      Datatype representing xsd:language

      public static final XSDDatatype XSDNMTOKEN
      Datatype representing xsd:NMTOKEN

      public static final XSDDatatype XSDENTITY
      Datatype representing xsd:ENTITY
    • XSDID

      public static final XSDDatatype XSDID
      Datatype representing xsd:ID
    • XSDNCName

      public static final XSDDatatype XSDNCName
      Datatype representing xsd:NCName

      public static final XSDDatatype XSDIDREF
      Datatype representing xsd:IDREF

      public static final XSDDatatype XSDNOTATION
      Datatype representing xsd:NOTATION
    • XSDhexBinary

      public static final XSDDatatype XSDhexBinary
      Datatype representing xsd:hexBinary
    • XSDbase64Binary

      public static final XSDDatatype XSDbase64Binary
      Datatype representing xsd:base64Binary
    • XSDdate

      public static final XSDDatatype XSDdate
      Datatype representing xsd:date
    • XSDtime

      public static final XSDDatatype XSDtime
      Datatype representing xsd:time
    • XSDdateTime

      public static final XSDDatatype XSDdateTime
      Datatype representing xsd:dateTime
    • XSDdateTimeStamp

      public static final XSDDatatype XSDdateTimeStamp
      Datatype representing xsd:dateTimeStamp
    • XSDduration

      public static final XSDDatatype XSDduration
      Datatype representing xsd:duration
    • XSDdayTimeDuration

      public static final XSDDatatype XSDdayTimeDuration
      Datatype representing xsd:dayTimeDration
    • XSDyearMonthDuration

      public static final XSDDatatype XSDyearMonthDuration
      Datatype representing xsd:yearMonthDuration
    • XSDgDay

      public static final XSDDatatype XSDgDay
      Datatype representing xsd:gDay
    • XSDgMonth

      public static final XSDDatatype XSDgMonth
      Datatype representing xsd:gMonth
    • XSDgYear

      public static final XSDDatatype XSDgYear
      Datatype representing xsd:gYear
    • XSDgYearMonth

      public static final XSDDatatype XSDgYearMonth
      Datatype representing xsd:gYearMonth
    • XSDgMonthDay

      public static final XSDDatatype XSDgMonthDay
      Datatype representing xsd:gMonthDay
  • Constructor Details

    • XSDDatatype

      public XSDDatatype(String typeName)
      typeName - the name of the XSD type to be instantiated, this is used to lookup a type definition from the Xerces schema factory.
    • XSDDatatype

      public XSDDatatype(String typeName, Class<?> javaClass)
      typeName - the name of the XSD type to be instantiated, this is used to lookup a type definition from the Xerces schema factory.
      javaClass - the java class for which this xsd type is to be treated as the canonical representation
  • Method Details

    • parse

      public Object parse(String lexicalForm) throws DatatypeFormatException
      Parse a lexical form of this datatype to a value
      Specified by:
      parse in interface RDFDatatype
      parse in class BaseDatatype
      DatatypeFormatException - if the lexical form is not legal
    • unparse

      public String unparse(Object value)
      Convert a value of this datatype out to lexical form.
      Specified by:
      unparse in interface RDFDatatype
      unparse in class BaseDatatype
    • isEqual

      public boolean isEqual(LiteralLabel value1, LiteralLabel value2)
      Compares two instances of values of the given datatype.
      Specified by:
      isEqual in interface RDFDatatype
      isEqual in class BaseDatatype
    • getJavaClass

      public Class<?> getJavaClass()
      If this datatype is used as the cannonical representation for a particular java datatype then return that java type, otherwise returns null.
      Specified by:
      getJavaClass in interface RDFDatatype
      getJavaClass in class BaseDatatype
    • extendedTypeDefinition

      public Object extendedTypeDefinition()
      Returns the Xerces datatype representation for this type, this is an XSSimpleType, in fact an XSSimpleTypeDecl.
      Specified by:
      extendedTypeDefinition in interface RDFDatatype
      extendedTypeDefinition in class BaseDatatype
    • parseValidated

      public Object parseValidated(String lexical)
      Parse a validated lexical form. Subclasses which use the default parse implementation and are not convered by the explicit convertValidatedData cases should override this.
    • isValidLiteral

      public boolean isValidLiteral(LiteralLabel lit)
      Test whether the given LiteralLabel is a valid instance of this datatype. This takes into account typing information as well as lexical form - for example an xsd:string is never considered valid as an xsd:integer (even if it is lexically legal like "1").
      Specified by:
      isValidLiteral in interface RDFDatatype
      isValidLiteral in class BaseDatatype
    • isBaseTypeCompatible

      public boolean isBaseTypeCompatible(LiteralLabel lit)
      Test if the given typed value is in the right partition of the XSD type space. If this test passes then if the typed value has a legal lexical form for this type then it is a legal instance.
    • trimPlus

      public static String trimPlus(String str)
      Helper function to return the substring of a validated number string omitting any leading + sign.
    • loadXSDSimpleTypes

      public static void loadXSDSimpleTypes(TypeMapper tm)
      Add all of the XSD pre-defined simple types to the given type mapper registry.
    • main

      public static void main(String[] args)