Package org.apache.jena.datatypes
Interface RDFDatatype
-
- All Known Implementing Classes:
AdhocDatatype
,BaseDatatype
,FunctorDatatype
,RDFhtml
,RDFjson
,RDFLangString
,XMLLiteralType
,XSDAbstractDateTimeType
,XSDbase64Binary
,XSDBaseNumericType
,XSDBaseStringType
,XSDbinary
,XSDByteType
,XSDDatatype
,XSDDatatype.XSDGenericType
,XSDDateTimeStampType
,XSDDateTimeType
,XSDDateType
,XSDDayTimeDurationType
,XSDDayType
,XSDDouble
,XSDDurationType
,XSDFloat
,XSDhexBinary
,XSDMonthDayType
,XSDMonthType
,XSDPlainType
,XSDTimeType
,XSDYearMonthDurationType
,XSDYearMonthType
,XSDYearType
public interface RDFDatatype
Interface on a datatype representation. An instance of this interface is needed to convert typed literals between lexical and value forms.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.Object
cannonicalise(java.lang.Object value)
Cannonicalise a java Object value to a normal form.java.lang.Object
extendedTypeDefinition()
Returns an object giving more details on the datatype.int
getHashCode(LiteralLabel lit)
Gets the hash code of a given value.java.lang.Class<?>
getJavaClass()
If this datatype is used as the canonical representation for a particular java datatype then return that java type, otherwise returns null.java.lang.String
getURI()
Return the URI which is the label for this datatypeboolean
isEqual(LiteralLabel value1, LiteralLabel value2)
Compares two instances of values of the given datatype.boolean
isValid(java.lang.String lexicalForm)
Test whether the given string is a legal lexical form of this datatype.boolean
isValidLiteral(LiteralLabel lit)
Test whether the given LiteralLabel is a valid instance of this datatype.boolean
isValidValue(java.lang.Object valueForm)
Test whether the given object is a legal value form of this datatype.RDFDatatype
normalizeSubType(java.lang.Object value, RDFDatatype dt)
Normalization.java.lang.Object
parse(java.lang.String lexicalForm)
Parse a lexical form of this datatype to a valuejava.lang.String
unparse(java.lang.Object value)
Convert a value of this datatype out to lexical form.
-
-
-
Method Detail
-
getURI
java.lang.String getURI()
Return the URI which is the label for this datatype
-
unparse
java.lang.String unparse(java.lang.Object value)
Convert a value of this datatype out to lexical form.
-
parse
java.lang.Object parse(java.lang.String lexicalForm) throws DatatypeFormatException
Parse a lexical form of this datatype to a value- Throws:
DatatypeFormatException
- if the lexical form is not legal
-
isValid
boolean isValid(java.lang.String lexicalForm)
Test whether the given string is a legal lexical form of this datatype.
-
isValidValue
boolean isValidValue(java.lang.Object valueForm)
Test whether the given object is a legal value form of this datatype.
-
isValidLiteral
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").
-
isEqual
boolean isEqual(LiteralLabel value1, LiteralLabel value2)
Compares two instances of values of the given datatype. This defaults to just testing equality of the java value representation but datatypes can override this. We pass the entire LiteralLabel to allow the equality function to take the xml:lang tag and the datatype itself into account.
-
getHashCode
int getHashCode(LiteralLabel lit)
Gets the hash code of a given value. This defaults to lit.getValue().hashCode(), but datatypes can override this, and array types must.
-
getJavaClass
java.lang.Class<?> getJavaClass()
If this datatype is used as the canonical representation for a particular java datatype then return that java type, otherwise returns null.
-
cannonicalise
java.lang.Object cannonicalise(java.lang.Object value)
Cannonicalise a java Object value to a normal form. Primarily used in cases such as xsd:integer to reduce the Java object representation to the narrowest of the Number subclasses to ensure that indexing of typed literals works.
-
extendedTypeDefinition
java.lang.Object extendedTypeDefinition()
Returns an object giving more details on the datatype. This is type system dependent. In the case of XSD types this will be an instance oforg.apache.xerces.impl.xs.dv.XSSimpleType
.
-
normalizeSubType
RDFDatatype normalizeSubType(java.lang.Object value, RDFDatatype dt)
Normalization. If the value is narrower than the current data type (e.g. value is xsd:date but the time is xsd:datetime) returns the narrower type for the literal. If the type is narrower than the value then it may normalize the value (e.g. set the mask of an XSDDateTime) Currently only used to narrow gener XSDDateTime objects to the minimal XSD date/time type.- Parameters:
value
- the current object valuedt
- the currently set data type- Returns:
- a narrower version of the datatype based on the actual value range
-
-