Top Description Fields Methods
com.sun.msv.datatype.xsd

public Interface XSDatatype

extends Serializable, DatabindableDatatype
Known Direct Implementers
com.sun.msv.datatype.xsd.XSDatatypeImpl
Imports
com.sun.msv.datatype.DatabindableDatatype, .SerializationContext, java.io.Serializable

Publicly accesible interface of W3C XML Schema datatype (simple type).

The most important methods are defined in the org.relaxng.datatype.Datatype interface. This interface provides additional information which is not covered by org.relaxng.datatype.Datatype interface. Also, this interface provides various simple type component properties which are defined in the spec.

Application can use this interface to interact with datatype objects.

Author
Kohsuke KAWAGUCHI

Field Summary

Modifier and TypeField and Description
public static final int
APPLICABLE

indicates the specified facet is applicable to this type.

public static final int
public static final int
public static final int
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final int
FIXED

indicates the specified facet is fixed in this type and therefore not appliable.

public static final int
NOT_ALLOWED

indicates the specified facet is not appliable to this type by definition.

public static final int
public static final int
public static final int
public static final String

Method Summary

Modifier and TypeMethod and Description
public String
convertToLexicalValue(Object valueObject, SerializationContext
Context information that will be possibly used for the conversion. Currently, this object is used only by QName, but may be extended in the future.
context
)

converts value object back to the corresponding value in the lexical space.

public String
displayName()

gets the displayable name of this type.

public XSDatatype

Returns:

Always return non-null valid object.
getAncestorBuiltinType
()

Gets the nearest ancestor built-in type.

public String[]
getApplicableFacetNames()

Gets the names of all applicable facets.

public XSDatatype
getBaseType()

gets the base type of this type.

public DataTypeWithFacet

Returns:

null if no such facet object exists.
getFacetObject
(String facetName)

gets the facet object that restricts the specified facet.

public String
getName()

gets the local name of the type.

public String
getNamespaceUri()

Gets the namespace URI of this simple type definition.

public int

Returns:

VARIETY_ATOMIC, VARIETY_LIST, or VARIETY_UNION.
getVariety
()

gets the variety of this simple type.

public boolean
isAlwaysValid()

Returns true if this datatype is known to accept any string.

public boolean
isDerivedTypeOf(XSDatatype baseType, boolean
This test needs "a subset of {extension,restriction,list,union} (of which only restriction is actually relevant). If this flag is set to true, this method behaves as if the empty set is passed as the set. This is usually what you want if you're simply trying to check the derivation relationship.

If this flag is set to false, this method behaves as if {restriction} is passed as the set.

restrictionAllowed
)

tests if this type is a derived type of the specified type.

public int

Returns:

APPLICABLE
if the facet is applicable
FIXED
if the facet is already fixed (that is,not applicable)
NOT_ALLOWED
if the facet is not applicable to this datatype at all. this value is also returned for unknown facets.
isFacetApplicable
(String facetName)

returns if the specified facet is applicable to this datatype.

public boolean
isFinal(int
one of pre-defined values (DERIVATION_BY_XXX).
derivationType
)

checks if this type is declared as final for the specified kind of derivation.

Inherited from com.sun.msv.datatype.DatabindableDatatype:
createJavaObjectgetJavaObjectTypeserializeJavaObject

Field Detail

APPLICABLEback to summary
public static final int APPLICABLE

indicates the specified facet is applicable to this type. One of the possible return value from the isFacetApplicable method.

DERIVATION_BY_LISTback to summary
public static final int DERIVATION_BY_LIST
DERIVATION_BY_RESTRICTIONback to summary
public static final int DERIVATION_BY_RESTRICTION
DERIVATION_BY_UNIONback to summary
public static final int DERIVATION_BY_UNION
FACET_ENUMERATIONback to summary
public static final String FACET_ENUMERATION
FACET_FRACTIONDIGITSback to summary
public static final String FACET_FRACTIONDIGITS
FACET_LENGTHback to summary
public static final String FACET_LENGTH
FACET_MAXEXCLUSIVEback to summary
public static final String FACET_MAXEXCLUSIVE
FACET_MAXINCLUSIVEback to summary
public static final String FACET_MAXINCLUSIVE
FACET_MAXLENGTHback to summary
public static final String FACET_MAXLENGTH
FACET_MINEXCLUSIVEback to summary
public static final String FACET_MINEXCLUSIVE
FACET_MININCLUSIVEback to summary
public static final String FACET_MININCLUSIVE
FACET_MINLENGTHback to summary
public static final String FACET_MINLENGTH
FACET_PATTERNback to summary
public static final String FACET_PATTERN
FACET_TOTALDIGITSback to summary
public static final String FACET_TOTALDIGITS
FACET_WHITESPACEback to summary
public static final String FACET_WHITESPACE
FIXEDback to summary
public static final int FIXED

