use of org.eclipse.persistence.internal.oxm.schema.model.ComplexContent in project eclipselink by eclipse-ee4j.
the class SchemaGenerator method createComplexTypeForClass.
private ComplexType createComplexTypeForClass(JavaClass myClass, TypeInfo info) {
Schema schema = getSchemaForNamespace(info.getClassNamespace());
ComplexType type = new ComplexType();
JavaClass superClass = CompilerHelper.getNextMappedSuperClass(myClass, this.typeInfo, this.helper);
// Handle abstract class
if (myClass.isAbstract()) {
type.setAbstractValue(true);
}
Extension extension = null;
if (superClass != null) {
TypeInfo parentTypeInfo = this.typeInfo.get(superClass.getQualifiedName());
if (parentTypeInfo != null) {
extension = new Extension();
// may need to qualify the type
String parentPrefix = getPrefixForNamespace(schema, parentTypeInfo.getClassNamespace());
if (parentPrefix != null) {
extension.setBaseType(parentPrefix + COLON + parentTypeInfo.getSchemaTypeName());
} else {
extension.setBaseType(parentTypeInfo.getSchemaTypeName());
}
if (parentTypeInfo.getXmlValueProperty() != null) {
SimpleContent content = new SimpleContent();
content.setExtension(extension);
type.setSimpleContent(content);
return type;
} else {
ComplexContent content = new ComplexContent();
content.setExtension(extension);
type.setComplexContent(content);
}
}
}
TypeDefParticle compositor = null;
String[] propOrder = null;
if (info.isSetPropOrder()) {
propOrder = info.getPropOrder();
}
if (propOrder != null && propOrder.length == 0) {
// requires the extension case to use sequences
if (info.hasElementRefs()) {
// generate a sequence to satisfy TCK
compositor = new Sequence();
if (extension != null) {
extension.setSequence((Sequence) compositor);
} else {
type.setSequence((Sequence) compositor);
}
} else if (extension != null) {
compositor = new All();
extension.setAll((All) compositor);
} else {
compositor = new All();
type.setAll((All) compositor);
}
} else {
// generate a sequence to satisfy TCK
compositor = new Sequence();
if (extension != null) {
extension.setSequence((Sequence) compositor);
} else {
type.setSequence((Sequence) compositor);
}
}
return type;
}
use of org.eclipse.persistence.internal.oxm.schema.model.ComplexContent in project eclipselink by eclipse-ee4j.
the class SchemaModelGenerator method buildComplexType.
/**
* Create and return a ComplexType for a given XMLDescriptor. Assumes that the descriptor has a schema context
* set.
*/
protected ComplexType buildComplexType(boolean anonymous, Descriptor desc, HashMap<String, Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors) {
ComplexType ct = new ComplexType();
if (!anonymous) {
ct.setName(desc.getSchemaReference().getSchemaContextAsQName(workingSchema.getNamespaceResolver()).getLocalPart());
}
CoreInheritancePolicy inheritancePolicy = desc.getInheritancePolicyOrNull();
Extension extension = null;
if (inheritancePolicy != null && inheritancePolicy.getParentClass() != null) {
extension = new Extension();
extension.setBaseType(desc.getSchemaReference().getSchemaContextAsQName(workingSchema.getNamespaceResolver()).getLocalPart());
ComplexContent complexContent = new ComplexContent();
complexContent.setExtension(extension);
ct.setComplexContent(complexContent);
}
Sequence seq = new Sequence();
for (CoreMapping mapping : (Vector<CoreMapping>) desc.getMappings()) {
processMapping(mapping, seq, ct, schemaForNamespace, workingSchema, properties, descriptors);
}
if (extension != null) {
extension.setSequence(seq);
} else {
ct.setSequence(seq);
}
return ct;
}
Aggregations