Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.hp.hpl.jena.datatypes.xsd
Class XSDDatatype

    java.lang.Object
      com.hp.hpl.jena.datatypes.BaseDatatype
          com.hp.hpl.jena.datatypes.xsd.XSDDatatype

All Implemented Interfaces:
  RDFDatatype

Direct Known Subclasses:
  XSDbase64Binary, XSDhexBinary

    public class XSDDatatype

extends BaseDatatype

Representation of an XSD datatype based on the Xerces-2 XSD implementation.

Version:
  $Revision: 1.16 $ on $Date: 2008/03/01 18:06:49 $
Author:
  Dave Reynolds

Nested Class Summary

Nested classes/interfaces inherited from class com.hp.hpl.jena.datatypes.BaseDatatype
`BaseDatatype.TypedValue`

Field Summary
`static java.lang.String` | `XSD` The xsd namespace
`static XSDDatatype` | `XSDanyURI` Datatype representing xsd:anyURI
`static XSDDatatype` | `XSDbase64Binary` Datatype representing xsd:base64Binary
`static XSDDatatype` | `XSDboolean` Datatype representing xsd:boolean
`static XSDDatatype` | `XSDbyte` Datatype representing xsd:byte
`static XSDDatatype` | `XSDdate` Datatype representing xsd:date
`static XSDDatatype` | `XSDdateTime` Datatype representing xsd:dateTime
`static XSDDatatype` | `XSDdecimal` Datatype representing xsd:decimal
`static XSDDatatype` | `XSDdouble` Datatype representing xsd:double
`static XSDDatatype` | `XSDduration` Datatype representing xsd:duration
`static XSDDatatype` | `XSDENTITY` Datatype representing xsd:ENTITY
`static XSDDatatype` | `XSDfloat` Datatype representing xsd:float
`static XSDDatatype` | `XSDgDay` Datatype representing xsd:gDay
`static XSDDatatype` | `XSDgMonth` Datatype representing xsd:gMonth
`static XSDDatatype` | `XSDgMonthDay` Datatype representing xsd:gMonthDay
`static XSDDatatype` | `XSDgYear` Datatype representing xsd:gYear
`static XSDDatatype` | `XSDgYearMonth` Datatype representing xsd:gYearMonth
`static XSDDatatype` | `XSDhexBinary` Datatype representing xsd:hexBinary
`static XSDDatatype` | `XSDID` Datatype representing xsd:ID
`static XSDDatatype` | `XSDIDREF` Datatype representing xsd:IDREF
`static XSDDatatype` | `XSDint` Datatype representing xsd:int
`static XSDDatatype` | `XSDinteger` Datatype representing xsd:integer
`static XSDDatatype` | `XSDlanguage` Datatype representing xsd:language
`static XSDDatatype` | `XSDlong` Datatype representing xsd:long
`static XSDDatatype` | `XSDName` Datatype representing xsd:Name
`static XSDDatatype` | `XSDNCName` Datatype representing xsd:NCName
`static XSDDatatype` | `XSDnegativeInteger` Datatype representing xsd:negativeInteger
`static XSDDatatype` | `XSDNMTOKEN` Datatype representing xsd:NMTOKEN
`static XSDDatatype` | `XSDnonNegativeInteger` Datatype representing xsd:nonNegativeInteger
`static XSDDatatype` | `XSDnonPositiveInteger` Datatype representing xsd:nonPositiveInteger
`static XSDDatatype` | `XSDnormalizedString` Datatype representing xsd:normalizedString
`static XSDDatatype` | `XSDNOTATION` Datatype representing xsd:NOTATION
`static XSDDatatype` | `XSDpositiveInteger` Datatype representing xsd:positiveInteger
`static XSDDatatype` | `XSDQName` Datatype representing xsd:QName
`static XSDDatatype` | `XSDshort` Datatype representing xsd:short
`static XSDDatatype` | `XSDstring` Datatype representing xsd:string
`static XSDDatatype` | `XSDtime` Datatype representing xsd:time
`static XSDDatatype` | `XSDtoken` Datatype representing xsd:token
`static XSDDatatype` | `XSDunsignedByte` Datatype representing xsd:unsignedByte
`static XSDDatatype` | `XSDunsignedInt` Datatype representing xsd:unsignedInt
`static XSDDatatype` | `XSDunsignedLong` Datatype representing xsd:unsignedLong
`static XSDDatatype` | `XSDunsignedShort` Datatype representing xsd:unsignedShort

