org.jbind.xml.schema.cmp
Class AbstractType

java.lang.Object
  extended byorg.jbind.xml.schema.cmp.Component
      extended byorg.jbind.xml.schema.cmp.AbstractType
All Implemented Interfaces:
IAnyType, IComponent, IHasBindingAttributes, IHasLocation, ISourceInfo
Direct Known Subclasses:
AnyType, ComplexType, SimpleType

public abstract class AbstractType
extends Component
implements IAnyType

Represents a type.


Constructor Summary
AbstractType(ISourceInfo aSourceInfo, java.lang.String aNamespace, java.lang.String aName, java.lang.String aRole, java.util.Set aFinalTypes, java.util.Set aBlockTypes, boolean anIsAbstract)
           
 
Method Summary
 void addDirectSubtype(IAnyType aType)
          Adds a type to the collection of direct subtypes.
protected  void addFinalType(FinalType aFinalType)
           
 boolean canBeOverloadedBy(IAnyType aType)
          Checks if this type can be overloaded by the specified type.
 void checkConstraints(ICheckContext aContext)
          Checks the constraints of this type.
 IAnyTypeData createData(IDataImpl anImpl)
          Creates a data object for the specified data implementation.
 IAnyTypeData createEmptyData(IDataImpl anImpl)
          Creates an empty data object for the specified implementation.
 IAnyTypeData createUncheckedData(IDataImpl anImpl)
          Creates a data object for the specified data implementation.
protected  IAnyTypeData doCreateEmptyData(IDataImpl anImpl)
           
 IAttrDesc getAttrDesc(java.lang.String aNamespace, java.lang.String aName, IHasLocation aHasLocation)
          Gets an attribute description.
 IAttributesModel getAttributesModel()
          Gets the attributes model.
 IAnyType getBaseType()
          Gets the base type.
 IConstraints getConstraints()
          Gets the constraints imposed on this type.
 IContentModel getContentModel()
          Gets the content model.
 IDataCreator getDataCreator()
          Gets the data creator.
 java.util.Collection getDirectSubtypes()
          Gets the types that are direct subtypes of this type.
 IElemDesc getElemDesc(java.lang.String aNamespace, java.lang.String aName)
          Gets an element description.
 java.lang.String getRoleName()
          Gets the role name of the type.
 java.util.Collection getSubtypes()
          Recursively collects the subtypes of this type.
 ISymbolspace getSymbolspace()
          Gets the symbol space.
 boolean isAbstract()
          Checks if the type is abstract.
 boolean isActive(BlockType aBlockType)
          Checks if the specified block type is active.
 boolean isActive(FinalType aFinalType)
          Checks if the specified final type is active.
 boolean isBaseType(IAnyType aType)
          Checks if this type is a base type of the specified type.
 boolean isExtension(IAnyType aType)
          Checks if this type is an extension of the specified type.
 boolean isInstanceType(IAnyType aType)
          Checks if this type is an instance type of the specified type.
 boolean isReference()
          Checks if this component is defined as a reference to another component.
 boolean isRestriction(IAnyType aType)
          Checks if this type is a restriction of the specified type.
protected abstract  boolean isUnion()
           
 void setAttributesModel(IAttributesModel anAttributesModel)
           
 void setBaseType(IAnyType aType)
          Sets the base type.
 void setConstraints(IConstraints aConstraints)
          Sets the constraints.
 void setContentModel(IContentModel aContentModel)
           
 void setDataCreator(IDataCreator aCreator)
          Sets the data creator.
 void validate(IConstraintViolations aViolations)
          Validates the component.
 
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
checkEnclosedConstraints, getInstanceType, getSimpleContentType, getSimpleStorageType, getXPathMethods, isComplex, isExtension, isSimple
 
Methods inherited from interface org.jbind.xml.core.cmp.IComponent
accept, addSubComponent, getBindings, getGlobalRef, getName, getNamespace, getParentComponent, isAnonymous, 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

AbstractType

public AbstractType(ISourceInfo aSourceInfo,
                    java.lang.String aNamespace,
                    java.lang.String aName,
                    java.lang.String aRole,
                    java.util.Set aFinalTypes,
                    java.util.Set aBlockTypes,
                    boolean anIsAbstract)
