org.jbind.xml.schema.cmp
Class UnionType

java.lang.Object
  extended byorg.jbind.xml.schema.cmp.Component
      extended byorg.jbind.xml.schema.cmp.AbstractType
          extended byorg.jbind.xml.schema.cmp.SimpleType
              extended byorg.jbind.xml.schema.cmp.UnionType
All Implemented Interfaces:
IAnySimpleType, IAnyType, IComponent, IHasBindingAttributes, IHasLocation, ISimpleType, ISourceInfo, IUnionType

public class UnionType
extends SimpleType
implements IUnionType


Constructor Summary
UnionType(ISourceInfo aSourceInfo, java.lang.String aNamespace, java.lang.String aName, java.lang.String aRole, java.util.Set aFinalTypes)
           
 
Method Summary
 void accept(IComponentVisitor aVisitor)
          Accepts a visitor.
 void addMemberType(ISimpleType aSimpleType, IConstraintViolations aViolations)
           
 boolean canBeOverloadedBy(IAnyType aType)
          Checks if this type can be overloaded by the specified type.
 void checkEnclosedConstraints(ICheckContext aContext)
          Checks the enclosed constraints.
 ISimpleType createRestriction(ISourceInfo aSourceInfo, java.lang.String aNamespace, java.lang.String aName, java.lang.String aRole, java.util.Set aFinalTypes, IConstraintViolations aViolations)
          Creates a simple type that is a restriction of this type.
protected  IAnyTypeData doCreateEmptyData(IDataImpl anImpl)
          Creates a data object for the specified implementation.
 IAnyType getInstanceType()
          Gets the type that instances of this type have.
 java.lang.Class getSimpleStorageType()
          Gets the simple storage type.
 boolean isApplicable(ConstraintType aConstraintType)
          Checks if the specified constraint type is applicable to the type.
 boolean isInstanceType(IAnyType aType)
          Checks if this type is an instance type of the specified type.
protected  boolean isUnion()
           
 java.util.Iterator iterMemberTypes()
           
 void validate(IConstraintViolations aViolations)
          Validates the component.
 
Methods inherited from class org.jbind.xml.schema.cmp.SimpleType
getSimpleContentType, getXPathMethods, isComplex, isExtension, isSimple
 
Methods inherited from class org.jbind.xml.schema.cmp.AbstractType
addDirectSubtype, addFinalType, checkConstraints, createData, createEmptyData, createUncheckedData, getAttrDesc, getAttributesModel, getBaseType, getConstraints, getContentModel, getDataCreator, getDirectSubtypes, getElemDesc, getRoleName, getSubtypes, getSymbolspace, isAbstract, isActive, isActive, isBaseType, isExtension, isReference, isRestriction, setAttributesModel, setBaseType, setConstraints, setContentModel, setDataCreator
 
Methods inherited from class org.jbind.xml.schema.cmp.Component
addSubComponent, getAnnotation, getBindingAttribute, getBindings, getDefaultedLocalBindingAttribute, getDefaultedLocalStringBindingAttribute, getGlobalRef, getLocalBindingAttribute, getLocalStringBindingAttribute, getLocation, getName, getNamespace, getParentComponent, getPrefixToNamespaceMapping, getStringBindingAttribute, isAnonymous, isTopLevelComponent, setBindings, setParentComponent, visitSubComponents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jbind.xml.core.type.IAnyType
addDirectSubtype, checkConstraints, createData, createEmptyData, createUncheckedData, getAttrDesc, getAttributesModel, getBaseType, getConstraints, getContentModel, getDataCreator, getDirectSubtypes, getElemDesc, getRoleName, getSimpleContentType, getSubtypes, getXPathMethods, isAbstract, isActive, isActive, isBaseType, isComplex, isExtension, isExtension, isRestriction, isSimple, setBaseType, setConstraints, setDataCreator
 
Methods inherited from interface org.jbind.xml.core.cmp.IComponent
addSubComponent, getBindings, getGlobalRef, getName, getNamespace, getParentComponent, getSymbolspace, isAnonymous, isReference, isTopLevelComponent, setBindings, setParentComponent
 
Methods inherited from interface org.jbind.xml.core.cmp.ISourceInfo
getAnnotation, getPrefixToNamespaceMapping
 
Methods inherited from interface org.jbind.xml.base.IHasLocation
getLocation
 
Methods inherited from interface org.jbind.xml.base.IHasBindingAttributes
getBindingAttribute, getDefaultedLocalBindingAttribute, getDefaultedLocalStringBindingAttribute, getLocalBindingAttribute, getLocalStringBindingAttribute, getStringBindingAttribute
 