Constructor Summary
`XSDDatatype(java.lang.String typeName)` Constructor.
`XSDDatatype(java.lang.String typeName, java.lang.Class javaClass)` Constructor.
`XSDDatatype(org.apache.xerces.impl.dv.XSSimpleType xstype, java.lang.String namespace)` Constructor used when loading in external user defined XSD types - should only be used by the internals but public scope because the internals spread across multiple packages.

Method Summary
`java.lang.Object` | `convertValidatedDataValue(org.apache.xerces.impl.dv.ValidatedInfo validatedInfo)` Convert a validated xerces data value into the corresponding java data value.
`java.lang.Object` | `extendedTypeDefinition()` Returns the Xerces datatype representation for this type, this is an XSSimpleType, in fact an XSSimpleTypeDecl.
`int` | `getHashCode(byte[] bytes)`
`java.lang.Class` | `getJavaClass()` If this datatype is used as the cannonical representation for a particular java datatype then return that java type, otherwise returns null.
`boolean` | `isBaseTypeCompatible(com.hp.hpl.jena.graph.impl.LiteralLabel lit)` Test if the given typed value is in the right partition of the XSD type space.
`boolean` | `isEqual(com.hp.hpl.jena.graph.impl.LiteralLabel value1, com.hp.hpl.jena.graph.impl.LiteralLabel value2)` Compares two instances of values of the given datatype.
`boolean` | `isValidLiteral(com.hp.hpl.jena.graph.impl.LiteralLabel lit)` Test whether the given LiteralLabel is a valid instance of this datatype.
`static java.util.List` | `loadUserDefined(java.lang.String uri, java.io.Reader reader, java.lang.String encoding, TypeMapper tm)` Create and register a set of types specified in a user schema file.
`static java.util.List` | `loadUserDefined(java.lang.String uri, java.lang.String encoding, TypeMapper tm)` Create and register a set of types specified in a user schema file.
`static void` | `loadXSDSimpleTypes(TypeMapper tm)` Add all of the XSD pre-defined simple types to the given type mapper registry.
`static void` | `main(java.lang.String[] args)`
`java.lang.Object` | `parse(java.lang.String lexicalForm)` Parse a lexical form of this datatype to a value
`java.lang.Object` | `parseValidated(java.lang.String lexical)` Parse a validated lexical form.
`static java.lang.String` | `trimPlus(java.lang.String str)` Helper function to return the substring of a validated number string omitting any leading + sign.
`java.lang.String` | `unparse(java.lang.Object value)` Convert a value of this datatype out to lexical form.

Methods inherited from class com.hp.hpl.jena.datatypes.BaseDatatype
`cannonicalise, getHashCode, getURI, isValid, isValidValue, langTagCompatible, normalizeSubType, toString`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### XSD

    public static final java.lang.String XSD

  The xsd namespace

  See Also:
    Constant Field Values

### 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

### XSDNMTOKEN

    public static final XSDDatatype XSDNMTOKEN

  Datatype representing xsd:NMTOKEN

### XSDENTITY

    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

### XSDIDREF

    public static final XSDDatatype XSDIDREF

  Datatype representing xsd:IDREF

### XSDNOTATION

    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

### XSDduration

    public static final XSDDatatype XSDduration

  Datatype representing xsd:duration

### 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 Detail

### XSDDatatype

    public XSDDatatype(java.lang.String typeName)

  Constructor.

  Parameters:
    `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(java.lang.String typeName,
                       java.lang.Class javaClass)

  Constructor.

  Parameters:
    `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 cannonical representation

