com.sun.msv.datatype.xsd
Class UnionType

java.lang.Object
  extended by com.sun.msv.datatype.xsd.XSDatatypeImpl
      extended by com.sun.msv.datatype.xsd.ConcreteType
          extended by com.sun.msv.datatype.xsd.UnionType
All Implemented Interfaces:
DatabindableDatatype, XSDatatype, Serializable, org.relaxng.datatype.Datatype

public final class UnionType
extends ConcreteType

union type.

Author:
Kohsuke KAWAGUCHI
See Also:
Serialized Form

Field Summary
 XSDatatypeImpl[] memberTypes
          member types
 
Fields inherited from class com.sun.msv.datatype.xsd.XSDatatypeImpl
ERR_DUPLICATE_FACET, ERR_EMPTY_UNION, ERR_ENUMERATION, ERR_ENUMERATION_WITH_ARG, ERR_FACET_MUST_BE_NON_NEGATIVE_INTEGER, ERR_FACET_MUST_BE_POSITIVE_INTEGER, ERR_INAPPROPRIATE_FOR_TYPE, ERR_INCONSISTENT_FACETS_1, ERR_INCONSISTENT_FACETS_2, ERR_INVALID_BASE_TYPE, ERR_INVALID_ITEMTYPE, ERR_INVALID_MEMBER_TYPE, ERR_INVALID_VALUE_FOR_THIS_TYPE, ERR_INVALID_WHITESPACE_VALUE, ERR_LENGTH, ERR_LOOSENED_FACET, ERR_MAXLENGTH, ERR_MINLENGTH, ERR_NOT_APPLICABLE_FACET, ERR_OUT_OF_RANGE, ERR_OVERRIDING_FIXED_FACET, ERR_PARSE_ERROR, ERR_PATTERN_1, ERR_PATTERN_MANY, ERR_SCALE_IS_GREATER_THAN_PRECISION, ERR_TOO_MUCH_PRECISION, ERR_TOO_MUCH_SCALE, ERR_X_AND_Y_ARE_EXCLUSIVE, serializedValueChecker, whiteSpace
 
Fields inherited from interface com.sun.msv.datatype.xsd.XSDatatype
APPLICABLE, DERIVATION_BY_LIST, DERIVATION_BY_RESTRICTION, DERIVATION_BY_UNION, FACET_ENUMERATION, FACET_FRACTIONDIGITS, FACET_LENGTH, FACET_MAXEXCLUSIVE, FACET_MAXINCLUSIVE, FACET_MAXLENGTH, FACET_MINEXCLUSIVE, FACET_MININCLUSIVE, FACET_MINLENGTH, FACET_PATTERN, FACET_TOTALDIGITS, FACET_WHITESPACE, FIXED, NOT_ALLOWED, VARIETY_ATOMIC, VARIETY_LIST, VARIETY_UNION, XMLSCHEMA_NSURI
 
Fields inherited from interface org.relaxng.datatype.Datatype
ID_TYPE_ID, ID_TYPE_IDREF, ID_TYPE_IDREFS, ID_TYPE_NULL
 
Constructor Summary
UnionType(String nsUri, String newTypeName, XSDatatype[] memberTypes)
          derives a new datatype from atomic datatypes by union
 
Method Summary
protected  void _checkValid(String content, org.relaxng.datatype.ValidationContext context)
          actual 'meat' of the checkValid method
 Object _createValue(String content, org.relaxng.datatype.ValidationContext context)
          converts a whitespace-processed lexical value into the corresponding value object
protected  boolean checkFormat(String content, org.relaxng.datatype.ValidationContext context)
           
 String convertToLexicalValue(Object o, SerializationContext context)
          converts value object back to the corresponding value in the lexical space.
 String displayName()
          gets the displayable name of this type.
 XSDatatype getBaseType()
          gets the base type of this type.
 Class getJavaObjectType()
          gets the type of the objects that are created by the createJavaObject method.
 int getVariety()
          Variety of the UnionType is VARIETY_UNION.
 boolean isContextDependent()
          The union type is context-dependent if one of the member types is so.
 int isFacetApplicable(String facetName)
          returns if the specified facet is applicable to this datatype.
 
Methods inherited from class com.sun.msv.datatype.xsd.ConcreteType
_createJavaObject, getConcreteType, isFinal, serializeJavaObject
 
Methods inherited from class com.sun.msv.datatype.xsd.XSDatatypeImpl
checkValid, createJavaObject, createStreamingValidator, createValue, getAncestorBuiltinType, getApplicableFacetNames, getFacetObject, getIdType, getName, getNamespaceUri, isAlwaysValid, isDerivedTypeOf, isDerivedTypeOf, isValid, localize, localize, localize, localize, localize, needValueCheck, sameValue, valueHashCode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

memberTypes

public final XSDatatypeImpl[] memberTypes
member types

Constructor Detail

UnionType

public UnionType(String nsUri,
                 String newTypeName,
                 XSDatatype[] memberTypes)
          throws org.relaxng.datatype.DatatypeException
derives a new datatype from atomic datatypes by union

Throws:
org.relaxng.datatype.DatatypeException
Method Detail

getBaseType

public final XSDatatype getBaseType()
Description copied from interface: XSDatatype
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.


displayName

public final String displayName()
Description copied from interface: XSDatatype
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.


isContextDependent

public boolean isContextDependent()
The union type is context-dependent if one of the member types is so.

Specified by:
isContextDependent in interface org.relaxng.datatype.Datatype
Overrides:
isContextDependent in class XSDatatypeImpl

getVariety

public final int getVariety()
Variety of the UnionType is VARIETY_UNION. So this method always returns VARIETY_UNION.

Returns:
VARIETY_ATOMIC, VARIETY_LIST, or VARIETY_UNION.

isFacetApplicable

public final int isFacetApplicable(String facetName)
Description copied from interface: XSDatatype
returns if the specified facet is applicable to this datatype.

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.

checkFormat

protected final boolean checkFormat(String content,
                                    org.relaxng.datatype.ValidationContext context)
Specified by:
checkFormat in class XSDatatypeImpl

_createValue

public Object _createValue(String content,
                           org.relaxng.datatype.ValidationContext context)
Description copied from class: XSDatatypeImpl
converts a whitespace-processed lexical value into the corresponding value object

Specified by:
_createValue in class XSDatatypeImpl

getJavaObjectType

public Class getJavaObjectType()
Description copied from interface: DatabindableDatatype
gets the type of the objects that are created by the createJavaObject method.


convertToLexicalValue

public String convertToLexicalValue(Object o,
                                    SerializationContext context)
Description copied from interface: XSDatatype
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.

context - 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.

_checkValid

protected void _checkValid(String content,
                           org.relaxng.datatype.ValidationContext context)
                    throws org.relaxng.datatype.DatatypeException
Description copied from class: XSDatatypeImpl
actual 'meat' of the checkValid method

Overrides:
_checkValid in class ConcreteType
Throws:
org.relaxng.datatype.DatatypeException


MSV