indicates the specified facet is fixed in this type and therefore not appliable. One of the possible return value from the isFacetApplicable method.

NOT_ALLOWEDback to summary
public static final int NOT_ALLOWED

indicates the specified facet is not appliable to this type by definition. One of the possible return value from the isFacetApplicable method.

VARIETY_ATOMICback to summary
public static final int VARIETY_ATOMIC
VARIETY_LISTback to summary
public static final int VARIETY_LIST
VARIETY_UNIONback to summary
public static final int VARIETY_UNION
XMLSCHEMA_NSURIback to summary
public static final String XMLSCHEMA_NSURI

Method Detail

convertToLexicalValueback to summary
public String convertToLexicalValue(Object valueObject, SerializationContext context) throws IllegalArgumentException

converts value object back to the corresponding value in the lexical space.

This method does the reverse operation of the createValue method. The returned string is not necessarily the canonical representation. Also note that the implementation may accept invalid values without throwing IllegalArgumentException. To make sure that the result is actually a valid representation, call the isValid method.

Be careful not to confuse this method with The serializeJavaObject method, which is defined in the DatabindableDatatype method.

Parameters
context:SerializationContext

Context information that will be possibly used for the conversion. Currently, this object is used only by QName, but may be extended in the future.

Exceptions
IllegalArgumentException:
if the type of the given object is not the expected one. For example, this exception is thrown if you pass a BigInteger object to the "gYear" type.
displayNameback to summary
public String displayName()

gets the displayable name of this type. This method always return something. It is useful to provide a message to the user.

This method is an ad-hoc method and there is no corresponding property in the spec.

getAncestorBuiltinTypeback to summary
public XSDatatype getAncestorBuiltinType()

Gets the nearest ancestor built-in type.

This method traverses the inheritance chain from this datatype to the root type (anySimpleType) and return the first built-in type it finds.

For example, if you derive a type Foo from NCName and Bar from Foo, then this method returns NCName.

Returns:XSDatatype

Always return non-null valid object.

getApplicableFacetNamesback to summary
public String[] getApplicableFacetNames()

Gets the names of all applicable facets.

getBaseTypeback to summary
public XSDatatype getBaseType()

gets the base type of this type. This method returns null if this object represents the simple ur-type.

This method is intended to capture the semantics of the base type definition property of the simple type component, but there is an important difference.

Specifically, if you derive a type D from another type B, then calling D.getBaseType() does not necessarily return B. Instead, it may return an intermediate object (that represents a facet). Calling the getBaseType method recursively will eventually return B.

getFacetObjectback to summary
public DataTypeWithFacet getFacetObject(String facetName)

gets the facet object that restricts the specified facet. This method can be used to access various details of how facets are applied to this datatype.

Returns:DataTypeWithFacet

null if no such facet object exists.

getNameback to summary
public String getName()

gets the local name of the type. If this type is an anonymous type, then this method returns null.

In the terminology of the spec, this method returns the name property of this simple type component. If the name property is absent, this method returns null.

getNamespaceUriback to summary
public String getNamespaceUri()

Gets the namespace URI of this simple type definition.

getVarietyback to summary
public int getVariety()

gets the variety of this simple type.

Returns:int

VARIETY_ATOMIC, VARIETY_LIST, or VARIETY_UNION.

isAlwaysValidback to summary
public boolean isAlwaysValid()

Returns true if this datatype is known to accept any string. This is just a hint that allows the client code to do certain optimization.

This method can return false even if the datatype actually accepts any string. That is, it's perfectly OK for any datatype to return false from this method.

isDerivedTypeOfback to summary
public boolean isDerivedTypeOf(XSDatatype baseType, boolean restrictionAllowed)

tests if this type is a derived type of the specified type.

This method is an implementation of "Type Derivation OK (Simple)" of the spec. Therefore use caution if what you want is a casual method because this method may cause a lot of unintuitive result.

Note to implementors Use the static version of this method defined in the XSDatatypeImpl class. You don't need to implement this method from scratch.

Parameters
restrictionAllowed:boolean

This test needs "a subset of {extension,restriction,list,union} (of which only restriction is actually relevant). If this flag is set to true, this method behaves as if the empty set is passed as the set. This is usually what you want if you're simply trying to check the derivation relationship.

If this flag is set to false, this method behaves as if {restriction} is passed as the set.

isFacetApplicableback to summary
public int isFacetApplicable(String facetName)

returns if the specified facet is applicable to this datatype.

Returns:int

APPLICABLE
if the facet is applicable
FIXED
if the facet is already fixed (that is,not applicable)
NOT_ALLOWED
if the facet is not applicable to this datatype at all. this value is also returned for unknown facets.
isFinalback to summary
public boolean isFinal(int derivationType)

checks if this type is declared as final for the specified kind of derivation.

In the terminology of the spec, this method can be used to examine the final property of this component.

Parameters
derivationType:int

one of pre-defined values (DERIVATION_BY_XXX).