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

public abstract Class XSDatatypeImpl

extends Object
implements XSDatatype
Class Inheritance
All Implemented Interfaces
com.sun.msv.datatype.xsd.XSDatatype, com.sun.msv.datatype.DatabindableDatatype, org.relaxng.datatype.Datatype, java.io.Serializable
Known Direct Subclasses
com.sun.msv.datatype.xsd.ConcreteType, com.sun.msv.datatype.xsd.DataTypeWithFacet, com.sun.msv.datatype.xsd.Proxy
Imports
org.relaxng.datatype.DatatypeException, .DatatypeStreamingValidator, .ValidationContext, org.relaxng.datatype.helpers.StreamingValidatorImpl, java.util.Vector

base implementaion for XSDatatype interface.

This class should be considered as the implementation-detail, and applications should not access this class.

Author
Kohsuke KAWAGUCHI

Field Summary

Modifier and TypeField and Description
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 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 String
public static final String
public static final String
public static final String
private final String
protected static final ValidationContext
private static final long
private final String
public final WhiteSpaceProcessor
whiteSpace

this field characterizes how this datatype treats white space.

Constructor Summary

AccessConstructor and Description
protected
XSDatatypeImpl(String uri, String typeName, WhiteSpaceProcessor whiteSpace)

Method Summary

Modifier and TypeMethod and Description
protected abstract void
_checkValid(String content, ValidationContext context)

actual 'meat' of the checkValid method

protected abstract Object
protected abstract Object
_createValue(String content, ValidationContext context)

converts a whitespace-processed lexical value into the corresponding value object

protected abstract boolean
public final void
checkValid(String content, ValidationContext context)

Implements org.relaxng.datatype.Datatype.checkValid.

Similar to the isValid method but throws an exception with diagnosis in case of errors.
public final Object
createJavaObject(String literal, ValidationContext context)

Implements com.sun.msv.datatype.DatabindableDatatype.createJavaObject.

converts lexcial value to a corresponding Java-friendly object by using the given context information.
public DatatypeStreamingValidator
createStreamingValidator(ValidationContext
If this datatype is context-dependent (i.e. the isContextDependent method returns true), then the caller must provide a non-null valid context object. Otherwise, the caller can pass null. The callee may keep a reference to this context object only while the returned streaming validator is being used.
context
)

Implements org.relaxng.datatype.Datatype.createStreamingValidator.

Creates an instance of a streaming validator for this type.
public final Object
createValue(String lexicalValue, ValidationContext
If this datatype is context-dependent (when the isContextDependent method returns true), then the caller must provide a non-null valid context object. Otherwise, the caller can pass null.
context
)

Implements org.relaxng.datatype.Datatype.createValue.

Converts lexcial value and the current context to the corresponding value object.
public XSDatatype
getAncestorBuiltinType()

Implements com.sun.msv.datatype.xsd.XSDatatype.getAncestorBuiltinType.

Gets the nearest ancestor built-in type.
public String[]
getApplicableFacetNames()

Implements com.sun.msv.datatype.xsd.XSDatatype.getApplicableFacetNames.

Gets the names of all applicable facets.
public abstract ConcreteType
getConcreteType()

gets the concrete type object of the restriction chain.

public DataTypeWithFacet

Returns:

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

Implements com.sun.msv.datatype.xsd.XSDatatype.getFacetObject.

gets the facet object that restricts the specified facet
public int
getIdType()

Implements org.relaxng.datatype.Datatype.getIdType.

A property for RELAX NG DTD compatibility datatypes.
public String
getName()

Implements com.sun.msv.datatype.xsd.XSDatatype.getName.

gets the local name of the type.
public String
getNamespaceUri()

Implements com.sun.msv.datatype.xsd.XSDatatype.getNamespaceUri.

Gets the namespace URI of this simple type definition.
public boolean
isAlwaysValid()

Implements com.sun.msv.datatype.xsd.XSDatatype.isAlwaysValid.

Returns true if this datatype is known to accept any string.
public boolean
isContextDependent()

Implements org.relaxng.datatype.Datatype.isContextDependent.

A property for RELAX NG DTD compatibility datatypes.
public final 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
)

Implements com.sun.msv.datatype.xsd.XSDatatype.isDerivedTypeOf.

tests if this type is a derived type of the specified type.
public static boolean
isDerivedTypeOf(XSDatatype base, XSDatatype derived, boolean restrictionAllowed)