### XSDDatatype

    public XSDDatatype(org.apache.xerces.impl.dv.XSSimpleType xstype,
                       java.lang.String namespace)

  Constructor used when loading in external user defined XSD types - should only be used by the internals but public scope because the internals spread across multiple packages.

  Parameters:
    `xstype` - the XSSimpleType definition to be wrapped
    `namespace` - the namespace for the type (used because the grammar loading doesn't seem to keep that)

Method Detail

### parse

    public java.lang.Object parse(java.lang.String lexicalForm)
                           throws DatatypeFormatException

  Parse a lexical form of this datatype to a value

  Specified by:
    `parse` in interface `RDFDatatype`
  Overrides:
    `parse` in class `BaseDatatype`
  Throws:
    `DatatypeFormatException` - if the lexical form is not legal

### unparse

    public java.lang.String unparse(java.lang.Object value)

  Convert a value of this datatype out to lexical form.

  Specified by:
    `unparse` in interface `RDFDatatype`
  Overrides:
    `unparse` in class `BaseDatatype`

### isEqual

    public boolean isEqual(com.hp.hpl.jena.graph.impl.LiteralLabel value1,
                           com.hp.hpl.jena.graph.impl.LiteralLabel value2)

  Compares two instances of values of the given datatype. This ignores lang tags and defers to the equality function defined by the Xerces package - to be checked.

  Specified by:
    `isEqual` in interface `RDFDatatype`
  Overrides:
    `isEqual` in class `BaseDatatype`

### getJavaClass

    public java.lang.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`
  Overrides:
    `getJavaClass` in class `BaseDatatype`

### extendedTypeDefinition

    public java.lang.Object extendedTypeDefinition()

  Returns the Xerces datatype representation for this type, this is an XSSimpleType, in fact an XSSimpleTypeDecl.

  Specified by:
    `extendedTypeDefinition` in interface `RDFDatatype`
  Overrides:
    `extendedTypeDefinition` in class `BaseDatatype`

### loadUserDefined

    public static java.util.List loadUserDefined(java.lang.String uri,
                                                 java.io.Reader reader,
                                                 java.lang.String encoding,
                                                 TypeMapper tm)
                                          throws DatatypeFormatException

  Create and register a set of types specified in a user schema file. We use the (illegal) DAML+OIL approach that the uriref of the type is the url of the schema file with fragment ID corresponding the the name of the type.

  Parameters:
    `uri` - the absolute uri of the schema file to be loaded
    `reader` - the Reader stream onto the file (useful if you wish to load a cached copy of the schema file)
    `encoding` - the encoding of the source file (can be null)
    `tm` - the type mapper into which to load the definitions
  Returns:
    a List of strings giving the uri's of the newly defined datatypes
  Throws:
    `DatatypeFormatException` - if there is a problem during load (not that we use Xerces in default mode for load which may provide diagnostic output direct to stderr)

### loadUserDefined

    public static java.util.List loadUserDefined(java.lang.String uri,
                                                 java.lang.String encoding,
                                                 TypeMapper tm)
                                          throws DatatypeFormatException

  Create and register a set of types specified in a user schema file. We use the (illegal) DAML+OIL approach that the uriref of the type is the url of the schema file with fragment ID corresponding the the name of the type.

  Parameters:
    `uri` - the absolute uri of the schema file to be loaded, this should be a resolvable URL
    `encoding` - the encoding of the source file (can be null)
    `tm` - the type mapper into which to load the definitions
  Returns:
    a List of strings giving the uri's of the newly defined datatypes
  Throws:
    `DatatypeFormatException` - if there is a problem during load (not that we use Xerces in default mode for load which may provide diagnostic output direct to stderr)

### convertValidatedDataValue

    public java.lang.Object convertValidatedDataValue(org.apache.xerces.impl.dv.ValidatedInfo validatedInfo)
                                               throws DatatypeFormatException

  Convert a validated xerces data value into the corresponding java data value. This function is currently the most blatently xerces-version dependent part of this subsystem. In many cases it also involves reparsing data which has already been parsed as part of the validation.

  Parameters:
    `validatedInfo` - a fully populated Xerces data validation context
  Returns:
    the appropriate java wrapper type
  Throws:
    `DatatypeFormatException`

### parseValidated

    public java.lang.Object parseValidated(java.lang.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(com.hp.hpl.jena.graph.impl.LiteralLabel lit)

  Test whether the given LiteralLabel is a valid instance of this datatype. This takes into accound 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`
  Overrides:
    `isValidLiteral` in class `BaseDatatype`

### isBaseTypeCompatible

    public boolean isBaseTypeCompatible(com.hp.hpl.jena.graph.impl.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 java.lang.String trimPlus(java.lang.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(java.lang.String[] args)

### getHashCode

    public int getHashCode(byte[] bytes)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP