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

java.lang.Object
  |
  +--org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl
All Implemented Interfaces:
XSObject, XSSimpleType, XSSimpleTypeDefinition, XSTypeDecl, XSTypeDefinition

public class XSSimpleTypeDecl
extends java.lang.Object
implements XSSimpleType

Version:
$Id: XSSimpleTypeDecl.java,v 1.11 2002/06/17 18:41:45 elena Exp $
Author:
Sandy Gao, IBM, Neeraj Bajaj, Sun Microsystems, inc.

Field Summary
 
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_QNAME, PRIMITIVE_STRING, PRIMITIVE_TIME, WS_COLLAPSE, WS_PRESERVE, WS_REPLACE
 
Fields inherited from interface org.apache.xerces.impl.xs.psvi.XSTypeDefinition
COMPLEX_TYPE, SIMPLE_TYPE
 
Fields inherited from interface org.apache.xerces.impl.xs.psvi.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
 
Constructor Summary
  XSSimpleTypeDecl()
           
protected XSSimpleTypeDecl(java.lang.String name, java.lang.String uri, short finalSet, XSSimpleTypeDecl itemType)
           
protected XSSimpleTypeDecl(java.lang.String name, java.lang.String uri, short finalSet, XSSimpleTypeDecl[] memberTypes)
           
protected XSSimpleTypeDecl(XSSimpleTypeDecl base, java.lang.String name, short validateDV, short ordered, boolean bounded, boolean finite, boolean numeric)
           
protected XSSimpleTypeDecl(XSSimpleTypeDecl base, java.lang.String name, java.lang.String uri, short finalSet)
           
 
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)
          Experimental: return whether this type is derived from a type of the given namespace name and type name.
 boolean derivedFrom(XSTypeDefinition ancestor)
          Experimental: return whether this type is derived from a given type.
 XSAnnotation getAnnotation()
          Optional.
 XSTypeDefinition getBaseType()
          {base type definition} Either a simple type definition or a complex type definition.
 short getDefinedFacets()
          {Facets} Get all facets defined on this type.
 short getFinal()
          {final} For complex type definition it is a subset of {extension, restriction}.
 short getFixedFacets()
          {Facets} Get all facets defined and fixed on this type.
 boolean getIsAnonymous()
          A boolean that specifies if the type definition is anonymous.
 boolean getIsBounded()
          Fundamental Facet: [Definition:] A datatype is bounded if its value space has either an inclusive upper bound or an exclusive upper bound and either an inclusive lower bound and an exclusive lower bound.
 boolean getIsDefinedFacet(short facetName)
          {Facets} Check whether a facet is defined on this type.
 boolean getIsFinal(short derivation)
          {final} For complex type definition it is a subset of {extension, restriction}.
 boolean getIsFinite()
          Fundamental Facet: [Definition:] Every value space has associated with it the concept of cardinality.
 boolean getIsFixedFacet(short facetName)
          {Facets} Check whether a facet is defined and fixed on this type.
 boolean getIsNumeric()
          Fundamental Facet: [Definition:] A datatype is said to be numeric if its values are conceptually quantities (in some mathematical number system).
 XSSimpleTypeDefinition getItemType()
          If variety is list the item type definition (an atomic or union simple type definition) is available, otherwise null.
 StringList getLexicalEnumerations()
          Returns a list of enumeration values, as String's.
 java.lang.String getLexicalFacetValue(short facetName)
          Convenience method.
 StringList getLexicalPatterns()
          Returns a list of pattern values, as String's.
 XSObjectList getMemberTypes()
          If variety is union the list of member type definitions (a non-empty sequence of simple type definitions) is available, otherwise null.
 java.lang.String getName()
          The name of this XSObject depending on the XSObject type.
 java.lang.String getNamespace()
          The namespace URI of this node, or null if it is unspecified.
 short getOrdered()
          Fundamental Facet: [Definition:] An order relation on a value space is a mathematical relation that imposes a total order or a partial order on the members of the value space.
 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.
 java.lang.String getStringValue(java.lang.Object value)
           
 short getType()
          Get the type of the object, i.e ELEMENT_DECLARATION.
 short getTypeCategory()
          Return whether this type definition is a simple type or complex type.
 short getVariety()
          {variety} One of {atomic, list, union}.
 short getWhitespace()
          Return the whitespace corresponding to this datatype.
 boolean isEqual(java.lang.Object value1, java.lang.Object value2)
          Check whether two actual values are equal.
 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()
           
protected  XSSimpleTypeDecl setListValues(java.lang.String name, java.lang.String uri, short finalSet, XSSimpleTypeDecl itemType)
           
protected  XSSimpleTypeDecl setRestrictionValues(XSSimpleTypeDecl base, java.lang.String name, java.lang.String uri, short finalSet)
           
protected  XSSimpleTypeDecl setUnionValues(java.lang.String name, java.lang.String uri, short finalSet, XSSimpleTypeDecl[] memberTypes)
           
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XSSimpleTypeDecl

public XSSimpleTypeDecl()

XSSimpleTypeDecl

protected XSSimpleTypeDecl(XSSimpleTypeDecl base,
                           java.lang.String name,
                           short validateDV,
                           short ordered,
                           boolean bounded,
                           boolean finite,
                           boolean numeric)

XSSimpleTypeDecl

protected XSSimpleTypeDecl(XSSimpleTypeDecl base,
                           java.lang.String name,
                           java.lang.String uri,
                           short finalSet)

XSSimpleTypeDecl

protected XSSimpleTypeDecl(java.lang.String name,
                           java.lang.String uri,
                           short finalSet,
                           XSSimpleTypeDecl itemType)

XSSimpleTypeDecl

protected XSSimpleTypeDecl(java.lang.String name,
                           java.lang.String uri,
                           short finalSet,
                           XSSimpleTypeDecl[] memberTypes)
Method Detail

setRestrictionValues

protected XSSimpleTypeDecl setRestrictionValues(XSSimpleTypeDecl base,
                                                java.lang.String name,
                                                java.lang.String uri,
                                                short finalSet)

setListValues

protected XSSimpleTypeDecl setListValues(java.lang.String name,
                                         java.lang.String uri,
                                         short finalSet,
                                         XSSimpleTypeDecl itemType)

setUnionValues

protected XSSimpleTypeDecl setUnionValues(java.lang.String name,
                                          java.lang.String uri,
                                          short finalSet,
                                          XSSimpleTypeDecl[] memberTypes)

getType

public short getType()
Description copied from interface: XSObject
Get the type of the 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 this XSObject depending on the XSObject type.

Specified by:
getName in interface XSObject

getNamespace

public java.lang.String getNamespace()
Description copied from interface: XSObject
The namespace URI of this node, or null if it is unspecified. defines how a namespace URI is attached to schema components.

Specified by:
getNamespace in interface XSObject

getFinal

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

Specified by:
getFinal in interface XSTypeDefinition
Returns:
A bit flag that represents: {extension, restriction) or none for complexTypes; {extension, list, restriction, union} or none for simpleTypes;

getIsFinal

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

Specified by:
getIsFinal in interface XSTypeDefinition
Parameters:
derivation - Extension, restriction, list, union constants (defined in XSConstants).
Returns:
True if derivation 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

getIsAnonymous

public boolean getIsAnonymous()
Description copied from interface: XSTypeDefinition
A boolean that specifies if the type definition is anonymous. Convenience attribute. This is a field is not part of XML Schema component model.

Specified by:
getIsAnonymous in interface XSTypeDefinition

getVariety

public short getVariety()
Description copied from interface: XSSimpleTypeDefinition
{variety} One of {atomic, list, union}. The valid constant values defined in XSConstants are UNION, LIST, ATOMIC.

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

getPrimitiveType

public XSSimpleTypeDefinition getPrimitiveType()
Description copied from interface: XSSimpleTypeDefinition
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()
Description copied from interface: XSSimpleTypeDefinition
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()
Description copied from interface: XSSimpleTypeDefinition
If variety is union the list of member type definitions (a non-empty sequence of simple type definitions) is available, otherwise null.

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
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
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
Returns:
true if the two value are equal

normalize

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

getStringValue

public java.lang.String getStringValue(java.lang.Object value)

getOrdered

public short getOrdered()
Description copied from interface: XSSimpleTypeDefinition
Fundamental Facet: [Definition:] An order relation on a value space is a mathematical relation that imposes a total order or a partial order on the members of the value space.

Specified by:
getOrdered in interface XSSimpleTypeDefinition

getIsBounded

public boolean getIsBounded()
Description copied from interface: XSSimpleTypeDefinition
Fundamental Facet: [Definition:] A datatype is bounded if its value space has either an inclusive upper bound or an exclusive upper bound and either an inclusive lower bound and an exclusive lower bound. Should bounded be of type boolean? Should this facet provide more information (discontinuous)?

Specified by:
getIsBounded in interface XSSimpleTypeDefinition

getIsFinite

public boolean getIsFinite()
Description copied from interface: XSSimpleTypeDefinition
Fundamental Facet: [Definition:] Every value space has associated with it the concept of cardinality. Some value spaces are finite, some are countably infinite while still others could conceivably be uncountably infinite (although no value space defined by this specification is uncountable infinite). A datatype is said to have the cardinality of its value space.

Specified by:
getIsFinite in interface XSSimpleTypeDefinition

getIsNumeric

public boolean getIsNumeric()
Description copied from interface: XSSimpleTypeDefinition
Fundamental Facet: [Definition:] A datatype is said to be numeric if its values are conceptually quantities (in some mathematical number system). [Definition:] A datatype whose values are not numeric is said to be non-numeric.

Specified by:
getIsNumeric in interface XSSimpleTypeDefinition

getIsDefinedFacet

public boolean getIsDefinedFacet(short facetName)
Description copied from interface: XSSimpleTypeDefinition
{Facets} Check whether a facet is defined on this type.

Specified by:
getIsDefinedFacet in interface XSSimpleTypeDefinition
Parameters:
facetName - The name of the facet.
Returns:
true if the facet is defined; false othereise.

getDefinedFacets

public short getDefinedFacets()
Description copied from interface: XSSimpleTypeDefinition
{Facets} Get all facets defined on this type.

Specified by:
getDefinedFacets in interface XSSimpleTypeDefinition
Returns:
bit combination of FACET_XXX constants of all defined facets.

getIsFixedFacet

public boolean getIsFixedFacet(short facetName)
Description copied from interface: XSSimpleTypeDefinition
{Facets} Check whether a facet is defined and fixed on this type.

Specified by:
getIsFixedFacet in interface XSSimpleTypeDefinition
Parameters:
facetName - The name of the facet.
Returns:
true if the facet is defined and fixed; false othereise.

getFixedFacets

public short getFixedFacets()
Description copied from interface: XSSimpleTypeDefinition
{Facets} Get all facets defined and fixed on this type.

Specified by:
getFixedFacets in interface XSSimpleTypeDefinition
Returns:
bit combination of FACET_XXX constants of all fixed facets.

getLexicalFacetValue

public java.lang.String getLexicalFacetValue(short facetName)
Description copied from interface: XSSimpleTypeDefinition
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 value for pattern or enumeration, see enumeration and pattern.
Returns:
A value of the facet specified in facetName for this simple type definition or null.

getLexicalEnumerations

public StringList getLexicalEnumerations()
Description copied from interface: XSSimpleTypeDefinition
Returns a list of enumeration values, as String's.

Specified by:
getLexicalEnumerations in interface XSSimpleTypeDefinition

getLexicalPatterns

public StringList getLexicalPatterns()
Description copied from interface: XSSimpleTypeDefinition
Returns a list of pattern values, as String's.

Specified by:
getLexicalPatterns in interface XSSimpleTypeDefinition

getAnnotation

public XSAnnotation getAnnotation()
Description copied from interface: XSSimpleTypeDefinition
Optional. Annotation.

Specified by:
getAnnotation in interface XSSimpleTypeDefinition

derivedFrom

public boolean derivedFrom(XSTypeDefinition ancestor)
Description copied from interface: XSTypeDecl
Experimental: return whether this type is derived from a given type.

Specified by:
derivedFrom in interface XSTypeDecl

derivedFrom

public boolean derivedFrom(java.lang.String ancestorNS,
                           java.lang.String ancestorName)
Description copied from interface: XSTypeDecl
Experimental: return whether this type is derived from a type of the given namespace name and type name.

Specified by:
derivedFrom in interface XSTypeDecl

reset

public void reset()


Copyright © 1999-2002 Apache XML Project. All Rights Reserved.