an implementation of "Type Derivation OK (Simple)" of the spec.

public final boolean
isValid(String
the lexical representation to be checked.
literal
,
ValidationContext
If this datatype is context-dependent (i.e. the isContextDependent method returns true), then the caller must provide a non-null valid context object. Otherwise, the caller can pass null.
context
)

Implements org.relaxng.datatype.Datatype.isValid.

Checks if the specified 'literal' matches this Datatype with respect to the current context.
public static String
localize(String prop, Object[] args)

public static String
public static String
localize(String prop, Object arg1)

public static String
localize(String prop, Object arg1, Object arg2)

public static String
localize(String prop, Object arg1, Object arg2, Object arg3)

protected boolean
public final boolean
sameValue(Object o1, Object o2)

Implements org.relaxng.datatype.Datatype.sameValue.

Tests the equality of two value objects which were originally created by the createValue method of this object.
public final int
valueHashCode(Object o)

Implements org.relaxng.datatype.Datatype.valueHashCode.

Computes the hash code for a value object, which is consistent with the sameValue method.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ERR_DUPLICATE_FACETback to summary
public static final String ERR_DUPLICATE_FACET
ERR_EMPTY_UNIONback to summary
public static final String ERR_EMPTY_UNION
ERR_ENUMERATIONback to summary
public static final String ERR_ENUMERATION
ERR_ENUMERATION_WITH_ARGback to summary
public static final String ERR_ENUMERATION_WITH_ARG
ERR_FACET_MUST_BE_NON_NEGATIVE_INTEGERback to summary
public static final String ERR_FACET_MUST_BE_NON_NEGATIVE_INTEGER
ERR_FACET_MUST_BE_POSITIVE_INTEGERback to summary
public static final String ERR_FACET_MUST_BE_POSITIVE_INTEGER
ERR_INAPPROPRIATE_FOR_TYPEback to summary
public static final String ERR_INAPPROPRIATE_FOR_TYPE
ERR_INCONSISTENT_FACETS_1back to summary
public static final String ERR_INCONSISTENT_FACETS_1
ERR_INCONSISTENT_FACETS_2back to summary
public static final String ERR_INCONSISTENT_FACETS_2
ERR_INVALID_BASE_TYPEback to summary
public static final String ERR_INVALID_BASE_TYPE
ERR_INVALID_ITEMTYPEback to summary
public static final String ERR_INVALID_ITEMTYPE
ERR_INVALID_MEMBER_TYPEback to summary
public static final String ERR_INVALID_MEMBER_TYPE
ERR_INVALID_VALUE_FOR_THIS_TYPEback to summary
public static final String ERR_INVALID_VALUE_FOR_THIS_TYPE
ERR_INVALID_WHITESPACE_VALUEback to summary
public static final String ERR_INVALID_WHITESPACE_VALUE
ERR_LENGTHback to summary
public static final String ERR_LENGTH
ERR_LOOSENED_FACETback to summary
public static final String ERR_LOOSENED_FACET
ERR_MAXLENGTHback to summary
public static final String ERR_MAXLENGTH
ERR_MINLENGTHback to summary
public static final String ERR_MINLENGTH
ERR_NOT_APPLICABLE_FACETback to summary
public static final String ERR_NOT_APPLICABLE_FACET
ERR_OUT_OF_RANGEback to summary
public static final String ERR_OUT_OF_RANGE
ERR_OVERRIDING_FIXED_FACETback to summary
public static final String ERR_OVERRIDING_FIXED_FACET
ERR_PARSE_ERRORback to summary
public static final String ERR_PARSE_ERROR
ERR_PATTERN_1back to summary
public static final String ERR_PATTERN_1
ERR_PATTERN_MANYback to summary
public static final String ERR_PATTERN_MANY
ERR_SCALE_IS_GREATER_THAN_PRECISIONback to summary
public static final String ERR_SCALE_IS_GREATER_THAN_PRECISION
ERR_TOO_MUCH_PRECISIONback to summary
public static final String ERR_TOO_MUCH_PRECISION
ERR_TOO_MUCH_SCALEback to summary
public static final String ERR_TOO_MUCH_SCALE
ERR_X_AND_Y_ARE_EXCLUSIVEback to summary
public static final String ERR_X_AND_Y_ARE_EXCLUSIVE
namespaceUriback to summary
private final String namespaceUri
serializedValueCheckerback to summary
protected static final ValidationContext serializedValueChecker
serialVersionUIDback to summary
private static final long serialVersionUID
typeNameback to summary
private final String typeName
whiteSpaceback to summary
public final WhiteSpaceProcessor whiteSpace

