//an imported schema to prevent class creation
//////////////////////////////////////////////////////
//4-- intialization of the JClass
ClassInfo classInfo = state.classInfo;
JClass jClass = state.jClass;
initialize(jClass);
//-- name information
classInfo.setNodeName(component.getXMLName());
//-- namespace information
classInfo.setNamespaceURI(component.getTargetNamespace());
//5--processing the type
XMLType type = component.getXMLType();
boolean createForSingleGroup = false;
boolean creatingForAnElement = false;
if (type != null) {
//5a--the type is a complexType
if (type.isComplexType()) {
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(_config);
baseComponent.setBinding(component.getBinding());
baseComponent.setView(complexType);
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 = JavaNaming.toJavaClassName(baseClassName);
}
} else {
baseClassName = baseComponent.getJavaClassName();
}
jClass.setSuperClass(baseClassName);
basePackage = null;
baseClassName = null;
component.setView(saved);
saved = null;
}
//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.
else if (complexType.isTopLevel() || creatingForAnElement) {
//-- 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) {
classInfo.getGroupInfo().setAsChoice();
}
}
}
Annotated saved = component.getAnnotated();
processComplexType(complexType, state);
component.setView(saved);
saved = null;
}
}
//--5b the type is a simpleType
else if (type.isSimpleType()) {
SimpleType simpleType = (SimpleType)type;
//-- handle our special case for enumerated types
if (simpleType.hasFacet(Facet.ENUMERATION)) {
//-- Don't create source code for simple types that
//-- don't belong in the elements target namespace
String tns = simpleType.getSchema().getTargetNamespace();
boolean create = false;
if (tns == null)
create = (component.getTargetNamespace() == null);
else
create = tns.equals(component.getTargetNamespace());
if (create) {
ClassInfo tmpInfo = sgState.resolve(simpleType);
JClass tmpClass = null;
if (tmpInfo != null) {
tmpClass = tmpInfo.getJClass();
}
else {
tmpClass = createSourceCode(simpleType, sgState);