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

java.lang.Object
  extended by com.sun.tools.xjc.reader.xmlschema.ct.CTBuilder
      extended by com.sun.tools.xjc.reader.xmlschema.ct.AbstractExtendedComplexTypeBuilder
Direct Known Subclasses:
ExtendedComplexTypeBuilder, MixedExtendedComplexTypeBuilder

abstract class AbstractExtendedComplexTypeBuilder
extends CTBuilder

Binds a complex type derived from another complex type by extension.


Field Summary
protected  java.util.Map<com.sun.xml.xsom.XSComplexType,org.kohsuke.rngom.nc.NameClass[]> characteristicNameClasses
          Map from XSComplexType to NameClass[2] that represents the names used in its child elements [0] and attributes [1].
protected  com.sun.xml.xsom.visitor.XSTermFunction<org.kohsuke.rngom.nc.NameClass> contentModelNameClassBuilder
          Computes a name class that represents everything in a given content model.
 
Fields inherited from class com.sun.tools.xjc.reader.xmlschema.ct.CTBuilder
bgmBuilder, builder, errorReceiver, green, schemas, selector, simpleTypeBuilder
 
Constructor Summary
AbstractExtendedComplexTypeBuilder()
           
 
Method Summary
protected  boolean checkCollision(org.kohsuke.rngom.nc.NameClass anc, org.kohsuke.rngom.nc.NameClass enc, com.sun.xml.xsom.XSComplexType type)
          Checks if the particles/attributes defined in the type parameter collides with the name classes of anc/enc.
protected  boolean checkIfExtensionSafe(com.sun.xml.xsom.XSComplexType baseType, com.sun.xml.xsom.XSComplexType thisType)
          Checks if this new extension is safe.
protected  com.sun.xml.xsom.XSComplexType getLastRestrictedType(com.sun.xml.xsom.XSComplexType t)
          Looks for the derivation chain t_1 > t_2 > ...
 
Methods inherited from class com.sun.tools.xjc.reader.xmlschema.ct.CTBuilder
build, isApplicable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

characteristicNameClasses

protected final java.util.Map<com.sun.xml.xsom.XSComplexType,org.kohsuke.rngom.nc.NameClass[]> characteristicNameClasses
Map from XSComplexType to NameClass[2] that represents the names used in its child elements [0] and attributes [1].


contentModelNameClassBuilder

protected final com.sun.xml.xsom.visitor.XSTermFunction<org.kohsuke.rngom.nc.NameClass> contentModelNameClassBuilder
Computes a name class that represents everything in a given content model.

Constructor Detail

AbstractExtendedComplexTypeBuilder

AbstractExtendedComplexTypeBuilder()
Method Detail

checkCollision

protected boolean checkCollision(org.kohsuke.rngom.nc.NameClass anc,
                                 org.kohsuke.rngom.nc.NameClass enc,
                                 com.sun.xml.xsom.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.

getLastRestrictedType

protected com.sun.xml.xsom.XSComplexType getLastRestrictedType(com.sun.xml.xsom.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.

checkIfExtensionSafe

protected boolean checkIfExtensionSafe(com.sun.xml.xsom.XSComplexType baseType,
                                       com.sun.xml.xsom.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.