ClassInfo classInfo = state.getClassInfo();
JClass jClass = state.getJClass();
boolean creatingForAnElement =
(component.getAnnotated().getStructureType() == Structure.ELEMENT);
ComplexType complexType = (ComplexType) type;
if (complexType.isTopLevel() && creatingForAnElement) {
//--move the view and keep the structure
Annotated saved = component.getAnnotated();
String previousPackage = component.getJavaPackage();
XMLBindingComponent baseComponent = new XMLBindingComponent(
getConfig(), getGroupNaming());
baseComponent.setBinding(component.getBinding());
baseComponent.setView(complexType);
//-- call createSourceCode to pre-process the complexType
createSourceCode(baseComponent, sgState);
String baseClassName = null;
String basePackage = baseComponent.getJavaPackage();
//--if the base class is not in the same package
//--of the current class then we have to qualify the base
//--class
if (basePackage != null && !basePackage.equals(previousPackage)) {
baseClassName = baseComponent.getQualifiedName();
if (baseClassName.indexOf('.') == -1) {
//--be sure it is a valid className
baseClassName = getJavaNaming().toJavaClassName(baseClassName);
}
} else {
baseClassName = baseComponent.getJavaClassName();
}
jClass.setSuperClass(baseClassName);
basePackage = null;
baseClassName = null;
component.setView(saved);
saved = null;
} else if (complexType.isTopLevel() || creatingForAnElement) {
//generate class if the complexType is anonymous and we create classes
//for an element OR if the complexType is top-level and we create
//classes for it.
//-- check Group type
if (complexType.getParticleCount() == 1) {
Particle particle = complexType.getParticle(0);
if (particle.getStructureType() == Structure.GROUP) {
Group group = (Group) particle;
if (group.getOrder() == Order.choice) {
new XMLInfoNature(classInfo).getGroupInfo().setAsChoice();
}