Constructor Detail

UnionType

public UnionType(ISourceInfo aSourceInfo,
                 java.lang.String aNamespace,
                 java.lang.String aName,
                 java.lang.String aRole,
                 java.util.Set aFinalTypes)
Method Detail

isApplicable

public final boolean isApplicable(ConstraintType aConstraintType)
Description copied from interface: ISimpleType
Checks if the specified constraint type is applicable to the type.

Specified by:
isApplicable in interface ISimpleType
Parameters:
aConstraintType - (required).
Returns:
Returns true iff the constraint type is applicable on the type.

addMemberType

public void addMemberType(ISimpleType aSimpleType,
                          IConstraintViolations aViolations)

iterMemberTypes

public java.util.Iterator iterMemberTypes()
Specified by:
iterMemberTypes in interface IUnionType

validate

public void validate(IConstraintViolations aViolations)
Description copied from interface: IComponent
Validates the component. This method is called as the last step of the component construction.

Specified by:
validate in interface IComponent
Overrides:
validate in class AbstractType

doCreateEmptyData

protected IAnyTypeData doCreateEmptyData(IDataImpl anImpl)
                                  throws XmlException
Creates a data object for the specified implementation.

If an overloading type is specified then it is validated that the overloading type is contained in the member types. The overloading type is then used to create an unchecked data object.

If no overloading type is specified then a member type is looked for that can create a checked data object without constraint violations. If such a type is found then the created data object is returned. Otherwise it is tried to find a type that can create an unchecked data object. If such a type is found then the created data object is returned.

Overrides:
doCreateEmptyData in class AbstractType
Parameters:
anImpl - (required).
Returns:
(required).
Throws:
XmlException - Description of the Exception

canBeOverloadedBy

public boolean canBeOverloadedBy(IAnyType aType)
Description copied from interface: IAnyType
Checks if this type can be overloaded by the specified type. In general, all sub types of this type are valid overloading types. If this type is a union type then the specified type can also be an overloading type of any of the member types. Overloading constraints (i.e. that a type is blocked for extension or restriction) are not checked.

Specified by:
canBeOverloadedBy in interface IAnyType
Overrides:
canBeOverloadedBy in class AbstractType

isInstanceType

public boolean isInstanceType(IAnyType aType)
Description copied from interface: IAnyType
Checks if this type is an instance type of the specified type. In general, this type is an instance type of the specified type if the specified type is a base type of this type. If this type is a union type then this type is also an instance type if any of the union member types is an instance type.

Specified by:
isInstanceType in interface IAnyType
Overrides:
isInstanceType in class AbstractType

getInstanceType

public IAnyType getInstanceType()
Description copied from interface: IAnyType
Gets the type that instances of this type have. In general a type is also its instance type. In case of union types the instance type is the most specific common base type of all member types of the union.

Specified by:
getInstanceType in interface IAnyType
Returns:
(required).

checkEnclosedConstraints

public void checkEnclosedConstraints(ICheckContext aContext)
Description copied from interface: IAnyType
Checks the enclosed constraints. Depending on the type this method performs the following checks:

Specified by:
checkEnclosedConstraints in interface IAnyType
Parameters:
aContext - (required).

accept

public void accept(IComponentVisitor aVisitor)
            throws XmlException
Description copied from interface: IComponent
Accepts a visitor. The implementation calls the corresponding visitXXXStart and vistXXXEnd methods of the visitor (e.g. visitComplexTypeStart and visitComplexTypeEnd).

Specified by:
accept in interface IComponent
Parameters:
aVisitor - (required).
Throws:
XmlException

createRestriction

public ISimpleType createRestriction(ISourceInfo aSourceInfo,
                                     java.lang.String aNamespace,
                                     java.lang.String aName,
                                     java.lang.String aRole,
                                     java.util.Set aFinalTypes,
                                     IConstraintViolations aViolations)
Description copied from interface: ISimpleType
Creates a simple type that is a restriction of this type.

Specified by:
createRestriction in interface ISimpleType
Returns:
(required).

getSimpleStorageType

public java.lang.Class getSimpleStorageType()
Description copied from interface: IAnyType
Gets the simple storage type. The simple storage type is the Java type that is used to store the simple values of this type. A simple storage type can either be a primitive type (like int, boolean, float, ...) or a (simple) reference type (like String). Only non-complex types, i.e. atomic types, list types, union types, and restrictions of them have a simple storage type. In particular, complex types with simple content also return null.

Specified by:
getSimpleStorageType in interface IAnyType
Returns:
(optional).

isUnion

protected boolean isUnion()
Specified by:
isUnion in class AbstractType