org.apache.xerces.impl.dv.xs
Class XSSimpleTypeDecl

java.lang.Object
  extended by org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl
All Implemented Interfaces:
XSSimpleType, XSObject, XSSimpleTypeDefinition, XSTypeDefinition, TypeInfo

public class XSSimpleTypeDecl
extends java.lang.Object
implements XSSimpleType, TypeInfo

Version:
$Id: XSSimpleTypeDecl.java 548093 2007-06-17 18:36:08Z mrglavas $
Author:
Sandy Gao, IBM, Neeraj Bajaj, Sun Microsystems, inc.

Field Summary
static short ANYATOMICTYPE_DT
           
static short DAYTIMEDURATION_DT
           
 XSObjectList enumerationAnnotations
           
 XSAnnotation fractionDigitsAnnotation
           
 XSAnnotation lengthAnnotation
           
 XSAnnotation maxExclusiveAnnotation
           
 XSAnnotation maxInclusiveAnnotation
           
 XSAnnotation maxLengthAnnotation
           
 XSAnnotation minExclusiveAnnotation
           
 XSAnnotation minInclusiveAnnotation
           
 XSAnnotation minLengthAnnotation
           
 XSObjectListImpl patternAnnotations
           
static short PRECISIONDECIMAL_DT
           
 XSAnnotation totalDigitsAnnotation
           
 XSAnnotation whiteSpaceAnnotation
           
static short YEARMONTHDURATION_DT
           
 
Fields inherited from interface org.apache.xerces.impl.dv.XSSimpleType
PRIMITIVE_ANYURI, PRIMITIVE_BASE64BINARY, PRIMITIVE_BOOLEAN, PRIMITIVE_DATE, PRIMITIVE_DATETIME, PRIMITIVE_DECIMAL, PRIMITIVE_DOUBLE, PRIMITIVE_DURATION, PRIMITIVE_FLOAT, PRIMITIVE_GDAY, PRIMITIVE_GMONTH, PRIMITIVE_GMONTHDAY, PRIMITIVE_GYEAR, PRIMITIVE_GYEARMONTH, PRIMITIVE_HEXBINARY, PRIMITIVE_NOTATION, PRIMITIVE_PRECISIONDECIMAL, PRIMITIVE_QNAME, PRIMITIVE_STRING, PRIMITIVE_TIME, WS_COLLAPSE, WS_PRESERVE, WS_REPLACE
 
Fields inherited from interface org.apache.xerces.xs.XSSimpleTypeDefinition
FACET_ENUMERATION, FACET_FRACTIONDIGITS, FACET_LENGTH, FACET_MAXEXCLUSIVE, FACET_MAXINCLUSIVE, FACET_MAXLENGTH, FACET_MINEXCLUSIVE, FACET_MININCLUSIVE, FACET_MINLENGTH, FACET_NONE, FACET_PATTERN, FACET_TOTALDIGITS, FACET_WHITESPACE, ORDERED_FALSE, ORDERED_PARTIAL, ORDERED_TOTAL, VARIETY_ABSENT, VARIETY_ATOMIC, VARIETY_LIST, VARIETY_UNION
 
Fields inherited from interface org.apache.xerces.xs.XSTypeDefinition
COMPLEX_TYPE, SIMPLE_TYPE
 
