Package org.apache.jena.datatypes.xsd
Class XSDDatatype
- java.lang.Object
-
- org.apache.jena.datatypes.BaseDatatype
-
- org.apache.jena.datatypes.xsd.XSDDatatype
-
- All Implemented Interfaces:
RDFDatatype
- 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
XSDDatatype.XSDGenericType
Generic XML Schema datatype (outside the xsd: namespace)-
Nested classes/interfaces inherited from class org.apache.jena.datatypes.BaseDatatype
BaseDatatype.TypedValue
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
XSD
The xsd namespacestatic XSDDatatype
XSDanyURI
Datatype representing xsd:anyURIstatic XSDDatatype
XSDbase64Binary
Datatype representing xsd:base64Binarystatic XSDDatatype
XSDboolean
Datatype representing xsd:booleanstatic XSDDatatype
XSDbyte
Datatype representing xsd:bytestatic XSDDatatype
XSDdate
Datatype representing xsd:datestatic XSDDatatype
XSDdateTime
Datatype representing xsd:dateTimestatic XSDDatatype
XSDdateTimeStamp
Datatype representing xsd:dateTimeStampstatic XSDDatatype
XSDdayTimeDuration
Datatype representing xsd:dayTimeDrationstatic XSDDatatype
XSDdecimal
Datatype representing xsd:decimalstatic XSDDatatype
XSDdouble
Datatype representing xsd:doublestatic XSDDatatype
XSDduration
Datatype representing xsd:durationstatic XSDDatatype
XSDENTITY
Datatype representing xsd:ENTITYstatic XSDDatatype
XSDfloat
Datatype representing xsd:floatstatic XSDDatatype
XSDgDay
Datatype representing xsd:gDaystatic XSDDatatype
XSDgMonth
Datatype representing xsd:gMonthstatic XSDDatatype
XSDgMonthDay
Datatype representing xsd:gMonthDaystatic XSDDatatype
XSDgYear
Datatype representing xsd:gYearstatic XSDDatatype
XSDgYearMonth
Datatype representing xsd:gYearMonthstatic XSDDatatype
XSDhexBinary
Datatype representing xsd:hexBinarystatic XSDDatatype
XSDID
Datatype representing xsd:IDstatic XSDDatatype
XSDIDREF
Datatype representing xsd:IDREFstatic XSDDatatype
XSDint
Datatype representing xsd:intstatic XSDDatatype
XSDinteger
Datatype representing xsd:integerstatic XSDDatatype
XSDlanguage
Datatype representing xsd:languagestatic XSDDatatype
XSDlong
Datatype representing xsd:longstatic XSDDatatype
XSDName
Datatype representing xsd:Namestatic XSDDatatype
XSDNCName
Datatype representing xsd:NCNamestatic XSDDatatype
XSDnegativeInteger
Datatype representing xsd:negativeIntegerstatic XSDDatatype
XSDNMTOKEN
Datatype representing xsd:NMTOKENstatic XSDDatatype
XSDnonNegativeInteger
Datatype representing xsd:nonNegativeIntegerstatic XSDDatatype
XSDnonPositiveInteger
Datatype representing xsd:nonPositiveIntegerstatic XSDDatatype
XSDnormalizedString
Datatype representing xsd:normalizedStringstatic XSDDatatype
XSDNOTATION
Datatype representing xsd:NOTATIONstatic XSDDatatype
XSDpositiveInteger
Datatype representing xsd:positiveIntegerstatic XSDDatatype
XSDQName
Datatype representing xsd:QNamestatic XSDDatatype
XSDshort
Datatype representing xsd:shortstatic XSDDatatype
XSDstring
Datatype representing xsd:stringstatic XSDDatatype
XSDtime
Datatype representing xsd:timestatic XSDDatatype
XSDtoken
Datatype representing xsd:tokenstatic XSDDatatype
XSDunsignedByte
Datatype representing xsd:unsignedBytestatic XSDDatatype
XSDunsignedInt
Datatype representing xsd:unsignedIntstatic XSDDatatype
XSDunsignedLong
Datatype representing xsd:unsignedLongstatic XSDDatatype
XSDunsignedShort
Datatype representing xsd:unsignedShortstatic XSDDatatype
XSDyearMonthDuration
Datatype representing xsd:yearMonthDuration
-
Constructor Summary
Constructors Constructor Description XSDDatatype(java.lang.String typeName)
Constructor.XSDDatatype(java.lang.String typeName, java.lang.Class<?> javaClass)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
extendedTypeDefinition()
Returns the Xerces datatype representation for this type, this is an XSSimpleType, in fact an XSSimpleTypeDecl.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(LiteralLabel lit)
Test if the given typed value is in the right partition of the XSD type space.boolean
isEqual(LiteralLabel value1, LiteralLabel value2)
Compares two instances of values of the given datatype.boolean
isValidLiteral(LiteralLabel lit)
Test whether the given LiteralLabel is a valid instance of this datatype.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 valuejava.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 org.apache.jena.datatypes.BaseDatatype
cannonicalise, getHashCode, getURI, isValid, isValidValue, langTagCompatible, normalizeSubType, toString
-
-
-
-
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
-
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 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 canonical representation
-
-
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 interfaceRDFDatatype
- Overrides:
parse
in classBaseDatatype
- 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 interfaceRDFDatatype
- Overrides:
unparse
in classBaseDatatype
-
isEqual
public boolean isEqual(LiteralLabel value1, LiteralLabel value2)
Compares two instances of values of the given datatype.- Specified by:
isEqual
in interfaceRDFDatatype
- Overrides:
isEqual
in classBaseDatatype
-
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 interfaceRDFDatatype
- Overrides:
getJavaClass
in classBaseDatatype
-
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 interfaceRDFDatatype
- Overrides:
extendedTypeDefinition
in classBaseDatatype
-
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(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 interfaceRDFDatatype
- Overrides:
isValidLiteral
in classBaseDatatype
-
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 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)
-
-