Search in sources :

Example 1 with AttributeInfo

use of org.apache.cxf.javascript.AttributeInfo in project cxf by apache.

the class SchemaJavascriptBuilder method complexTypeConstructorAndAccessors.

// In general, I (bimargulies) hate fields that are temporary communications
// between members of a class. However, given the style restrictions on the
// number
// of parameters, it's the least of the evils.
public void complexTypeConstructorAndAccessors(QName name, XmlSchemaComplexType type) {
    accessors = new StringBuilder();
    utils = new JavascriptUtils(code);
    List<XmlSchemaObject> items = JavascriptUtils.getContentElements(type, xmlSchemaCollection);
    List<XmlSchemaAnnotated> attrs = XmlSchemaUtils.getContentAttributes(type, xmlSchemaCollection);
    final String elementPrefix = "this._";
    String typeObjectName = nameManager.getJavascriptName(name);
    code.append("//\n");
    code.append("// Constructor for XML Schema item " + name.toString() + "\n");
    code.append("//\n");
    code.append("function " + typeObjectName + " () {\n");
    // to assist in debugging we put a type property into every object.
    utils.appendLine("this.typeMarker = '" + typeObjectName + "';");
    for (XmlSchemaObject thing : items) {
        ParticleInfo itemInfo = ParticleInfo.forLocalItem(thing, xmlSchema, xmlSchemaCollection, prefixAccumulator, type.getQName());
        constructItem(type, elementPrefix, typeObjectName, itemInfo);
    }
    for (XmlSchemaAnnotated thing : attrs) {
        AttributeInfo itemInfo = AttributeInfo.forLocalItem(thing, xmlSchema, xmlSchemaCollection, prefixAccumulator, type.getQName());
        constructOneItem(type, elementPrefix, typeObjectName, itemInfo);
    }
    code.append("}\n\n");
    code.append(accessors.toString());
}
Also used : AttributeInfo(org.apache.cxf.javascript.AttributeInfo) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) JavascriptUtils(org.apache.cxf.javascript.JavascriptUtils) ParticleInfo(org.apache.cxf.javascript.ParticleInfo) XmlSchemaAnnotated(org.apache.ws.commons.schema.XmlSchemaAnnotated)

Aggregations

AttributeInfo (org.apache.cxf.javascript.AttributeInfo)1 JavascriptUtils (org.apache.cxf.javascript.JavascriptUtils)1 ParticleInfo (org.apache.cxf.javascript.ParticleInfo)1 XmlSchemaAnnotated (org.apache.ws.commons.schema.XmlSchemaAnnotated)1 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)1