Constructor Summary
XSSimpleTypeDecl()
           
 
Method Summary
 void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, ValidationContext context)
          If is chosen
 boolean derivedFrom(java.lang.String ancestorNS, java.lang.String ancestorName, short derivation)
          Convenience method which checks if this type is derived from the given ancestor type.
 boolean derivedFromType(XSTypeDefinition ancestor, short derivation)
          Convenience method which checks if this type is derived from the given ancestorType.
 ObjectList getActualEnumeration()
          A list of actual enumeration values if it exists, otherwise an empty ObjectList.
 XSObjectList getAnnotations()
          [annotations]: a set of annotations for this simple type component if it exists, otherwise an empty XSObjectList.
 boolean getAnonymous()
          Convenience attribute.
 XSTypeDefinition getBaseType()
          {base type definition}: either a simple type definition or a complex type definition.
 boolean getBounded()
          Fundamental Facet: bounded.
 short getBuiltInKind()
          Returns the closest built-in type category this type represents or derived from.
 short getDefinedFacets()
          [facets]: all facets defined on this type.
 ObjectList getEnumerationItemTypeList()
          A list of enumeration type values (as a list of ShortList objects) if it exists, otherwise returns null
 ShortList getEnumerationTypeList()
           
 XSObjectList getFacets()
          A list of constraining facets if it exists, otherwise an empty XSObjectList.
 short getFinal()
          For complex types the returned value is a bit combination of the subset of {DERIVATION_EXTENSION, DERIVATION_RESTRICTION} corresponding to final set of this type or DERIVATION_NONE.
 boolean getFinite()
          Fundamental Facet: cardinality.
 short getFixedFacets()
          [facets]: all defined facets for this type which are fixed.
 XSSimpleTypeDefinition getItemType()
          If variety is list the item type definition (an atomic or union simple type definition) is available, otherwise null.
 StringList getLexicalEnumeration()
          A list of enumeration values if it exists, otherwise an empty StringList.
 java.lang.String getLexicalFacetValue(short facetName)
          Convenience method.
 StringList getLexicalPattern()
          A list of pattern values if it exists, otherwise an empty StringList.
 java.lang.Object getMaxExclusiveValue()
           
 java.lang.Object getMaxInclusiveValue()
           
 XSObjectList getMemberTypes()
          If variety is union the list of member type definitions (a non-empty sequence of simple type definitions) is available, otherwise an empty XSObjectList.
 java.lang.Object getMinExclusiveValue()
           
 java.lang.Object getMinInclusiveValue()
           
 XSObjectList getMultiValueFacets()
          A list of enumeration and pattern constraining facets if it exists, otherwise an empty XSObjectList.
 java.lang.String getName()
          The name of type NCName, as defined in XML Namespaces, of this declaration specified in the {name} property of the component or null if the definition of this component does not have a {name} property.
 java.lang.String getNamespace()
          The [target namespace] of this object, or null if it is unspecified.
 XSNamespaceItem getNamespaceItem()
          A namespace schema information item corresponding to the target namespace of the component, if it is globally declared; or null otherwise.
 boolean getNumeric()
          Fundamental Facet: numeric.
 short getOrdered()
          Fundamental Facet: ordered.
 short getPrimitiveKind()
          return an ID representing the built-in primitive base type.
 XSSimpleTypeDefinition getPrimitiveType()
          If variety is atomic the primitive type definition (a built-in primitive datatype definition or the simple ur-type definition) is available, otherwise null.
 short getType()
          The type of this object, i.e.
 short getTypeCategory()
          Return whether this type definition is a simple type or complex type.
 java.lang.String getTypeName()
          The name of a type declared for the associated element or attribute, or null if unknown.
 java.lang.String getTypeNamespace()
          The namespace of the type declared for the associated element or attribute or null if the element does not have declaration or if no namespace information is available.
 short getVariety()
          [variety]: one of {atomic, list, union} or absent.
 short getWhitespace()
          Return the whitespace corresponding to this datatype.
 boolean isDefinedFacet(short facetName)
          Convenience method.
 boolean isDerivedFrom(java.lang.String typeNamespaceArg, java.lang.String typeNameArg, int derivationMethod)
          This method returns if there is a derivation between the reference type definition, i.e.
 boolean isDOMDerivedFrom(java.lang.String ancestorNS, java.lang.String ancestorName, int derivationMethod)
          Checks if a type is derived from another by restriction, given the name and namespace.
 boolean isEqual(java.lang.Object value1, java.lang.Object value2)
          Check whether two actual values are equal.
 boolean isFinal(short derivation)
          {final}.
 boolean isFixedFacet(short facetName)
          Convenience method.
 boolean isIdentical(java.lang.Object value1, java.lang.Object value2)
           
 boolean isIDType()
          Check whether this type is or is derived from ID.
