* @param state the FactoryState.
**/
private void processComplexType
(ComplexType complexType, FactoryState state)
{
XMLBindingComponent component = new XMLBindingComponent(_config);
if (_binding != null) component.setBinding(_binding);
component.setView(complexType);
String typeName = component.getXMLName();
ClassInfo classInfo = state.classInfo;
classInfo.setSchemaType(new XSClass(state.jClass, typeName));
/// I don't believe this should be here: kv 20030423
///classInfo.setNamespaceURI(component.getTargetNamespace());
//- Handle derived types
XMLType base = complexType.getBaseType();
//-- if the base is a complexType, we need to process it
if (base != null) {
if (base.isComplexType()) {
String baseClassName = null;
component.setView(base);
//-- Is this base type from the schema we are currently generating source for?
//////////////////////////////////////////////////////////
//NOTE: generate sources if the flag for generating sources
//from imported schemas in on
//////////////////////////////////////////////////////////
if (base.getSchema() == complexType.getSchema()) {
ClassInfo cInfo = state.resolve(base);
//--no classInfo yet so no source code available
//--for the base type: we need to generate it
if (cInfo == null) {
JClass[] classes = createSourceCode(component, state.getSGStateInfo());
cInfo = state.resolve(base);
baseClassName = classes[0].getName();
} else {
baseClassName = cInfo.getJClass().getName();
}
//set the base class
classInfo.setBaseClass(cInfo);
} else {
//-- Create qualified class name for a base type class
//-- from another package
baseClassName = component.getQualifiedName();
}
//-- Set super class
//-- and reset the view on the current ComplexType
component.setView(complexType);
//--only set a super class name if the current complexType
//--is not a restriction of a simpleContent (--> no object hierarchy, only content hierarchy)
if (! ( complexType.isRestricted() && ((ComplexType)base).isSimpleContent() ) )
state.jClass.setSuperClass(baseClassName);
} //--complexType
//--if the content type is a simpleType create a field info for it.
if (complexType.getContentType().getType() == ContentType.SIMPLE) {
SimpleContent simpleContent = (SimpleContent)complexType.getContentType();
SimpleType temp = simpleContent.getSimpleType();
XSType xsType = _typeConversion.convertType(temp, state.packageName);
FieldInfo fieldInfo = memberFactory.createFieldInfoForContent(xsType);
handleField(fieldInfo,state);
}
}//--base not null
//---------------------/
//- handle attributes -/
//- and mixed content -/
//---------------------/
if (!state.isCreateGroupItem()) {
processAttributes(complexType, state);
//--reset the view on the current ComplexType
component.setView(complexType);
if (complexType.getContentType() == ContentType.mixed) {
FieldInfo fieldInfo = memberFactory.createFieldInfoForContent(new XSString());
handleField(fieldInfo, state);
}
}