private void buildGenericElements(XmlSchema schema, XmlSchemaSequence seq, Field f) { XmlSchemaComplexType generics = new XmlSchemaComplexType(schema, true); Type type = f.getGenericType(); String rawType = ((ParameterizedType)type).getRawType().toString(); String typeName = StringUtils.uncapitalize(rawType.substring(rawType.lastIndexOf(".") + 1)); generics.setName(typeName); Class<?> genericsClass = f.getType(); buildGenericSeq(schema, generics, genericsClass); String name = Character.toLowerCase(f.getName().charAt(0)) + f.getName().substring(1); XmlSchemaElement newel = new XmlSchemaElement(schema, false); newel.setName(name); newel.setSchemaTypeName(generics.getQName()); newel.setMinOccurs(0); if (!seq.getItems().contains(newel)) { seq.getItems().add(newel); } }
private XmlSchemaElement generateWrapper(QName el, XmlSchemaSequence wrappingSequence) { XmlSchemaComplexType schemaComplexType = new XmlSchemaComplexType(schema, false); schemaComplexType.setParticle(wrappingSequence); XmlSchemaElement wrappingSchemaElement = new XmlSchemaElement(schema, true); wrappingSchemaElement.setName(el.getLocalPart()); wrappingSchemaElement.setSchemaType(schemaComplexType); return wrappingSchemaElement; }
private void generateComplexTypeforException() { XmlSchemaSequence sequence = new XmlSchemaSequence(); XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace); QName elementName = new QName(schemaTargetNameSpace, "Exception", schema_namespace_prefix); XmlSchemaComplexType complexType = new XmlSchemaComplexType(xmlSchema, false); complexType.setName("Exception"); xmlSchema.getItems().add(complexType); xmlSchema.getSchemaTypes().put(elementName, complexType); typeTable.addComplexSchema(Exception.class.getName(), elementName); QName schemaTypeName = new QName(Java2WSDLConstants.URI_2001_SCHEMA_XSD, "string"); addContentToMethodSchemaType(sequence, schemaTypeName, "Message", false); complexType.setParticle(sequence); }
private void buildGenericElements(XmlSchema schema, XmlSchemaSequence seq, Method m, Type type) { String rawType = ((ParameterizedType)type).getRawType().toString(); String typeName = StringUtils.uncapitalize(rawType.substring(rawType.lastIndexOf(".") + 1)); XmlSchemaComplexType generics = (XmlSchemaComplexType)schema.getTypeByName(typeName); if (generics == null) { generics = new XmlSchemaComplexType(schema, true); generics.setName(typeName); } Class<?> genericsClass = m.getReturnType(); buildGenericSeq(schema, generics, genericsClass); int idx = m.getName().startsWith("get") ? 3 : 2; String name = m.getName().substring(idx); name = Character.toLowerCase(name.charAt(0)) + name.substring(1); XmlSchemaElement newel = new XmlSchemaElement(schema, false); newel.setName(name); newel.setSchemaTypeName(generics.getQName()); newel.setMinOccurs(0); if (!seq.getItems().contains(newel)) { seq.getItems().add(newel); } }
private void generateComplexTypeforException() { XmlSchemaSequence sequence = new XmlSchemaSequence(); XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace); QName elementName = new QName(schemaTargetNameSpace, "Exception", schema_namespace_prefix); XmlSchemaComplexType complexType = new XmlSchemaComplexType(xmlSchema, false); complexType.setName("Exception"); xmlSchema.getItems().add(complexType); xmlSchema.getSchemaTypes().put(elementName, complexType); typeTable.addComplexSchema(Exception.class.getName(), elementName); QName schemaTypeName = new QName(Java2WSDLConstants.URI_2001_SCHEMA_XSD, "string"); addContentToMethodSchemaType(sequence, schemaTypeName, "Message", false); complexType.setParticle(sequence); }
@Nonnull private XmlSchemaType createAny() { final XmlSchemaComplexType value = new XmlSchemaComplexType(schema, false); final XmlSchemaChoice xmlSchemaSequence = new XmlSchemaChoice(); value.setParticle(xmlSchemaSequence); final List<XmlSchemaChoiceMember> items = xmlSchemaSequence.getItems(); final XmlSchemaAny schemaAny = new XmlSchemaAny(); schemaAny.setMinOccurs(0); schemaAny.setMaxOccurs(UNBOUNDED); schemaAny.setProcessContent(XmlSchemaContentProcessing.SKIP); items.add(schemaAny); return value; } }
private XmlSchemaComplexType duplicateXmlSchemaComplexType(Scope newScope) { XmlSchemaComplexType oldSchemaType = (XmlSchemaComplexType) getSchemaType(); XmlSchemaComplexType newSchemaType = new XmlSchemaComplexType(schema, true); newSchemaType.setName(newScope.toString()); newSchemaType.setParticle(oldSchemaType.getParticle()); return newSchemaType; }
@Nonnull private XmlSchemaType createAny() { final XmlSchemaComplexType value = new XmlSchemaComplexType(schema, false); final XmlSchemaChoice xmlSchemaSequence = new XmlSchemaChoice(); value.setParticle(xmlSchemaSequence); final List<XmlSchemaChoiceMember> items = xmlSchemaSequence.getItems(); final XmlSchemaAny schemaAny = new XmlSchemaAny(); schemaAny.setMinOccurs(0); schemaAny.setMaxOccurs(UNBOUNDED); schemaAny.setProcessContent(XmlSchemaContentProcessing.SKIP); items.add(schemaAny); return value; } }
/** * Generate schema construct for given type * * @param localPartName */ private XmlSchemaComplexType createSchemaTypeForMethodPart(String localPartName) { XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace); QName elementName = new QName(this.schemaTargetNameSpace, localPartName, this.schema_namespace_prefix); XmlSchemaComplexType complexType = getComplexTypeForElement(xmlSchema, elementName); if (complexType == null) { complexType = new XmlSchemaComplexType(xmlSchema, false); XmlSchemaElement globalElement = new XmlSchemaElement(xmlSchema, false); globalElement.setSchemaType(complexType); globalElement.setName(localPartName); xmlSchema.getItems().add(globalElement); xmlSchema.getElements().put(elementName, globalElement); } typeTable.addComplexSchema(localPartName, elementName); return complexType; }
private XmlSchemaComplexType createSchemaTypeForMethodPart(String localPartName) { XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace); QName elementName = new QName(this.schemaTargetNameSpace, localPartName, this.schema_namespace_prefix); XmlSchemaComplexType complexType = getComplexTypeForElement(xmlSchema, elementName); if (complexType == null) { complexType = new XmlSchemaComplexType(xmlSchema, false); XmlSchemaElement globalElement = new XmlSchemaElement(xmlSchema, false); globalElement.setName(localPartName); boolean disallowAnonTypes = isAnonymousTypesDisallowed(); if (disallowAnonTypes) { String complexTypeName = localPartName.substring(0, 1).toUpperCase() + localPartName.substring(1); complexType.setName(complexTypeName); globalElement.setSchemaTypeName(complexType.getQName()); xmlSchema.getItems().add(complexType); xmlSchema.getSchemaTypes().put(complexType.getQName(), complexType); } else { globalElement.setSchemaType(complexType); } xmlSchema.getItems().add(globalElement); xmlSchema.getElements().put(elementName, globalElement); } typeTable.addComplexSchema(localPartName, elementName); return complexType; }
/** * Generate schema construct for given type * * @param localPartName */ private XmlSchemaComplexType createSchemaTypeForMethodPart(String localPartName) { XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace); QName elementName = new QName(this.schemaTargetNameSpace, localPartName, this.schema_namespace_prefix); XmlSchemaComplexType complexType = getComplexTypeForElement(xmlSchema, elementName); if (complexType == null) { complexType = new XmlSchemaComplexType(xmlSchema, false); XmlSchemaElement globalElement = new XmlSchemaElement(xmlSchema, false); globalElement.setSchemaType(complexType); globalElement.setName(localPartName); xmlSchema.getItems().add(globalElement); xmlSchema.getElements().put(elementName, globalElement); } typeTable.addComplexSchema(localPartName, elementName); return complexType; }
private XmlSchemaComplexType createSchemaTypeForFault(String localPartName) { XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace); QName elementName = new QName(this.schemaTargetNameSpace, localPartName, this.schema_namespace_prefix); XmlSchemaComplexType complexType = getComplexTypeForElement(xmlSchema, elementName); if (complexType == null) { complexType = new XmlSchemaComplexType(xmlSchema, false); XmlSchemaElement globalElement = new XmlSchemaElement(xmlSchema, false); globalElement.setName(localPartName); boolean disallowAnonTypes = isAnonymousTypesDisallowed(); if (disallowAnonTypes) { complexType.setName(localPartName); globalElement.setSchemaTypeName(complexType.getQName()); xmlSchema.getItems().add(complexType); xmlSchema.getSchemaTypes().put(complexType.getQName(), complexType); } else { globalElement.setSchemaType(complexType); } xmlSchema.getItems().add(globalElement); xmlSchema.getElements().put(elementName, globalElement); } return complexType; }
private XmlSchemaComplexType createSchemaTypeForFault(String localPartName) { XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace); QName elementName = new QName(this.schemaTargetNameSpace, localPartName, this.schema_namespace_prefix); XmlSchemaComplexType complexType = getComplexTypeForElement(xmlSchema, elementName); if (complexType == null) { complexType = new XmlSchemaComplexType(xmlSchema, false); XmlSchemaElement globalElement = new XmlSchemaElement(xmlSchema, false); globalElement.setName(localPartName); boolean disallowAnonTypes = isAnonymousTypesDisallowed(); if (disallowAnonTypes) { complexType.setName(localPartName); globalElement.setSchemaTypeName(complexType.getQName()); xmlSchema.getItems().add(complexType); xmlSchema.getSchemaTypes().put(complexType.getQName(), complexType); } else { globalElement.setSchemaType(complexType); } xmlSchema.getItems().add(globalElement); xmlSchema.getElements().put(elementName, globalElement); } return complexType; }
@Override public void writeSchema(XmlSchema root) { XmlSchemaComplexType complex = new XmlSchemaComplexType(root, true); complex.setName(getSchemaType().getLocalPart()); XmlSchemaSequence sequence = new XmlSchemaSequence(); complex.setParticle(sequence); AegisType kType = getKeyType(); AegisType vType = getValueType(); XmlSchemaElement element = new XmlSchemaElement(root, false); sequence.getItems().add(element); element.setName(getEntryName().getLocalPart()); element.setMinOccurs(0); element.setMaxOccurs(Long.MAX_VALUE); XmlSchemaComplexType evType = new XmlSchemaComplexType(root, false); element.setType(evType); XmlSchemaSequence evSequence = new XmlSchemaSequence(); evType.setParticle(evSequence); createElement(root, evSequence, getKeyName(), kType, false); createElement(root, evSequence, getValueName(), vType, true); }
@Override public void writeSchema(XmlSchema root) { XmlSchemaComplexType complex = new XmlSchemaComplexType(root, true); complex.setName(getSchemaType().getLocalPart()); XmlSchemaSequence sequence = new XmlSchemaSequence(); complex.setParticle(sequence); AegisType kType = getKeyType(); AegisType vType = getValueType(); XmlSchemaElement element = new XmlSchemaElement(root, false); sequence.getItems().add(element); element.setName(getEntryName().getLocalPart()); element.setMinOccurs(0); element.setMaxOccurs(Long.MAX_VALUE); XmlSchemaComplexType evType = new XmlSchemaComplexType(root, false); element.setType(evType); XmlSchemaSequence evSequence = new XmlSchemaSequence(); evType.setParticle(evSequence); createElement(root, evSequence, getKeyName(), kType, false); createElement(root, evSequence, getValueName(), vType, true); }
@Override public void writeSchema(XmlSchema root) { if (isFlat()) { return; // there is no extra level of type. } if (hasDefinedArray(root)) { return; } XmlSchemaComplexType complex = new XmlSchemaComplexType(root, true); complex.setName(getSchemaType().getLocalPart()); XmlSchemaSequence seq = new XmlSchemaSequence(); complex.setParticle(seq); AegisType componentType = getComponentType(); XmlSchemaElement element = new XmlSchemaElement(root, false); element.setName(componentType.getSchemaType().getLocalPart()); element.setSchemaTypeName(componentType.getSchemaType()); seq.getItems().add(element); if (componentType.isNillable()) { element.setNillable(true); } element.setMinOccurs(getMinOccurs()); element.setMaxOccurs(getMaxOccurs()); }
@Override public void writeSchema(XmlSchema root) { if (isFlat()) { return; // there is no extra level of type. } if (hasDefinedArray(root)) { return; } XmlSchemaComplexType complex = new XmlSchemaComplexType(root, true); complex.setName(getSchemaType().getLocalPart()); XmlSchemaSequence seq = new XmlSchemaSequence(); complex.setParticle(seq); AegisType componentType = getComponentType(); XmlSchemaElement element = new XmlSchemaElement(root, false); element.setName(componentType.getSchemaType().getLocalPart()); element.setSchemaTypeName(componentType.getSchemaType()); seq.getItems().add(element); if (componentType.isNillable()) { element.setNillable(true); } element.setMinOccurs(getMinOccurs()); element.setMaxOccurs(getMaxOccurs()); }
private XmlSchemaComplexType generateSchemaArray(Scope scopedName, Long size, XmlSchemaType type, Scope fQName) { XmlSchemaComplexType complexType = new XmlSchemaComplexType(schema, true); complexType.setName(mapper.mapToQName(scopedName)); XmlSchemaSequence sequence = new XmlSchemaSequence(); XmlSchemaElement element = new XmlSchemaElement(schema, false); element.setMinOccurs(size); element.setMaxOccurs(size); element.setName(ELEMENT_NAME); if (type != null) { element.setSchemaTypeName(type.getQName()); if (type.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) { element.setNillable(true); } } else { ArrayDeferredAction arrayAction = new ArrayDeferredAction(element); wsdlVisitor.getDeferredActions().add(fQName, arrayAction); } sequence.getItems().add(element); complexType.setParticle(sequence); return complexType; }
private XmlSchemaType generateSchemaType(XmlSchemaType stype, Scope scopedName, long bound, Scope fullyQualifiedName) { XmlSchemaComplexType ct = new XmlSchemaComplexType(schema, true); ct.setName(mapper.mapToQName(scopedName)); XmlSchemaSequence sequence = new XmlSchemaSequence(); XmlSchemaElement el = new XmlSchemaElement(schema, false); el.setName(ELEMENT_NAME); el.setMinOccurs(0); if (bound != -1) { el.setMaxOccurs(bound); } else { el.setMaxOccurs(Long.MAX_VALUE); } if (stype != null) { el.setSchemaTypeName(stype.getQName()); if (stype.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) { el.setNillable(true); } } else { SequenceDeferredAction elementAction = new SequenceDeferredAction(el); wsdlVisitor.getDeferredActions().add(fullyQualifiedName, elementAction); } sequence.getItems().add(el); ct.setParticle(sequence); return ct; }
public void visitDeclaredStruct(AST identifierNode) { Scope structScope = new Scope(getScope(), identifierNode); // xmlschema:struct XmlSchemaComplexType complexType = new XmlSchemaComplexType(schema, true); complexType.setName(mapper.mapToQName(structScope)); XmlSchemaSequence sequence = new XmlSchemaSequence(); complexType.setParticle(sequence); // corba:struct Struct struct = new Struct(); struct.setQName(new QName(typeMap.getTargetNamespace(), structScope.toString())); struct.setType(complexType.getQName()); struct.setRepositoryID(structScope.toIDLRepositoryID()); boolean recursiveAdd = addRecursiveScopedName(identifierNode); // struct members visitStructMembers(identifierNode, struct, sequence, structScope); if (recursiveAdd) { removeRecursiveScopedName(identifierNode); } // add corbaType typeMap.getStructOrExceptionOrUnion().add(struct); // REVISIT: are there assignment needed? setSchemaType(complexType); setCorbaType(struct); // Need to check if the struct was forward declared processForwardStructActions(structScope); // Once we've finished declaring the struct, we should make sure it has been removed from // the list of scopedNames so that we inidicate that is no longer simply forward declared. scopedNames.remove(structScope); }