static java.lang.String normalize(java.lang.String content, short ws)
           
 void reset()
           
 void setAnonymous(boolean anon)
           
 java.lang.String toString()
           
 java.lang.Object validate(java.lang.Object content, ValidationContext context, ValidatedInfo validatedInfo)
          validate a value, and return the compiled form
 java.lang.Object validate(java.lang.String content, ValidationContext context, ValidatedInfo validatedInfo)
          validate a value, and return the compiled form
 void validate(ValidationContext context, ValidatedInfo validatedInfo)
          validate an actual value against this DV
 ValidatedInfo validateWithInfo(java.lang.String content, ValidationContext context, ValidatedInfo validatedInfo)
          validate a value, and return the compiled form
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

YEARMONTHDURATION_DT

public static final short YEARMONTHDURATION_DT
See Also:
Constant Field Values

DAYTIMEDURATION_DT

public static final short DAYTIMEDURATION_DT
See Also:
Constant Field Values

PRECISIONDECIMAL_DT

public static final short PRECISIONDECIMAL_DT
See Also:
Constant Field Values

ANYATOMICTYPE_DT

public static final short ANYATOMICTYPE_DT
See Also:
Constant Field Values

lengthAnnotation

public XSAnnotation lengthAnnotation

minLengthAnnotation

public XSAnnotation minLengthAnnotation

maxLengthAnnotation

public XSAnnotation maxLengthAnnotation

whiteSpaceAnnotation

public XSAnnotation whiteSpaceAnnotation

totalDigitsAnnotation

public XSAnnotation totalDigitsAnnotation

fractionDigitsAnnotation

public XSAnnotation fractionDigitsAnnotation

patternAnnotations

public XSObjectListImpl patternAnnotations

enumerationAnnotations

public XSObjectList enumerationAnnotations

maxInclusiveAnnotation

public XSAnnotation maxInclusiveAnnotation

maxExclusiveAnnotation

public XSAnnotation maxExclusiveAnnotation

minInclusiveAnnotation

public XSAnnotation minInclusiveAnnotation

minExclusiveAnnotation

public XSAnnotation minExclusiveAnnotation
Constructor Detail

XSSimpleTypeDecl

public XSSimpleTypeDecl()
Method Detail

getType

public short getType()
Description copied from interface: XSObject
The type of this object, i.e. ELEMENT_DECLARATION.

Specified by:
getType in interface XSObject

getTypeCategory

public short getTypeCategory()
Description copied from interface: XSTypeDefinition
Return whether this type definition is a simple type or complex type.

Specified by:
getTypeCategory in interface XSTypeDefinition

getName

public java.lang.String getName()
Description copied from interface: XSObject
The name of type NCName, as defined in XML Namespaces, of this declaration specified in the {name} property of the component or null if the definition of this component does not have a {name} property. For anonymous types, the processor must construct and expose an anonymous type name that is distinct from the name of every named type and the name of every other anonymous type.

Specified by:
getName in interface XSObject

getTypeName

public java.lang.String getTypeName()
Description copied from interface: TypeInfo
The name of a type declared for the associated element or attribute, or null if unknown.

Specified by:
getTypeName in interface TypeInfo

getNamespace

public java.lang.String getNamespace()
Description copied from interface: XSObject
The [target namespace] of this object, or null if it is unspecified.

Specified by:
getNamespace in interface XSObject

getFinal

public short getFinal()
Description copied from interface: XSTypeDefinition
For complex types the returned value is a bit combination of the subset of {DERIVATION_EXTENSION, DERIVATION_RESTRICTION} corresponding to final set of this type or DERIVATION_NONE. For simple types the returned value is a bit combination of the subset of { DERIVATION_RESTRICTION, DERIVATION_EXTENSION, DERIVATION_UNION, DERIVATION_LIST } corresponding to final set of this type or DERIVATION_NONE.

Specified by:
getFinal in interface XSTypeDefinition

isFinal

public boolean isFinal(short derivation)
Description copied from interface: XSTypeDefinition
{final}. For a complex type definition it is a subset of {extension, restriction}. For a simple type definition it is a subset of {extension, list, restriction, union}.

Specified by:
isFinal in interface XSTypeDefinition
Parameters:
derivation - Extension, restriction, list, union constants (defined in XSConstants).
Returns:
True if restriction is in the final set, otherwise false.

getBaseType

public XSTypeDefinition getBaseType()
Description copied from interface: XSTypeDefinition
{base type definition}: either a simple type definition or a complex type definition.

Specified by:
getBaseType in interface XSTypeDefinition

