in axis-codegen/src/main/java/org/apache/axis/wsdl/toJava/JavaBeanWriter.java [682:828]
protected void writeFullConstructor() {
if (type.isSimpleType()) {
return;
}
// The constructor needs to consider all extended types
Vector extendList = new Vector();
extendList.add(type);
TypeEntry parent = extendType;
while (parent != null) {
if (parent.isSimpleType())
return;
extendList.add(parent);
parent =
SchemaUtils.getComplexElementExtensionBase(parent.getNode(),
emitter.getSymbolTable());
}
// Now generate a list of names and types starting with
// the oldest parent. (Attrs are considered before elements).
Vector paramTypes = new Vector();
Vector paramNames = new Vector();
boolean gotAny = false;
for (int i = extendList.size() - 1; i >= 0; i--) {
TypeEntry te = (TypeEntry) extendList.elementAt(i);
// The names of the inherited parms are mangled
// in case they interfere with local parms.
String mangle = "";
if (i > 0) {
mangle = "_"
+ JavaUtils.xmlNameToJava(te.getQName().getLocalPart())
+ "_";
}
// Process the attributes
Vector attributes = te.getContainedAttributes();
if (attributes != null) {
for (int j = 0; j < attributes.size(); j += 1) {
ContainedAttribute attr = (ContainedAttribute) attributes.get(j);
String name = getAttributeName(attr);
String typeName = attr.getType().getName();
// TODO - What about MinOccurs and Nillable?
// Do they make sense here?
if (attr.getOptional()) {
typeName = Utils.getWrapperType(typeName);
}
paramTypes.add(typeName);
paramNames.add(JavaUtils.getUniqueValue(
helper.reservedPropNames, name));
}
}
// Process the elements
Vector elements = te.getContainedElements();
if (elements != null) {
for (int j = 0; j < elements.size(); j++) {
ElementDecl elem = (ElementDecl) elements.get(j);
if (elem.getAnyElement()) {
if (!gotAny) {
gotAny = true;
paramTypes.add("org.apache.axis.message.MessageElement []");
paramNames.add(Constants.ANYCONTENT);
}
} else {
paramTypes.add(processTypeName(elem,elem.getType().getName()));
String name = elem.getName() == null ? ("param" + i) : elem.getName();
paramNames.add(JavaUtils.getUniqueValue(
helper.reservedPropNames, name));
}
}
}
}
if (isMixed && !isAny && !parentIsAny && !parentIsMixed) {
paramTypes.add("org.apache.axis.message.MessageElement []");
paramNames.add(Constants.ANYCONTENT);
}
// Set the index where the local params start
int localParams = paramTypes.size() - names.size() / 2;
// Now write the constructor signature
if (paramTypes.size() > 0 && paramTypes.size() < 255) {
// Prevent name clash between local parameters and the
// parameters for the super class
if(localParams > 0) {
for (int j = 0; j < localParams; j++) {
String name = (String) paramNames.elementAt(j);
if(paramNames.indexOf(name, localParams)!=-1){
paramNames.set(j, "_" + name);
}
}
}
pw.println(" public " + className + "(");
for (int i = 0; i < paramTypes.size(); i++) {
pw.print(" " + paramTypes.elementAt(i) + " "
+ paramNames.elementAt(i));
if ((i + 1) < paramTypes.size()) {
pw.println(",");
} else {
pw.println(") {");
}
}
// Call the extended constructor to set inherited fields
if ((extendType != null) && (localParams > 0)) {
pw.println(" super(");
for (int j = 0; j < localParams; j++) {
pw.print(" " + paramNames.elementAt(j));
if ((j + 1) < localParams) {
pw.println(",");
} else {
pw.println(");");
}
}
}
// Set local fields directly
for (int j = localParams; j < paramNames.size(); j++) {
pw.println(" this." + paramNames.elementAt(j) + " = "
+ paramNames.elementAt(j) + ";");
}
pw.println(" }");
pw.println();
}
}