this field characterizes how this datatype treats white space.

Constructor Detail

XSDatatypeImplback to summary
protected XSDatatypeImpl(String uri, String typeName, WhiteSpaceProcessor whiteSpace)

Method Detail

_checkValidback to summary
protected abstract void _checkValid(String content, ValidationContext context) throws DatatypeException

actual 'meat' of the checkValid method

_createJavaObjectback to summary
protected abstract Object _createJavaObject(String literal, ValidationContext context)
_createValueback to summary
protected abstract Object _createValue(String content, ValidationContext context)

converts a whitespace-processed lexical value into the corresponding value object

checkFormatback to summary
protected abstract boolean checkFormat(String literal, ValidationContext context)
checkValidback to summary
public final void checkValid(String content, ValidationContext context) throws DatatypeException

Implements org.relaxng.datatype.Datatype.checkValid.

Doc from org.relaxng.datatype.Datatype.checkValid.

Similar to the isValid method but throws an exception with diagnosis in case of errors.

If the specified 'literal' is a valid lexical representation for this datatype, then this method must return without throwing any exception. If not, the callee must throw an exception (with diagnosis message, if possible.)

The application can use this method to provide detailed error message to users. This method is kept separate from the isValid method to achieve higher performance during normal validation.

Exceptions
DatatypeException:
If the given literal is invalid, then this exception is thrown. If the callee supports error diagnosis, then the exception should contain a diagnosis message.
createJavaObjectback to summary
public final Object createJavaObject(String literal, ValidationContext context)

Implements com.sun.msv.datatype.DatabindableDatatype.createJavaObject.

Doc from com.sun.msv.datatype.DatabindableDatatype.createJavaObject.

converts lexcial value to a corresponding Java-friendly object by using the given context information.

For the actual types returned by each type, see here.

Note that due to the difference between those Java friendly types and actual XML Schema specification, the returned object sometimes loses accuracy. For example, the "time" type allows "0.0000000000001 sec" which cannot be represented in java.util.Calendar class.

Returns:Object

null when the given lexical value is not a valid lexical value for this type.

createStreamingValidatorback to summary
public DatatypeStreamingValidator createStreamingValidator(ValidationContext context)

Implements org.relaxng.datatype.Datatype.createStreamingValidator.

Doc from org.relaxng.datatype.Datatype.createStreamingValidator.

Creates an instance of a streaming validator for this type.

By using streaming validators instead of the isValid method, the caller can avoid keeping the entire string, which is sometimes quite big, in memory.

Parameters
context:ValidationContext

If this datatype is context-dependent (i.e. the isContextDependent method returns true), then the caller must provide a non-null valid context object. Otherwise, the caller can pass null. The callee may keep a reference to this context object only while the returned streaming validator is being used.

createValueback to summary
public final Object createValue(String lexicalValue, ValidationContext context)

Implements org.relaxng.datatype.Datatype.createValue.

Doc from org.relaxng.datatype.Datatype.createValue.

Converts lexcial value and the current context to the corresponding value object.

The caller cannot generally assume that the value object is a meaningful Java object. For example, the caller cannot expect this method to return java.lang.Number type for the "integer" type of XML Schema Part 2.

Also, the caller cannot assume that the equals method and the hashCode method of the value object are consistent with the semantics of the datatype. For that purpose, the sameValue method and the valueHashCode method have to be used. Note that this means you cannot use classes like java.util.Hashtable to store the value objects.

The returned value object should be used solely for the sameValue and valueHashCode methods.

Parameters
context:ValidationContext

If this datatype is context-dependent (when the isContextDependent method returns true), then the caller must provide a non-null valid context object. Otherwise, the caller can pass null.

Returns:Object

null when the given lexical value is not a valid lexical value for this type.

getAncestorBuiltinTypeback to summary
public XSDatatype getAncestorBuiltinType()

Implements com.sun.msv.datatype.xsd.XSDatatype.getAncestorBuiltinType.

Doc from com.sun.msv.datatype.xsd.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()

Implements com.sun.msv.datatype.xsd.XSDatatype.getApplicableFacetNames.

Doc from com.sun.msv.datatype.xsd.XSDatatype.getApplicableFacetNames.