getAnonymous

public boolean getAnonymous()
Description copied from interface: XSTypeDefinition
Convenience attribute. A boolean that specifies if the type definition is anonymous.

Specified by:
getAnonymous in interface XSTypeDefinition

getVariety

public short getVariety()
Description copied from interface: XSSimpleTypeDefinition
[variety]: one of {atomic, list, union} or absent.

Specified by:
getVariety in interface XSSimpleTypeDefinition

isIDType

public boolean isIDType()
Description copied from interface: XSSimpleType
Check whether this type is or is derived from ID. REVISIT: this method makes ID special, which is not a good design. but since ID is not a primitive, there doesn't seem to be a clean way of doing it except to define special method like this.

Specified by:
isIDType in interface XSSimpleType
Returns:
whether this simple type is or is derived from ID.

getWhitespace

public short getWhitespace()
                    throws DatatypeException
Description copied from interface: XSSimpleType
Return the whitespace corresponding to this datatype.

Specified by:
getWhitespace in interface XSSimpleType
Returns:
valid values are WS_PRESERVE, WS_REPLACE, WS_COLLAPSE.
Throws:
DatatypeException - union datatypes don't have whitespace facet associated with them

getPrimitiveKind

public short getPrimitiveKind()
Description copied from interface: XSSimpleType
return an ID representing the built-in primitive base type. REVISIT: This method is (currently) for internal use only. the constants returned from this method are not finalized yet. the names and values might change in the further.

Specified by:
getPrimitiveKind in interface XSSimpleType
Returns:
an ID representing the built-in primitive base type

getBuiltInKind

public short getBuiltInKind()
Returns the closest built-in type category this type represents or derived from. For example, if this simple type is a built-in derived type integer the INTEGER_DV is returned.

Specified by:
getBuiltInKind in interface XSSimpleTypeDefinition

getPrimitiveType

public XSSimpleTypeDefinition getPrimitiveType()
If variety is atomic the primitive type definition (a built-in primitive datatype definition or the simple ur-type definition) is available, otherwise null.

Specified by:
getPrimitiveType in interface XSSimpleTypeDefinition

getItemType

public XSSimpleTypeDefinition getItemType()
If variety is list the item type definition (an atomic or union simple type definition) is available, otherwise null.

Specified by:
getItemType in interface XSSimpleTypeDefinition

getMemberTypes

public XSObjectList getMemberTypes()
If variety is union the list of member type definitions (a non-empty sequence of simple type definitions) is available, otherwise an empty XSObjectList.

Specified by:
getMemberTypes in interface XSSimpleTypeDefinition

applyFacets

public void applyFacets(XSFacets facets,
                        short presentFacet,
                        short fixedFacet,
                        ValidationContext context)
                 throws InvalidDatatypeFacetException
If is chosen

Specified by:
applyFacets in interface XSSimpleType
Parameters:
facets - the value of all the facets
presentFacet - bit combination value of the costraining facet constants which are present.
fixedFacet - bit combination value of the costraining facet constants which are fixed.
context - the validation context
Throws:
InvalidDatatypeFacetException - exception for invalid facet values.

validate

public java.lang.Object validate(java.lang.String content,
                                 ValidationContext context,
                                 ValidatedInfo validatedInfo)
                          throws InvalidDatatypeValueException
validate a value, and return the compiled form

Specified by:
validate in interface XSSimpleType
Parameters:
content - the string value that needs to be validated
context - the validation context
validatedInfo - used to store validation result
Returns:
the actual value (QName, Boolean) of the string value
Throws:
InvalidDatatypeValueException

validateWithInfo

public ValidatedInfo validateWithInfo(java.lang.String content,
                                      ValidationContext context,
                                      ValidatedInfo validatedInfo)
                               throws InvalidDatatypeValueException
validate a value, and return the compiled form

Throws:
InvalidDatatypeValueException

validate

public java.lang.Object validate(java.lang.Object content,
                                 ValidationContext context,
                                 ValidatedInfo validatedInfo)
                          throws InvalidDatatypeValueException
validate a value, and return the compiled form

Specified by:
validate in interface XSSimpleType
Parameters:
content - the string value that needs to be validated
context - the validation context
validatedInfo - used to store validation result
Returns:
the actual value (QName, Boolean) of the string value
Throws:
InvalidDatatypeValueException