Method Detail

getDataCreator

public final IDataCreator getDataCreator()
Description copied from interface: IAnyType
Gets the data creator. All types except abstract types and union types have a data creator.

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

setDataCreator

public final void setDataCreator(IDataCreator aCreator)
Description copied from interface: IAnyType
Sets the data creator.

Specified by:
setDataCreator in interface IAnyType
Parameters:
aCreator - (optional).

getRoleName

public java.lang.String getRoleName()
Description copied from interface: IAnyType
Gets the role name of the type. Only types that are anonymous have a role name. Examples of role names are "itemType" or "memberType0". Role names are unique in the context of the enclosing declaration of a type.

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

setBaseType

public void setBaseType(IAnyType aType)
Description copied from interface: IAnyType
Sets the base type.

Specified by:
setBaseType in interface IAnyType
Parameters:
aType - (required).

getBaseType

public IAnyType getBaseType()
Description copied from interface: IAnyType
Gets the base type. Every type except the "anyType" has a base type.

Specified by:
getBaseType in interface IAnyType
Returns:
A type (optional).

addDirectSubtype

public void addDirectSubtype(IAnyType aType)
Description copied from interface: IAnyType
Adds a type to the collection of direct subtypes.

Specified by:
addDirectSubtype in interface IAnyType
Parameters:
aType - (required).

getDirectSubtypes

public java.util.Collection getDirectSubtypes()
Description copied from interface: IAnyType
Gets the types that are direct subtypes of this type. This type itself is not included in the collection.

Specified by:
getDirectSubtypes in interface IAnyType
Returns:
(required). A collection of IAnyType.

getSubtypes

public java.util.Collection getSubtypes()
Description copied from interface: IAnyType
Recursively collects the subtypes of this type. This type itself is not included in the collection.

Specified by:
getSubtypes in interface IAnyType
Returns:
(required). A collection of IAnyType.

isBaseType

public boolean isBaseType(IAnyType aType)
Description copied from interface: IAnyType
Checks if this type is a base type of the specified type. A type is a base type of some other type if it is the same type or the other type was either directly or indirectly derived from it.

Specified by:
isBaseType in interface IAnyType
Parameters:
aType - The type to check. (optional)
Returns:
Returns true iff this type is a base type of the specified type.

isAbstract

public boolean isAbstract()
Description copied from interface: IAnyType
Checks if the type is abstract.

Specified by:
isAbstract in interface IAnyType
Returns:
Returns true iff the type is abstract.

getSymbolspace

public ISymbolspace getSymbolspace()
Description copied from interface: IComponent
Gets the symbol space. A component that is not anonymous has a symbol space.

Specified by:
getSymbolspace in interface IComponent
Returns:
(optional).

isActive

public boolean isActive(FinalType aFinalType)
Description copied from interface: IAnyType
Checks if the specified final type is active.

Specified by:
isActive in interface IAnyType
Parameters:
aFinalType - (required).
Returns:
Returns true iff the specified final type is active.

isActive

public boolean isActive(BlockType aBlockType)
Description copied from interface: IAnyType
Checks if the specified block type is active.

Specified by:
isActive in interface IAnyType
Parameters:
aBlockType - (required).
Returns:
Returns true iff the specified block type is active.

addFinalType

protected void addFinalType(FinalType aFinalType)

createData

public final IAnyTypeData createData(IDataImpl anImpl)
                              throws XmlException
Description copied from interface: IAnyType
Creates a data object for the specified data implementation. All local constraints that are imposed on the data object by this type are checked.

Specified by:
createData in interface IAnyType
Parameters:
anImpl - (required).
Returns:
(required).
Throws:
XmlException - Raised iff the data object could not be created.

createUncheckedData

public final IAnyTypeData createUncheckedData(IDataImpl anImpl)
                                       throws XmlException
Description copied from interface: IAnyType
Creates a data object for the specified data implementation. Only constraints that are inherent in the creation are checked (e.g. a number must not contain letters). Constraint that correspond to additionally applied facets are not checked.