Gets the names of all applicable facets.

getConcreteTypeback to summary
public abstract ConcreteType getConcreteType()

gets the concrete type object of the restriction chain.

getFacetObjectback to summary
public DataTypeWithFacet getFacetObject(String facetName)

Implements com.sun.msv.datatype.xsd.XSDatatype.getFacetObject.

gets the facet object that restricts the specified facet

Returns:DataTypeWithFacet

null if no such facet object exists.

getIdTypeback to summary
public int getIdType()

Implements org.relaxng.datatype.Datatype.getIdType.

A property for RELAX NG DTD compatibility datatypes. ID_TYPE_NULL is returned by default.

Returns:int

Doc from org.relaxng.datatype.Datatype.getIdType.

If this datatype doesn't have any ID/IDREF semantics, it returns ID_TYPE_NULL. If it has such a semantics (for example, XSD:ID, XSD:IDREF and comp:ID type), then it returns ID_TYPE_ID, ID_TYPE_IDREF or ID_TYPE_IDREFS.

getNameback to summary
public String getName()

Implements com.sun.msv.datatype.xsd.XSDatatype.getName.

Doc from com.sun.msv.datatype.xsd.XSDatatype.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()

Implements com.sun.msv.datatype.xsd.XSDatatype.getNamespaceUri.

Doc from com.sun.msv.datatype.xsd.XSDatatype.getNamespaceUri.

Gets the namespace URI of this simple type definition.

isAlwaysValidback to summary
public boolean isAlwaysValid()

Implements com.sun.msv.datatype.xsd.XSDatatype.isAlwaysValid.

Doc from com.sun.msv.datatype.xsd.XSDatatype.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.

isContextDependentback to summary
public boolean isContextDependent()

Implements org.relaxng.datatype.Datatype.isContextDependent.

A property for RELAX NG DTD compatibility datatypes. Context-independent by default.

Returns:boolean

Doc from org.relaxng.datatype.Datatype.isContextDependent.

true if this datatype is context-dependent (it needs a context object sometimes); false if this datatype is context-independent (it never needs a context object).

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

Implements com.sun.msv.datatype.xsd.XSDatatype.isDerivedTypeOf.

Doc from com.sun.msv.datatype.xsd.XSDatatype.isDerivedTypeOf.

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.

isDerivedTypeOfback to summary
public static boolean isDerivedTypeOf(XSDatatype base, XSDatatype derived, boolean restrictionAllowed)

an implementation of "Type Derivation OK (Simple)" of the spec.

See Also
isDerivedTypeOf(XSDatatype, boolean)
isValidback to summary
public final boolean isValid(String literal, ValidationContext context)

Implements org.relaxng.datatype.Datatype.isValid.

Doc from org.relaxng.datatype.Datatype.isValid.

Checks if the specified 'literal' matches this Datatype with respect to the current context.

Parameters
literal:String

the lexical representation to be checked.

context:ValidationContext

If this datatype is context-dependent (i.e. the isContextDependent method returns true), then the caller must provide a non-null valid context object. Otherwise, the caller can pass null.

Returns:boolean

true if the 'literal' is a member of this Datatype; false if it's not a member of this Datatype.

localizeback to summary
public static String localize(String prop, Object[] args)
localizeback to summary
public static String localize(String prop)
localizeback to summary
public static String localize(String prop, Object arg1)
localizeback to summary
public static String localize(String prop, Object arg1, Object arg2)
localizeback to summary
public static String localize(String prop, Object arg1, Object arg2, Object arg3)
needValueCheckback to summary
protected boolean needValueCheck()
sameValueback to summary
public final boolean sameValue(Object o1, Object o2)

Implements org.relaxng.datatype.Datatype.sameValue.

Doc from org.relaxng.datatype.Datatype.sameValue.

Tests the equality of two value objects which were originally created by the createValue method of this object. The behavior is undefined if objects not created by this type are passed. It is the caller's responsibility to ensure that value objects belong to this type.

Returns:boolean

true if two value objects are considered equal according to the definition of this datatype; false if otherwise.

valueHashCodeback to summary
public final int valueHashCode(Object o)

Implements org.relaxng.datatype.Datatype.valueHashCode.

Doc from org.relaxng.datatype.Datatype.valueHashCode.

Computes the hash code for a value object, which is consistent with the sameValue method.

Returns:int

hash code for the specified value object.