validate

public void validate(ValidationContext context,
                     ValidatedInfo validatedInfo)
              throws InvalidDatatypeValueException
validate an actual value against this DV

Specified by:
validate in interface XSSimpleType
Parameters:
context - the validation context
validatedInfo - used to provide the actual value and member types
Throws:
InvalidDatatypeValueException - exception for invalid values.

isEqual

public boolean isEqual(java.lang.Object value1,
                       java.lang.Object value2)
Description copied from interface: XSSimpleType
Check whether two actual values are equal.

Specified by:
isEqual in interface XSSimpleType
Parameters:
value1 - the first value
value2 - the second value
Returns:
true if the two value are equal

isIdentical

public boolean isIdentical(java.lang.Object value1,
                           java.lang.Object value2)

normalize

public static java.lang.String normalize(java.lang.String content,
                                         short ws)

getOrdered

public short getOrdered()
Fundamental Facet: ordered.

Specified by:
getOrdered in interface XSSimpleTypeDefinition

getBounded

public boolean getBounded()
Fundamental Facet: bounded.

Specified by:
getBounded in interface XSSimpleTypeDefinition

getFinite

public boolean getFinite()
Fundamental Facet: cardinality.

Specified by:
getFinite in interface XSSimpleTypeDefinition

getNumeric

public boolean getNumeric()
Fundamental Facet: numeric.

Specified by:
getNumeric in interface XSSimpleTypeDefinition

isDefinedFacet

public boolean isDefinedFacet(short facetName)
Convenience method. [Facets]: check whether a facet is defined on this type.

Specified by:
isDefinedFacet in interface XSSimpleTypeDefinition
Parameters:
facetName - The name of the facet.
Returns:
True if the facet is defined, false otherwise.

getDefinedFacets

public short getDefinedFacets()
[facets]: all facets defined on this type. The value is a bit combination of FACET_XXX constants of all defined facets.

Specified by:
getDefinedFacets in interface XSSimpleTypeDefinition

isFixedFacet

public boolean isFixedFacet(short facetName)
Convenience method. [Facets]: check whether a facet is defined and fixed on this type.

Specified by:
isFixedFacet in interface XSSimpleTypeDefinition
Parameters:
facetName - The name of the facet.
Returns:
True if the facet is fixed, false otherwise.

getFixedFacets

public short getFixedFacets()
[facets]: all defined facets for this type which are fixed.

Specified by:
getFixedFacets in interface XSSimpleTypeDefinition

getLexicalFacetValue

public java.lang.String getLexicalFacetValue(short facetName)
Convenience method. Returns a value of a single constraining facet for this simple type definition. This method must not be used to retrieve values for enumeration and pattern facets.

Specified by:
getLexicalFacetValue in interface XSSimpleTypeDefinition
Parameters:
facetName - The name of the facet, i.e. FACET_LENGTH, FACET_TOTALDIGITS (see XSConstants). To retrieve the value for a pattern or an enumeration, see enumeration and pattern.
Returns:
A value of the facet specified in facetName for this simple type definition or null.

getLexicalEnumeration

public StringList getLexicalEnumeration()
A list of enumeration values if it exists, otherwise an empty StringList.

Specified by:
getLexicalEnumeration in interface XSSimpleTypeDefinition

getActualEnumeration

public ObjectList getActualEnumeration()
A list of actual enumeration values if it exists, otherwise an empty ObjectList.


getEnumerationItemTypeList

public ObjectList getEnumerationItemTypeList()
A list of enumeration type values (as a list of ShortList objects) if it exists, otherwise returns null


getEnumerationTypeList

public ShortList getEnumerationTypeList()

getLexicalPattern

public StringList getLexicalPattern()
A list of pattern values if it exists, otherwise an empty StringList.

Specified by:
getLexicalPattern in interface XSSimpleTypeDefinition

getAnnotations

public XSObjectList getAnnotations()
[annotations]: a set of annotations for this simple type component if it exists, otherwise an empty XSObjectList.

Specified by:
getAnnotations in interface XSSimpleTypeDefinition

derivedFromType

