com.sun.tools.xjc.reader.xmlschema.ct

Class AbstractExtendedComplexTypeBuilder

abstract class AbstractExtendedComplexTypeBuilder extends CTBuilder

Binds a complex type derived from another complex type by extension.
Field Summary
protected Map<XSComplexType,NameClass[]>characteristicNameClasses
Map from XSComplexType to NameClass[2] that represents the names used in its child elements [0] and attributes [1].
protected XSTermFunction<NameClass>contentModelNameClassBuilder
Computes a name class that represents everything in a given content model.
Method Summary
protected booleancheckCollision(NameClass anc, NameClass enc, XSComplexType type)
Checks if the particles/attributes defined in the type parameter collides with the name classes of anc/enc.
protected booleancheckIfExtensionSafe(XSComplexType baseType, XSComplexType thisType)
Checks if this new extension is safe.
protected XSComplexTypegetLastRestrictedType(XSComplexType t)
Looks for the derivation chain t_1 > t_2 > ...

Field Detail

characteristicNameClasses

protected final Map<XSComplexType,NameClass[]> characteristicNameClasses
Map from XSComplexType to NameClass[2] that represents the names used in its child elements [0] and attributes [1].

contentModelNameClassBuilder

protected final XSTermFunction<NameClass> contentModelNameClassBuilder
Computes a name class that represents everything in a given content model.

Method Detail

checkCollision

protected boolean checkCollision(NameClass anc, NameClass enc, XSComplexType type)
Checks if the particles/attributes defined in the type parameter collides with the name classes of anc/enc.

Returns: true if there's a collision.

checkIfExtensionSafe

protected boolean checkIfExtensionSafe(XSComplexType baseType, XSComplexType thisType)
Checks if this new extension is safe. UGLY.

If you have ctA extending ctB and ctB restricting ctC, our Java classes will look like CtAImpl extending CtBImpl extending CtCImpl.

Since a derived class unmarshaller uses the base class unmarshaller, this could potentially result in incorrect unmarshalling. We used to just reject such a case, but then we found that there are schemas that are using it.

One generalized observation that we reached is that if the extension is only adding new elements/attributes which has never been used in any of its base class (IOW, if none of the particle / attribute use / attribute wildcard can match the name of newly added elements/attributes) then it is safe to add them.

This function checks if the derivation chain to this type is not using restriction, and if it is, then checks if it is safe according to the above condition.

Returns: false If this complex type needs to be rejected.

getLastRestrictedType

protected XSComplexType getLastRestrictedType(XSComplexType t)
Looks for the derivation chain t_1 > t_2 > ... > t and find t_i such that t_i derives by restriction but for every j>i, t_j derives by extension.

Returns: null If there's no such t_i or if t_i is any type.