Specified by:
createUncheckedData in interface IAnyType
Parameters:
anImpl - (required).
Returns:
(required).
Throws:
XmlException

createEmptyData

public final IAnyTypeData createEmptyData(IDataImpl anImpl)
                                   throws XmlException
Description copied from interface: IAnyType
Creates an empty data object for the specified implementation.

In general, the data implementation is not used while creating an empty data object. The created data object receives its implementation later when its setImpl method is called. The data implementation is passed to this method because in case of a union type the textual content of the implementation is used to decide which member type to instantiate.

The created data object has assigned its type.

Specified by:
createEmptyData in interface IAnyType
Parameters:
anImpl - (required).
Returns:
(required).
Throws:
XmlException

doCreateEmptyData

protected IAnyTypeData doCreateEmptyData(IDataImpl anImpl)
                                  throws XmlException
Throws:
XmlException

isUnion

protected abstract boolean isUnion()

checkConstraints

public final void checkConstraints(ICheckContext aContext)
Description copied from interface: IAnyType
Checks the constraints of this type.

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

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
Parameters:
aType - (required). The overloading type
Returns:
Returns true iff the specified type can overload this type.

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
Parameters:
aType - (required).

getContentModel

public final IContentModel getContentModel()
Description copied from interface: IAnyType
Gets the content model. Simple types return a simple content model.

Specified by:
getContentModel in interface IAnyType
Returns:
A content model. (required)

setContentModel

public final void setContentModel(IContentModel aContentModel)

getAttributesModel

public final IAttributesModel getAttributesModel()
Description copied from interface: IAnyType
Gets the attributes model. Simple types return an empty attributes model.

Specified by:
getAttributesModel in interface IAnyType
Returns:
An attributes model. (required)

setAttributesModel

public final void setAttributesModel(IAttributesModel anAttributesModel)

getConstraints

public final IConstraints getConstraints()
Description copied from interface: IAnyType
Gets the constraints imposed on this type.

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

setConstraints

public final void setConstraints(IConstraints aConstraints)
Description copied from interface: IAnyType
Sets the constraints.

Specified by:
setConstraints in interface IAnyType
Parameters:
aConstraints - (required).

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
Parameters:
aViolations - (required).

isExtension

public final boolean isExtension(IAnyType aType)
Description copied from interface: IAnyType
Checks if this type is an extension of the specified type. A type is an extension of another type if there is at least one derivation step in between them that is an extension.

Specified by:
isExtension in interface IAnyType
Parameters:
aType - (required).
Returns:
Returns true iff this type is an extension of the specified type.

isRestriction

public final boolean isRestriction(IAnyType aType)
Description copied from interface: IAnyType
Checks if this type is a restriction of the specified type. A type is a restriction of another type if there is at least one derivation step in between them that is a restriction.

Specified by:
isRestriction in interface IAnyType
Parameters:
aType - (required).
Returns:
Returns true iff this type is a restriction of the specified type.

getAttrDesc

public IAttrDesc getAttrDesc(java.lang.String aNamespace,
                             java.lang.String aName,
                             IHasLocation aHasLocation)
                      throws XmlException
Description copied from interface: IAnyType
Gets an attribute description.

Specified by:
getAttrDesc in interface IAnyType
Parameters:
aNamespace - (required).
aName - (required).
aHasLocation - (optional).
Returns:
(optional). If no declaration is returned then the attribute is to be skipped.
Throws:
XmlException - Raised iff the specified attribute is not allowed for the type.

getElemDesc

public final IElemDesc getElemDesc(java.lang.String aNamespace,
                                   java.lang.String aName)
                            throws XmlException
Description copied from interface: IAnyType
Gets an element description.

Specified by:
getElemDesc in interface IAnyType
Parameters:
aNamespace - (required).
aName - (required).
Returns:
(optional).
Throws:
XmlException - Raised iff the specified element is not contained in the type.

isReference

public boolean isReference()
Description copied from interface: IComponent
Checks if this component is defined as a reference to another component.

Specified by:
isReference in interface IComponent
Returns:
Returns true iff this component is a reference to another component.