public boolean derivedFromType(XSTypeDefinition ancestor,
                               short derivation)
Description copied from interface: XSTypeDefinition
Convenience method which checks if this type is derived from the given ancestorType.

Specified by:
derivedFromType in interface XSTypeDefinition
Parameters:
ancestor - An ancestor type definition.
derivation - A bit combination representing a subset of { DERIVATION_RESTRICTION, DERIVATION_EXTENSION, DERIVATION_UNION, DERIVATION_LIST }.
Returns:
True if this type is derived from ancestorType using only derivation methods from the derivationMethod .

derivedFrom

public boolean derivedFrom(java.lang.String ancestorNS,
                           java.lang.String ancestorName,
                           short derivation)
Description copied from interface: XSTypeDefinition
Convenience method which checks if this type is derived from the given ancestor type.

Specified by:
derivedFrom in interface XSTypeDefinition
Parameters:
ancestorNS - An ancestor type namespace.
ancestorName - An ancestor type name.
derivation - A bit combination representing a subset of { DERIVATION_RESTRICTION, DERIVATION_EXTENSION, DERIVATION_UNION, DERIVATION_LIST }.
Returns:
True if this type is derived from ancestorType using only derivation methods from the derivationMethod .

isDOMDerivedFrom

public boolean isDOMDerivedFrom(java.lang.String ancestorNS,
                                java.lang.String ancestorName,
                                int derivationMethod)
Checks if a type is derived from another by restriction, given the name and namespace. See: http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom

Parameters:
ancestorNS - The namspace of the ancestor type declaration
ancestorName - The name of the ancestor type declaration
derivationMethod - The derivation method
Returns:
boolean True if the ancestor type is derived from the reference type by the specifiied derivation method.

reset

public void reset()

getNamespaceItem

public XSNamespaceItem getNamespaceItem()
Description copied from interface: XSObject
A namespace schema information item corresponding to the target namespace of the component, if it is globally declared; or null otherwise.

Specified by:
getNamespaceItem in interface XSObject
See Also:
XSObject.getNamespaceItem()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

getFacets

public XSObjectList getFacets()
A list of constraining facets if it exists, otherwise an empty XSObjectList. Note: This method must not be used to retrieve values for enumeration and pattern facets.

Specified by:
getFacets in interface XSSimpleTypeDefinition

getMultiValueFacets

public XSObjectList getMultiValueFacets()
A list of enumeration and pattern constraining facets if it exists, otherwise an empty XSObjectList.

Specified by:
getMultiValueFacets in interface XSSimpleTypeDefinition

getMinInclusiveValue

public java.lang.Object getMinInclusiveValue()

getMinExclusiveValue

public java.lang.Object getMinExclusiveValue()

getMaxInclusiveValue

public java.lang.Object getMaxInclusiveValue()

getMaxExclusiveValue

public java.lang.Object getMaxExclusiveValue()

setAnonymous

public void setAnonymous(boolean anon)

getTypeNamespace

public java.lang.String getTypeNamespace()
Description copied from interface: TypeInfo
The namespace of the type declared for the associated element or attribute or null if the element does not have declaration or if no namespace information is available.

Specified by:
getTypeNamespace in interface TypeInfo

isDerivedFrom

public boolean isDerivedFrom(java.lang.String typeNamespaceArg,
                             java.lang.String typeNameArg,
                             int derivationMethod)
Description copied from interface: TypeInfo
This method returns if there is a derivation between the reference type definition, i.e. the TypeInfo on which the method is being called, and the other type definition, i.e. the one passed as parameters.

Specified by:
isDerivedFrom in interface TypeInfo
Parameters:
typeNamespaceArg - the namespace of the other type definition.
typeNameArg - the name of the other type definition.
derivationMethod - the type of derivation and conditions applied between two types, as described in the list of constants provided in this interface.
Returns:
If the document's schema is a DTD or no schema is associated with the document, this method will always return false . If the document's schema is an XML Schema, the method will true if the reference type definition is derived from the other type definition according to the derivation parameter. If the value of the parameter is 0 (no bit is set to 1 for the derivationMethod parameter), the method will return true if the other type definition can be reached by recursing any combination of {base type definition}, {item type definition}, or {member type definitions} from the reference type definition.