de.hedenus.xmltypes
Interface Type
- All Known Implementing Classes:
- AbstractTypeImpl, AnySimpleType, AnyType, AnyURIType, BooleanType, BuiltInDerivedType, BuiltInPrimitiveType, DateTimeType, DateType, DecimalType, DoubleType, FloatType, IntegerType, IntType, LongType, StringType, UrType, W3SchemaType, XMLLiteral
public interface Type
An interface describing a XML type (for example W3 Schema or other).
- Author:
- Michael Hedenus
Method Summary |
Type[] |
getBaseTypes()
Returns the base types of the type. |
java.lang.String |
getName()
Returns the name of the type according to the type system, for example "http://www.w3.org/2001/XMLSchema#string". |
java.lang.Class |
getRepresentationClass()
Returns the mapped Java type. |
java.lang.String |
getTypeSystem()
Returns the type system identifier, for example "http://www.w3.org/2001/XMLSchema" |
boolean |
isAbstract()
Returns true iff the type is abstract. |
boolean |
isPrimitive()
Returns true iff the type is considered to be a primitive. |
java.lang.Object |
parse(java.lang.String literal)
Parses a lexical value. |
java.lang.String |
toLiteral(java.lang.Object value)
Returns a lexical representation (literal) of a value. |
java.lang.String |
toString()
Returns a string representation of the type, for example "http://www.w3.org/2001/XMLSchema#string" |
boolean |
validate(java.lang.Object value)
Returns true iff the value is valid. |
getRepresentationClass
java.lang.Class getRepresentationClass()
- Returns the mapped Java type.
validate
boolean validate(java.lang.Object value)
- Returns true iff the value is valid.
getBaseTypes
Type[] getBaseTypes()
- Returns the base types of the type.
- If the type is a union type the constituent types are returned.
- If the type is a constrained type the unconstrained type is returned.
- If the type is a unconstrained type the base types in the type hierarchy are returned.
- If the type is a root of the type hierarchy,
null
is returned.
isPrimitive
boolean isPrimitive()
- Returns true iff the type is considered to be a primitive.
The definition of a primitive type depends on the type system. Note that a constrained type
may be considered as a primitive,
e.g. the boolean primitive can be defined as an element of the set {0;1}, which
is a constraint of the integral numbers.
On the other hand, the boolean primitive can also be defined
as in instance of {true;false} which is not a constraint of any other set.
In terms of W3 Schema primitive datatypes are those that are not defined in terms of other datatypes.
isAbstract
boolean isAbstract()
- Returns true iff the type is abstract.
If a type is abstract the methods toLiteral() and parse() will throw an exception.
In terms of W3 Schema this is an ur-type.
getName
java.lang.String getName()
- Returns the name of the type according to the type system, for example "http://www.w3.org/2001/XMLSchema#string".
getTypeSystem
java.lang.String getTypeSystem()
- Returns the type system identifier, for example "http://www.w3.org/2001/XMLSchema"
toString
java.lang.String toString()
- Returns a string representation of the type, for example "http://www.w3.org/2001/XMLSchema#string"
- Overrides:
toString
in class java.lang.Object
toLiteral
java.lang.String toLiteral(java.lang.Object value)
throws TypeException
- Returns a lexical representation (literal) of a value.
This method assumes that the value is valid, so before
passing a value to this method it should be checked if it is really appropriate.
- Throws:
TypeException
parse
java.lang.Object parse(java.lang.String literal)
throws TypeException
- Parses a lexical value. Only the unconstrained base types may be used for parsing, i.e.
it is possible that the parsing is successful but the resulting object is not valid
according to the constraints of this particluar type.
For example let the type be http://www.w3.org/2001/XMLSchema#nonNegativeInteger and the value be -5 then
it is up to the implementation either to throw an exception (because the value is negative)
or to return the value and let the application check it using the validate() method.
The latter case would allow the user to be informed and to correct the value.
If the method is successful then the returned value should at least be valid according to
the unconstrained base type of this particalur type.
- Throws:
TypeException