You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by pr...@apache.org on 2005/06/14 16:45:00 UTC
cvs commit: ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp BeanParamWriter.java ParmHeaderFileWriter.java
prestonf 2005/06/14 07:45:00
Modified: c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp
BeanParamWriter.java ParmHeaderFileWriter.java
Log:
This cures AXISCPP-693 for RPC.
Revision Changes Path
1.45 +673 -859 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java
Index: BeanParamWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- BeanParamWriter.java 3 Jun 2005 08:55:39 -0000 1.44
+++ BeanParamWriter.java 14 Jun 2005 14:45:00 -0000 1.45
@@ -1,6 +1,6 @@
/*
* Copyright 2003-2004 The Apache Software Foundation.
-// (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved
+ // (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,922 +28,736 @@
import org.apache.axis.wsdl.wsdl2ws.CUtils;
import org.apache.axis.wsdl.wsdl2ws.WrapperFault;
+import org.apache.axis.wsdl.wsdl2ws.info.ElementInfo;
import org.apache.axis.wsdl.wsdl2ws.info.Type;
import org.apache.axis.wsdl.wsdl2ws.info.WebServiceContext;
/**
* Genarate a webservice for the complex types likes structs.
+ *
* @author hemapani
*/
-public class BeanParamWriter extends ParamCPPFileWriter
-{
- public BeanParamWriter(WebServiceContext wscontext, Type type)
- throws WrapperFault
- {
- super(wscontext, type);
- }
-
- /* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.ParamCPPFileWriter#writeGlobalCodes()
- */
- protected void writeGlobalCodes() throws WrapperFault
- {
- try
- {
- HashSet typeSet = new HashSet();
- String typeName;
- for (int i = 0; i < attribs.length; i++)
- {
- if (!attribs[i].isSimpleType())
- {
- typeSet.add(attribs[i].getTypeName());
- }
- }
- Iterator itr = typeSet.iterator();
- while (itr.hasNext())
- {
- typeName = itr.next().toString();
- if (!typeName.equals(type.getName().getLocalPart()))
- {
- writer.write(
- "extern int Axis_DeSerialize_"
- + typeName
- + "("
- + typeName
- + "* param, IWrapperSoapDeSerializer* pDZ);\n");
- writer.write(
- "extern void* Axis_Create_"
- + typeName
- + "("
- + typeName
- + "* pObj, bool bArray = false, int nSize=0);\n");
- writer.write(
- "extern void Axis_Delete_"
- + typeName
- + "("
- + typeName
- + "* param, bool bArray = false, int nSize=0);\n");
- writer.write(
- "extern int Axis_Serialize_"
- + typeName
- + "("
- + typeName
- + "* param, IWrapperSoapSerializer* pSZ, bool bArray = false);\n");
- writer.write(
- "extern int Axis_GetSize_" + typeName + "();\n\n");
- }
- else
- {
- writer.write(
- "int Axis_DeSerialize_"
- + typeName
- + "("
- + typeName
- + "* param, IWrapperSoapDeSerializer* pDZ);\n");
- writer.write(
- "void* Axis_Create_"
- + typeName
- + "("
- + typeName
- + "* pObj, bool bArray, int nSize);\n");
- writer.write(
- "void Axis_Delete_"
- + typeName
- + "("
- + typeName
- + "* param, bool bArray, int nSize);\n");
- writer.write(
- "int Axis_Serialize_"
- + typeName
- + "("
- + typeName
- + "* param, IWrapperSoapSerializer* pSZ, bool bArray);\n");
- writer.write("int Axis_GetSize_" + typeName + "();\n\n");
- }
- }
-
- writeGetSetMethods();
- writeSerializeGlobalMethod();
- writeDeSerializeGlobalMethod();
- writeCreateGlobalMethod();
- writeDeleteGlobalMethod();
- writeGetSizeGlobalMethod();
- }
- catch (IOException e)
- {
- throw new WrapperFault(e);
- }
- }
-
- /**
- * Dushshantha:
- * following method writes getters and setters for the attributes
+public class BeanParamWriter extends ParamCPPFileWriter {
+ public BeanParamWriter(WebServiceContext wscontext, Type type)
+ throws WrapperFault {
+ super(wscontext, type);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.axis.wsdl.wsdl2ws.cpp.ParamCPPFileWriter#writeGlobalCodes()
+ */
+ protected void writeGlobalCodes() throws WrapperFault {
+ try {
+ HashSet typeSet = new HashSet();
+ String typeName;
+ for (int i = 0; i < attribs.length; i++) {
+ if (!attribs[i].isSimpleType()) {
+ typeSet.add(attribs[i].getTypeName());
+ }
+ }
+ Iterator itr = typeSet.iterator();
+ while (itr.hasNext()) {
+ /*
+ * Needed for self referenced array. <xsd:complexType
+ * name="Type1"> <xsd:sequence> <xsd:element name="followings"
+ * maxOccurs="unbounded" minOccurs="0" type="tns:Type1" />
+ * <xsd:element name="kind" type="xsd:string" /> <xsd:element
+ * name="index" type="xsd:int" /> </xsd:sequence> <xsd:attribute
+ * name="att_kind" type="tns:Kind" /> </xsd:complexType>
+ */
+ typeName = itr.next().toString();
+ if (!typeName.equals(type.getName().getLocalPart())) {
+ writer.write("extern int Axis_DeSerialize_" + typeName
+ + "(" + typeName
+ + "* param, IWrapperSoapDeSerializer* pDZ);\n");
+ writer.write("extern void* Axis_Create_" + typeName + "("
+ + typeName
+ + "* pObj, bool bArray = false, int nSize=0);\n");
+ writer.write("extern void Axis_Delete_" + typeName + "("
+ + typeName
+ + "* param, bool bArray = false, int nSize=0);\n");
+ writer
+ .write("extern int Axis_Serialize_"
+ + typeName
+ + "("
+ + typeName
+ + "* param, IWrapperSoapSerializer* pSZ, bool bArray = false);\n");
+ writer.write("extern int Axis_GetSize_" + typeName
+ + "();\n\n");
+ } else {
+ writer.write("int Axis_DeSerialize_" + typeName + "("
+ + typeName
+ + "* param, IWrapperSoapDeSerializer* pDZ);\n");
+ writer.write("void* Axis_Create_" + typeName + "("
+ + typeName + "* pObj, bool bArray, int nSize);\n");
+ writer.write("void Axis_Delete_" + typeName + "("
+ + typeName + "* param, bool bArray, int nSize);\n");
+ writer
+ .write("int Axis_Serialize_"
+ + typeName
+ + "("
+ + typeName
+ + "* param, IWrapperSoapSerializer* pSZ, bool bArray);\n");
+ writer.write("int Axis_GetSize_" + typeName + "();\n\n");
+ }
+ }
+
+ writeGetSetMethods();
+ writeSerializeGlobalMethod();
+ writeDeSerializeGlobalMethod();
+ writeCreateGlobalMethod();
+ writeDeleteGlobalMethod();
+ writeGetSizeGlobalMethod();
+ } catch (IOException e) {
+ throw new WrapperFault(e);
+ }
+ }
+
+ /**
+ * Dushshantha: following method writes getters and setters for the
+ * attributes
*/
-
- private void writeGetSetMethods() throws WrapperFault{
+
+ private void writeGetSetMethods() throws WrapperFault {
/**
- * Dushshantha:
- * writing getter
+ * Dushshantha: writing getter
*/
-
- if (type.isArray())
- {
- return;
- }
- try
- {
- for (int i = 0; i < attribs.length; i++){
-
- /**
- * Dushshantha:
- * Write getter
- */
-
- writer.write(
- "\n"
- + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i])
- + " "
+
+ if (type.isArray()) {
+ return;
+ }
+ try {
+ for (int i = 0; i < attribs.length; i++) {
+ // FJP Nillable vv
+ if (isElementNillable(i)) {
+ String parameterName = attribs[i]
+ .getParamNameWithoutSymbols();
+ String properParamName = getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]);
+
+ writer.write("\n" + properParamName + " * " + classname
+ + "::get" + parameterName + "()\n{\n");
+
+ writer.write("\t" + "return " + parameterName + " ; \n}\n");
+
+ writer.write("\n" + "void " + classname + "::set"
+ + parameterName + "(" + properParamName
+ + " * pInValue)\n{\n");
+
+ writer.write("\t" + parameterName + " = pInValue ; \n");
+
+ if (attribs[i].getChoiceElement()) {
+ for (int j = 0; j < attribs.length; j++) {
+ if ((attribs[j].getChoiceElement()) && (j != i)) {
+ writer.write("\t"
+ + attribs[j]
+ .getParamNameWithoutSymbols()
+ + " = NULL ; \n");
+ }
+ }
+ }
+
+ writer.write("}\n");
+ } else {
+ // FJP Nillable ^^
+ /**
+ * Dushshantha: Write getter
+ */
+
+ writer
+ .write("\n"
+ + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i])
+ + " " + classname + "::get"
+ + attribs[i].getParamNameWithoutSymbols()
+ + "()\n{\n");
+
+ writer.write("\t" + "return "
+ + attribs[i].getParamNameWithoutSymbols()
+ + " ; \n}\n");
+
+ /**
+ * Dushshantha: Write setter
+ */
+
+ writer
+ .write("\n"
+ + "void "
+ + classname
+ + "::set"
+ + attribs[i].getParamNameWithoutSymbols()
+ + "("
+ + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i])
+ + " InValue)\n{\n");
+
+ writer.write("\t" + attribs[i].getParamNameWithoutSymbols()
+ + " = InValue ; \n");
+
+ if (attribs[i].getChoiceElement()) {
+ for (int j = 0; j < attribs.length; j++) {
+ if ((attribs[j].getChoiceElement()) && (j != i)) {
+ writer.write("\t"
+ + attribs[j]
+ .getParamNameWithoutSymbols()
+ + " = NULL ; \n");
+ }
+ }
+ }
+
+ writer.write("}\n");
+ }
+ }
+ } catch (IOException e) {
+ throw new WrapperFault(e);
+ }
+
+ }
+
+ private void writeGetSizeGlobalMethod() throws IOException {
+ writer.write("/*\n");
+ writer.write(" * This static method gives the size of " + classname
+ + " type of object\n");
+ writer.write(" */\n");
+ writer.write("int Axis_GetSize_" + classname
+ + "()\n{\n\treturn sizeof(" + classname + ");\n}\n");
+ }
+
+ private void writeSerializeGlobalMethod() throws IOException, WrapperFault {
+ writer.write("/*\n");
+ writer.write(" * This static method serialize a " + classname
+ + " type of object\n");
+ writer.write(" */\n");
+ writer
+ .write("int Axis_Serialize_"
+ + classname
+ + "("
+ classname
- + "::get"
- + attribs[i].getParamNameWithoutSymbols()
- + "()\n{\n");
-
- writer.write(
- "\t"
- + "return "
- + attribs[i].getParamNameWithoutSymbols()
- + " ; \n}\n");
-
-
- /**
- * Dushshantha:
- * Write setter
- */
-
- writer.write(
- "\n"
- + "void "
- + classname
- + "::set"
- + attribs[i].getParamNameWithoutSymbols()
- + "("
- + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i])
- + " InValue)\n{\n");
-
- writer.write(
- "\t"
- + attribs[i].getParamNameWithoutSymbols()
- + " = InValue ; \n");
-
- if (attribs[i].getChoiceElement()){
- for (int j = 0; j < attribs.length; j++){
- if ((attribs[j].getChoiceElement())&& (j!=i))
- writer.write(
- "\t"
- + attribs[j].getParamNameWithoutSymbols()
- + " = NULL ; \n");
- }
- }
-
- writer.write("}\n");
-
- }
- }
- catch (IOException e)
- {
- throw new WrapperFault(e);
- }
-
- }
-
-
- private void writeGetSizeGlobalMethod() throws IOException
- {
- writer.write("/*\n");
- writer.write(
- " * This static method gives the size of "
- + classname
- + " type of object\n");
- writer.write(" */\n");
- writer.write(
- "int Axis_GetSize_"
- + classname
- + "()\n{\n\treturn sizeof("
- + classname
- + ");\n}\n");
- }
-
- private void writeSerializeGlobalMethod() throws IOException, WrapperFault
- {
- writer.write("/*\n");
- writer.write(
- " * This static method serialize a "
- + classname
- + " type of object\n");
- writer.write(" */\n");
- writer.write(
- "int Axis_Serialize_"
- + classname
- + "("
- + classname
- + "* param, IWrapperSoapSerializer* pSZ, bool bArray = false)\n{\n");
- if (attribs.length == 0)
- {
- System.out.println(
- "Possible error in class "
- + classname
- + ": class with no attributes....................");
- writer.write("\t}\n\n");
- return;
- }
- writer.write("\tif (bArray)\n");
- writer.write("\t{\n");
- writer.write(
- "\t\tpSZ->serialize(\"<\", Axis_TypeName_"
- + classname
- + ", \">\", NULL);\n");
- writer.write("\t}\n");
- writer.write("\telse\n");
- writer.write("\t{\n");
- writer.write("\t\tbool blnIsNewPrefix = false;\n");
- writer.write("\t\tconst AxisChar* sPrefix = pSZ->getNamespacePrefix(Axis_URI_"
- + classname
- + ", blnIsNewPrefix);\n");
- writer.write("\t\tif (!blnIsNewPrefix)\n");
- writer.write("\t\t{\n");
- writer.write(
- "\t\t\tpSZ->serialize(\"<\", Axis_TypeName_"
- + classname
- + ", \" xsi:type=\\\"\", sPrefix, \":\",\n");
- writer.write(
- "\t\t\t\tAxis_TypeName_"
- + classname
- + ", \"\\\">\", NULL);\n");
- writer.write("\t\t}\n");
- writer.write("\t\telse\n");
- writer.write("\t\t{\n");
- writer.write(
- "\t\t\tpSZ->serialize(\"<\", Axis_TypeName_"
- + classname
- + ", \" xsi:type=\\\"\", sPrefix, \":\",\n");
- writer.write(
- "\t\t\t\tAxis_TypeName_"
- + classname
- + ", \"\\\" xmlns:\", sPrefix, \"=\\\"\",\n");
- writer.write("\t\t\t\tAxis_URI_" + classname + ", \"\\\">\", NULL);\n");
- writer.write("\t\t}\n");
- writer.write("\t}\n\n");
-
- String arrayType;
- boolean firstIfWritten=false;
- for (int i = 0; i < attribs.length; i++)
- {
-
+ + "* param, IWrapperSoapSerializer* pSZ, bool bArray = false)\n{\n");
+
+ if (attribs.length == 0) {
+ System.out.println("Possible error in class " + classname
+ + ": class with no attributes....................");
+ writer.write("\t}\n\n");
+ return;
+ }
+ writer.write("\tif (bArray)\n");
+ writer.write("\t{\n");
+ writer.write("\t\tpSZ->serialize(\"<\", Axis_TypeName_" + classname
+ + ", \">\", NULL);\n");
+ writer.write("\t}\n");
+ writer.write("\telse\n");
+ writer.write("\t{\n");
+ writer.write("\t\tbool blnIsNewPrefix = false;\n");
+ writer
+ .write("\t\tconst AxisChar* sPrefix = pSZ->getNamespacePrefix(Axis_URI_"
+ + classname + ", blnIsNewPrefix);\n");
+ writer.write("\t\tif (!blnIsNewPrefix)\n");
+ writer.write("\t\t{\n");
+ writer.write("\t\t\tpSZ->serialize(\"<\", Axis_TypeName_" + classname
+ + ", \" xsi:type=\\\"\", sPrefix, \":\",\n");
+ writer.write("\t\t\t\tAxis_TypeName_" + classname
+ + ", \"\\\">\", NULL);\n");
+ writer.write("\t\t}\n");
+ writer.write("\t\telse\n");
+ writer.write("\t\t{\n");
+ writer.write("\t\t\tpSZ->serialize(\"<\", Axis_TypeName_" + classname
+ + ", \" xsi:type=\\\"\", sPrefix, \":\",\n");
+ writer.write("\t\t\t\tAxis_TypeName_" + classname
+ + ", \"\\\" xmlns:\", sPrefix, \"=\\\"\",\n");
+ writer.write("\t\t\t\tAxis_URI_" + classname + ", \"\\\">\", NULL);\n");
+ writer.write("\t\t}\n");
+ writer.write("\t}\n\n");
+
+ String arrayType;
+ boolean firstIfWritten = false;
+ for (int i = 0; i < attribs.length; i++) {
+
//Dushshantha:
- //if the attribute is a choice
+ //if the attribute is a choice
//following should do
-
- if(attribs[i].getChoiceElement())
- {
- if(!firstIfWritten)
- {
+
+ if (attribs[i].getChoiceElement()) {
+ if (!firstIfWritten) {
writer.write("\tif");
- firstIfWritten=true;
- }
- else
- {
+ firstIfWritten = true;
+ } else {
writer.write("\telse if");
}
- writer.write("(param->" + attribs[i].getParamNameAsMember()+ ")\n\t{\n\t");
+ writer.write("(param->" + attribs[i].getParamNameAsMember()
+ + ")\n\t{\n\t");
}
//..............................................................................
-
+
//Chinthana:
//if the attribute is a 'all' following should do
-
- if(attribs[i].getAllElement())
- {
- if(attribs[i].getMinOccurs() == 0)
- {
- writer.write("\tif(param->" + attribs[i].getParamNameAsMember()+ ")\n\t{\n\t");
+
+ if (attribs[i].getAllElement()) {
+ if (attribs[i].getMinOccurs() == 0) {
+ writer.write("\tif(param->"
+ + attribs[i].getParamNameAsMember() + ")\n\t{\n\t");
}
}
//17/05/2005........................................................................
- if (attribs[i].isAnyType())
- {
- writer.write("\tpSZ->serializeAnyObject(param->any);\n");
- }
- else
- if (attribs[i].isArray())
- {
- //if Array
- if (attribs[i].isSimpleType())
- {
- writer.write(
- "\tpSZ->serializeBasicArray((Axis_Array*)(¶m->"
- + attribs[i].getParamNameAsMember()
- + "),"
- + CUtils.getXSDTypeForBasicType(
- attribs[i].getTypeName())
- + ", \""
- + attribs[i].getParamName()
- + "\");\n");
- }
- else
- {
- String elm = attribs[i].getParamName();
- if (attribs[i].isReference())
- {
- elm = attribs[i].getTypeName();
- }
- arrayType = attribs[i].getTypeName();
- writer.write(
- "\tpSZ->serializeCmplxArray((Axis_Array*)(¶m->"
- + attribs[i].getParamNameAsMember()
- + "),\n");
- writer.write(
- "\t\t(void*) Axis_Serialize_"
- + arrayType
- + ", (void*) Axis_Delete_"
- + arrayType
- + ", (void*) Axis_GetSize_"
- + arrayType
- + ",\n");
- writer.write(
- "\t\t\""
- + elm
- + "\", Axis_URI_"
- + arrayType
- + ");\n");
- }
- }
- else
- if (attribs[i].isSimpleType())
- {
- if (attribs[i].isAttribute())
- {
- if (attribs[i].isOptional())
- {
- writer.write(
- "\tif (0 != param->"
- + attribs[i].getParamNameAsMember()
- + ")\n");
- if (CUtils.isPointerType(attribs[i].getTypeName()))
- {
- writer.write(
- "\t\tpSZ->serializeAsAttribute(\""
- + attribs[i].getParamName()
- + "\", 0, (void*)(param->"
- + attribs[i].getParamNameAsMember()
- + "), "
- + CUtils.getXSDTypeForBasicType(
- attribs[i].getTypeName())
- + ");\n");
- }
- else
- {
- writer.write(
- "\t\tpSZ->serializeAsAttribute(\""
- + attribs[i].getParamName()
- + "\", 0, (void*)&(param->"
- + attribs[i].getParamNameAsMember()
- + "), "
- + CUtils.getXSDTypeForBasicType(
- attribs[i].getTypeName())
- + ");\n");
- }
- }
- else
- {
- writer.write(
- "\tpSZ->serializeAsAttribute(\""
- + attribs[i].getParamName()
- + "\", 0, (void*)&(param->"
- + attribs[i].getParamNameAsMember()
- + "), "
- + CUtils.getXSDTypeForBasicType(
- attribs[i].getTypeName())
- + ");\n");
- }
- }
- else
- {
- if (CUtils.isPointerType(attribs[i].getTypeName()))
- {
- writer.write(
- "\tpSZ->serializeAsElement(\""
- + attribs[i].getParamName()
- + "\", (void*)(param->"
- + attribs[i].getParamNameAsMember()
- + "), "
- + CUtils.getXSDTypeForBasicType(
- attribs[i].getTypeName())
- + ");\n");
- }
- else
- {
- /**
- * Dushshantha:
- * if the element is a choice element,
- * it should be treated as a pointer
- */
- if (attribs[i].getChoiceElement() || attribs[i].getAllElement())
- writer.write(
- "\tpSZ->serializeAsElement(\""
- + attribs[i].getParamName()
- + "\", (void*)(param->"
- + attribs[i].getParamNameAsMember()
- + "), "
- + CUtils.getXSDTypeForBasicType(
- attribs[i].getTypeName())
- + ");\n");
- else
- writer.write(
- "\tpSZ->serializeAsElement(\""
- + attribs[i].getParamName()
- + "\", (void*)&(param->"
- + attribs[i].getParamNameAsMember()
- + "), "
- + CUtils.getXSDTypeForBasicType(
- attribs[i].getTypeName())
- + ");\n");
- }
- }
- }
- else
- {
- //if complex type
- writer.write(
- "\tAxis_Serialize_"
- + attribs[i].getTypeName()
- + "(param->"
- + attribs[i].getParamNameAsMember()
- + ", pSZ);\n");
- }
+ if (attribs[i].isAnyType()) {
+ writer.write("\tpSZ->serializeAnyObject(param->any);\n");
+ } else if (attribs[i].isArray()) {
+ //if Array
+ if (attribs[i].isSimpleType()) {
+ writer
+ .write("\tpSZ->serializeBasicArray((Axis_Array*)(¶m->"
+ + attribs[i].getParamNameAsMember()
+ + "),"
+ + CUtils.getXSDTypeForBasicType(attribs[i]
+ .getTypeName())
+ + ", \""
+ + attribs[i].getParamName() + "\");\n");
+ } else {
+ String elm = attribs[i].getParamName();
+ if (attribs[i].isReference()) {
+ elm = attribs[i].getTypeName();
+ }
+ arrayType = attribs[i].getTypeName();
+ writer
+ .write("\tpSZ->serializeCmplxArray((Axis_Array*)(¶m->"
+ + attribs[i].getParamNameAsMember()
+ + "),\n");
+ writer.write("\t\t(void*) Axis_Serialize_" + arrayType
+ + ", (void*) Axis_Delete_" + arrayType
+ + ", (void*) Axis_GetSize_" + arrayType + ",\n");
+ writer.write("\t\t\"" + elm + "\", Axis_URI_" + arrayType
+ + ");\n");
+ }
+ } else if (attribs[i].isSimpleType()) {
+ if (attribs[i].isAttribute()) {
+ if (attribs[i].isOptional()) {
+ writer.write("\tif (0 != param->"
+ + attribs[i].getParamNameAsMember() + ")\n");
+ if (attribs[i].getTypeName().equals("xsd__string")
+ || attribs[i].getTypeName().equals(
+ "xsd__anyURI")
+ || attribs[i].getTypeName()
+ .equals("xsd__QName")
+ || attribs[i].getTypeName().equals(
+ "xsd__notation")) {
+ writer.write("\t\tpSZ->serializeAsAttribute(\""
+ + attribs[i].getParamName()
+ + "\", 0, (void*)(param->"
+ + attribs[i].getParamNameAsMember()
+ + "), "
+ + CUtils.getXSDTypeForBasicType(attribs[i]
+ .getTypeName()) + ");\n");
+ } else {
+ writer.write("\t\tpSZ->serializeAsAttribute(\""
+ + attribs[i].getParamName()
+ + "\", 0, (void*)&(param->"
+ + attribs[i].getParamNameAsMember()
+ + "), "
+ + CUtils.getXSDTypeForBasicType(attribs[i]
+ .getTypeName()) + ");\n");
+ }
+ } else {
+ writer.write("\tpSZ->serializeAsAttribute(\""
+ + attribs[i].getParamName()
+ + "\", 0, (void*)&(param->"
+ + attribs[i].getParamNameAsMember()
+ + "), "
+ + CUtils.getXSDTypeForBasicType(attribs[i]
+ .getTypeName()) + ");\n");
+ }
+ } else {
+ if (attribs[i].getTypeName().equals("xsd__string")
+ || attribs[i].getTypeName().equals("xsd__anyURI")
+ || attribs[i].getTypeName().equals("xsd__QName")
+ || attribs[i].getTypeName().equals("xsd__notation")
+ || isElementNillable(i)) {
+ writer.write("\tpSZ->serializeAsElement(\""
+ + attribs[i].getParamName()
+ + "\", (void*)(param->"
+ + attribs[i].getParamNameAsMember()
+ + "), "
+ + CUtils.getXSDTypeForBasicType(attribs[i]
+ .getTypeName()) + ");\n");
+ } else {
+ /**
+ * Dushshantha: if the element is a choice element, it
+ * should be treated as a pointer
+ */
+ if (attribs[i].getChoiceElement()
+ || attribs[i].getAllElement())
+ writer.write("\tpSZ->serializeAsElement(\""
+ + attribs[i].getParamName()
+ + "\", (void*)(param->"
+ + attribs[i].getParamNameAsMember()
+ + "), "
+ + CUtils.getXSDTypeForBasicType(attribs[i]
+ .getTypeName()) + ");\n");
+ else
+ writer.write("\tpSZ->serializeAsElement(\""
+ + attribs[i].getParamName()
+ + "\", (void*)&(param->"
+ + attribs[i].getParamNameAsMember()
+ + "), "
+ + CUtils.getXSDTypeForBasicType(attribs[i]
+ .getTypeName()) + ");\n");
+ }
+ }
+ } else {
+ //if complex type
+ writer.write("\tAxis_Serialize_" + attribs[i].getTypeName()
+ + "(param->" + attribs[i].getParamNameAsMember()
+ + ", pSZ);\n");
+ }
//Dushshantha:
//end if choice element
-
- if(attribs[i].getChoiceElement())
+
+ if (attribs[i].getChoiceElement())
writer.write("\t}\n");
-
- //Chinthana: end if
- if(attribs[i].getAllElement())
- {
- if(attribs[i].getMinOccurs() == 0)
+
+ //Chinthana: end if
+ if (attribs[i].getAllElement()) {
+ if (attribs[i].getMinOccurs() == 0)
writer.write("\t}\n");
}
//17/05/2005.........................................
-
}
- writer.write(
- "\n\tpSZ->serialize(\"</\", Axis_TypeName_"
- + classname
- + ", \">\", NULL);\n");
- writer.write("\treturn AXIS_SUCCESS;\n");
- writer.write("}\n\n");
-
- }
- private void writeDeSerializeGlobalMethod()
- throws IOException, WrapperFault
- {
-
-
- writer.write("/*\n");
- writer.write(
- " * This static method deserialize a "
- + classname
- + " type of object\n");
- writer.write(" */\n");
- writer.write(
- "int Axis_DeSerialize_"
- + classname
- + "("
- + classname
- + "* param, IWrapperSoapDeSerializer* pIWSDZ)\n{\n");
-
-
-
- if (attribs.length == 0)
- {
- System.out.println(
- "Possible error in class "
- + classname
- + ": class with no attributes....................");
- writer.write("\t}\n\n");
- return;
- }
- String arrayType = null;
-
- /**
- *to handle simple type arrays
- */
-
- for(int i = 0; i< attribs.length;i++)
- {
-
- if(attribs[i].isArray())
- {
- writer.write("\tAxis_Array array;\n\n");
- break;
- }
- }
-
+ writer.write("\n\tpSZ->serialize(\"</\", Axis_TypeName_" + classname
+ + ", \">\", NULL);\n");
+ writer.write("\treturn AXIS_SUCCESS;\n");
+ writer.write("}\n\n");
+
+ }
+
+ private void writeDeSerializeGlobalMethod() throws IOException,
+ WrapperFault {
+
+ writer.write("/*\n");
+ writer.write(" * This static method deserialize a " + classname
+ + " type of object\n");
+ writer.write(" */\n");
+ writer.write("int Axis_DeSerialize_" + classname + "(" + classname
+ + "* param, IWrapperSoapDeSerializer* pIWSDZ)\n{\n");
+
+ if (attribs.length == 0) {
+ System.out.println("Possible error in class " + classname
+ + ": class with no attributes....................");
+ writer.write("\t}\n\n");
+ return;
+ }
+ String arrayType = null;
+
//Dushshantha:
- //peekCalled boolean variable checks whether the Line
- //const char* choiceName=pIWSDZ->peekNextElementName(); has been wriiten in the generated cade.
+ //peekCalled boolean variable checks whether the Line
+ //const char* choiceName=pIWSDZ->peekNextElementName(); has been
+ // wriiten in the generated cade.
boolean peekCalled = false;
- boolean firstIfWritten = false;
- boolean foundAll = false;
+ boolean firstIfWritten = false;
+ boolean foundAll = false;
- for (int i = 0; i < attribs.length; i++)
- {
- //Dushshantha:
- //if the attribute is a choice
- //following should do :-)
-
- if(attribs[i].getChoiceElement())
- {
- if(!peekCalled)
- {
- writer.write("\tconst char* choiceName=pIWSDZ->peekNextElementName();\n");
- peekCalled=true;
+ for (int i = 0; i < attribs.length; i++) {
+ //Dushshantha:
+ //if the attribute is a choice
+ //following should do :-)
+
+ if (attribs[i].getChoiceElement()) {
+ if (!peekCalled) {
+ writer
+ .write("\tconst char* choiceName=pIWSDZ->peekNextElementName();\n");
+ peekCalled = true;
}
- if(!firstIfWritten)
- {
+ if (!firstIfWritten) {
writer.write("\tif");
- firstIfWritten=true;
- }
- else
- {
+ firstIfWritten = true;
+ } else {
writer.write("\telse if");
}
-
- writer.write("(strcmp(choiceName,\"" + attribs[i].getParamNameAsMember()+ "\")==0)\n\t{\n\t");
-
- }
- //.............................................
-
+
+ writer.write("(strcmp(choiceName,\""
+ + attribs[i].getParamNameAsMember()
+ + "\")==0)\n\t{\n\t");
+
+ }
+ //.............................................
+
//Chinthana:
- //if the attribute is a 'all' construct we have to check Min occures
- if(attribs[i].getAllElement())
- {
- if(attribs[i].getMinOccurs() == 0)
- {
- if(!foundAll)
- {
- writer.write("\tconst char* allName = NULL;\n");
- writer.write("\tbool peekCalled = false;\n");
- foundAll = true;
+ //if the attribute is a 'all' construct we have to check Min
+ // occures
+ if (attribs[i].getAllElement()) {
+ if (attribs[i].getMinOccurs() == 0) {
+ if (!foundAll) {
+ writer.write("\tconst char* allName = NULL;\n");
+ writer.write("\tbool peekCalled = false;\n");
+ foundAll = true;
}
writer.write("\n\tif(!peekCalled)\n\t{\n\t");
writer.write("\tallName=pIWSDZ->peekNextElementName();\n");
writer.write("\t\tpeekCalled = true;\n");
writer.write("\t}\n");
- writer.write("\tif(strcmp(allName,\"" + attribs[i].getParamNameAsMember()+ "\")==0)\n\t{\n\t");
+ writer.write("\tif(strcmp(allName,\""
+ + attribs[i].getParamNameAsMember()
+ + "\")==0)\n\t{\n\t");
writer.write("\tpeekCalled = false;\n\t");
}
}
//17/05/2005...........................................................
-
- if (attribs[i].isAnyType())
- {
- writer.write("\tparam->any = pIWSDZ->getAnyObject();\n");
- }
- else
- if (attribs[i].isArray())
- {
- //if Array
- if (attribs[i].isSimpleType())
- {
- writer.write("\tarray = pIWSDZ->getBasicArray("+CUtils.getXSDTypeForBasicType(attribs[i].getTypeName())+ ", \""+attribs[i].getParamNameAsSOAPElement()+"\",0);\n");
- // writer.write("\tparam->"+attribs[i].getParamNameAsMember()+" = ("+CUtils.getBasicArrayNameforType(attribs[i].getTypeName())+"&)array;\n");
- String typename = attribs[i].getTypeName();
- if (CUtils.isPointerType(typename))
- {
-
- if(attribs[i].getChoiceElement())
- writer.write("\tparam->"+attribs[i].getParamNameAsMember()+"->m_Array = ("+attribs[i].getTypeName()+"*)new "+attribs[i].getTypeName()+"[array.m_Size];\n");
- else
- writer.write("\tparam->"+attribs[i].getParamNameAsMember()+".m_Array = ("+attribs[i].getTypeName()+"*)new "+attribs[i].getTypeName()+"[array.m_Size];\n");
- }
- else
- {
-
- /**
- *Dushshantha:
- *If the element is a Choice,
- *It should be treated as a pointer to an array.
- *Chinthana: This is the same in 'all' element
- */
-
- if(attribs[i].getChoiceElement() || attribs[i].getAllElement())
- writer.write("\tparam->"+attribs[i].getParamNameAsMember()+"->m_Array = ("+attribs[i].getTypeName()+"**)new "+attribs[i].getTypeName()+"*[array.m_Size];\n");
- else
- writer.write("\tparam->"+attribs[i].getParamNameAsMember()+".m_Array = ("+attribs[i].getTypeName()+"**)new "+attribs[i].getTypeName()+"*[array.m_Size];\n");
- }
-
- /**
- *Dushshantha:
- *If the element is a Choice,
- *It should be treated as a pointer to an array.
- *Chinthana: This is the same in 'all' element
- */
-
- if(attribs[i].getChoiceElement() || attribs[i].getAllElement())
- {
- writer.write("\tparam->"+attribs[i].getParamNameAsMember()+"->m_Size = array.m_Size;\n\n");
- writer.write("\tmemcpy( param->"+attribs[i].getParamNameAsMember()+"->m_Array, array.m_Array, sizeof( "+attribs[i].getTypeName()+" *) * array.m_Size);\n");
- }
- else
- {
- writer.write("\tparam->"+attribs[i].getParamNameAsMember()+".m_Size = array.m_Size;\n\n");
- writer.write("\tmemcpy( param->"+attribs[i].getParamNameAsMember()+".m_Array, array.m_Array, sizeof( "+attribs[i].getTypeName()+" *) * array.m_Size);\n");
- }
- }
- else
- {
- String elm = attribs[i].getParamName();
- if (attribs[i].isReference())
- {
- elm = attribs[i].getTypeName();
- }
- arrayType = attribs[i].getTypeName();
- writer.write(
- "\tparam->"
- + attribs[i].getParamNameAsMember()
- + " = ("
- + attribs[i].getTypeName()
- + "_Array&)pIWSDZ->getCmplxArray((void*)Axis_DeSerialize_"
- + arrayType
- + "\n\t\t, (void*)Axis_Create_"
- + arrayType
- + ", (void*)Axis_Delete_"
- + arrayType
- + "\n\t\t, (void*)Axis_GetSize_"
- + arrayType
- + ", \""
- + elm
- + "\", Axis_URI_"
- + arrayType
- + ");\n");
- }
- }
- else
- if (attribs[i].isSimpleType())
- {
- if (attribs[i].isNillable()
- || attribs[i].getTypeName().equals("xsd__anyURI")
- || attribs[i].getTypeName().equals("xsd__QName")
- || attribs[i].getTypeName().equals("xsd__notation"))
- {
- //TODO handle optional attributes
- writer.write( "\t" + attribs[i].getTypeName() + "* p_" + attribs[i].getParamNameAsMember()
- + " = (pIWSDZ->"
- + CUtils.getParameterGetValueMethodName(
- attribs[i].getTypeName(),
- attribs[i].isAttribute())
- + "(\""
- + attribs[i].getParamName()
- + "\",0));\n");
- writer.write(
- "\tparam->"
- + attribs[i].getParamNameAsMember() + " = *p_" + attribs[i].getParamNameAsMember() + ";\n");
-
- writer.write("\tdelete p_" + attribs[i].getParamNameAsMember() + ";\n");
- }
- else if(attribs[i].getTypeName().equals("xsd__string"))
- {
- writer.write(
- "\tparam->"
- + attribs[i].getParamNameAsMember()
- + " = pIWSDZ->"
- + CUtils.getParameterGetValueMethodName(
- attribs[i].getTypeName(),
- attribs[i].isAttribute())
- + "(\""
- + attribs[i].getParamName()
- + "\",0);\n");
- }
- else
- {
- //TODO handle optional attributes
- /**
- * Dushshantha:
- * if the element is a choice element,
- * it should be treated as a pointer.
- */
-
- if(attribs[i].getChoiceElement() || attribs[i].getAllElement())
- writer.write(
- "\tparam->"
- + attribs[i].getParamNameAsMember() + " = (pIWSDZ->"
- + CUtils.getParameterGetValueMethodName(
- attribs[i].getTypeName(),
- attribs[i].isAttribute())
- + "(\""
- + attribs[i].getParamName()
- + "\",0));\n");
-
- else{
-
- writer.write( "\t" + attribs[i].getTypeName() + "* p_" + attribs[i].getParamNameAsMember()
- + " = (pIWSDZ->"
- + CUtils.getParameterGetValueMethodName(
- attribs[i].getTypeName(),
- attribs[i].isAttribute())
- + "(\""
- + attribs[i].getParamName()
- + "\",0));\n");
- writer.write(
- "\tparam->"
- + attribs[i].getParamNameAsMember() + " = *p_" + attribs[i].getParamNameAsMember() + ";\n");
-
- writer.write("\tdelete p_" + attribs[i].getParamNameAsMember() + ";\n");
- }
-
- }
- }
- else
- {
- writer.write(
- "\tparam->"
- + attribs[i].getParamNameAsMember()
- + " = ("
- + attribs[i].getTypeName()
- + "*)pIWSDZ->getCmplxObject((void*)Axis_DeSerialize_"
- + attribs[i].getTypeName()
- + "\n\t\t, (void*)Axis_Create_"
- + attribs[i].getTypeName()
- + ", (void*)Axis_Delete_"
- + attribs[i].getTypeName()
- + "\n\t\t, \""
- + attribs[i].getParamNameAsSOAPElement()
- + "\", Axis_URI_"
- + attribs[i].getTypeName()
- + ");\n");
- }
-
-
+
+ if (attribs[i].isAnyType()) {
+ writer.write("\tparam->any = pIWSDZ->getAnyObject();\n");
+ } else if (attribs[i].isArray()) {
+ //if Array
+ if (attribs[i].isSimpleType()) {
+ writer.write("\tparam->"
+ + attribs[i].getParamNameAsMember()
+ + " = ("
+ + CUtils.getBasicArrayNameforType(attribs[i]
+ .getTypeName())
+ + "&)pIWSDZ->getBasicArray("
+ + CUtils.getXSDTypeForBasicType(attribs[i]
+ .getTypeName()) + ", \""
+ + attribs[i].getParamName() + "\",0);\n");
+ } else {
+ String elm = attribs[i].getParamName();
+ if (attribs[i].isReference()) {
+ elm = attribs[i].getTypeName();
+ }
+ arrayType = attribs[i].getTypeName();
+ writer
+ .write("\tparam->"
+ + attribs[i].getParamNameAsMember()
+ + " = ("
+ + attribs[i].getTypeName()
+ + "_Array&)pIWSDZ->getCmplxArray((void*)Axis_DeSerialize_"
+ + arrayType + "\n\t\t, (void*)Axis_Create_"
+ + arrayType + ", (void*)Axis_Delete_"
+ + arrayType
+ + "\n\t\t, (void*)Axis_GetSize_"
+ + arrayType + ", \"" + elm
+ + "\", Axis_URI_" + arrayType + ");\n");
+ }
+ } else if (attribs[i].isSimpleType()) {
+ if (attribs[i].isNillable()
+ || attribs[i].getTypeName().equals("xsd__anyURI")
+ || attribs[i].getTypeName().equals("xsd__QName")
+ || attribs[i].getTypeName().equals("xsd__notation")) {
+ //TODO handle optional attributes
+ writer.write("\t"
+ + attribs[i].getTypeName()
+ + "* p_"
+ + attribs[i].getParamNameAsMember()
+ + " = (pIWSDZ->"
+ + CUtils.getParameterGetValueMethodName(attribs[i]
+ .getTypeName(), attribs[i].isAttribute())
+ + "(\"" + attribs[i].getParamName() + "\",0));\n");
+ writer.write("\tparam->"
+ + attribs[i].getParamNameAsMember() + " = *p_"
+ + attribs[i].getParamNameAsMember() + ";\n");
+
+ writer.write("\tdelete p_"
+ + attribs[i].getParamNameAsMember() + ";\n");
+ } else if (attribs[i].getTypeName().equals("xsd__string")
+ || isElementNillable(i)) {
+ writer.write("\tparam->"
+ + attribs[i].getParamNameAsMember()
+ + " = pIWSDZ->"
+ + CUtils.getParameterGetValueMethodName(attribs[i]
+ .getTypeName(), attribs[i].isAttribute())
+ + "(\"" + attribs[i].getParamName() + "\",0);\n");
+ } else {
+ //TODO handle optional attributes
+ /**
+ * Dushshantha: if the element is a choice element, it
+ * should be treated as a pointer.
+ */
+
+ if (attribs[i].getChoiceElement()
+ || attribs[i].getAllElement())
+ writer.write("\tparam->"
+ + attribs[i].getParamNameAsMember()
+ + " = (pIWSDZ->"
+ + CUtils.getParameterGetValueMethodName(
+ attribs[i].getTypeName(), attribs[i]
+ .isAttribute()) + "(\""
+ + attribs[i].getParamName() + "\",0));\n");
+
+ else {
+
+ writer.write("\t"
+ + attribs[i].getTypeName()
+ + "* p_"
+ + attribs[i].getParamNameAsMember()
+ + " = (pIWSDZ->"
+ + CUtils.getParameterGetValueMethodName(
+ attribs[i].getTypeName(), attribs[i]
+ .isAttribute()) + "(\""
+ + attribs[i].getParamName() + "\",0));\n");
+ writer.write("\tparam->"
+ + attribs[i].getParamNameAsMember() + " = *p_"
+ + attribs[i].getParamNameAsMember() + ";\n");
+
+ writer.write("\tdelete p_"
+ + attribs[i].getParamNameAsMember() + ";\n");
+ }
+
+ }
+ } else {
+ writer.write("\tparam->" + attribs[i].getParamNameAsMember()
+ + " = (" + attribs[i].getTypeName()
+ + "*)pIWSDZ->getCmplxObject((void*)Axis_DeSerialize_"
+ + attribs[i].getTypeName()
+ + "\n\t\t, (void*)Axis_Create_"
+ + attribs[i].getTypeName() + ", (void*)Axis_Delete_"
+ + attribs[i].getTypeName() + "\n\t\t, \""
+ + attribs[i].getParamNameAsSOAPElement()
+ + "\", Axis_URI_" + attribs[i].getTypeName() + ");\n");
+ }
+
//Dushshantha:
//end if
-
- if(attribs[i].getChoiceElement())
+
+ if (attribs[i].getChoiceElement())
writer.write("\t}\n");
-
+
//Chinthana: end if
- if(attribs[i].getAllElement())
- {
- if(attribs[i].getMinOccurs() == 0)
+ if (attribs[i].getAllElement()) {
+ if (attribs[i].getMinOccurs() == 0)
writer.write("\t}\n");
}
//17/05/2005.........................................
}
- writer.write("\treturn pIWSDZ->getStatus();\n");
- writer.write("}\n");
- }
-
- private void writeCreateGlobalMethod() throws IOException
- {
- writer.write(
- "void* Axis_Create_"
- + classname
- + "("
- + classname
- + "* pObj, bool bArray = false, int nSize=0)\n{\n");
- writer.write(
- "\tif (bArray && (nSize > 0))\n\t{\n\t\tif (pObj)\n\t\t{\n");
- writer.write(
- "\t\t\t" + classname + "* pNew = new " + classname + "[nSize];\n");
- writer.write(
- "\t\t\tmemcpy(pNew, pObj, sizeof(" + classname + ")*nSize/2);\n");
- writer.write(
- "\t\t\tmemset(pObj, 0, sizeof(" + classname + ")*nSize/2);\n");
- writer.write("\t\t\tdelete [] pObj;\n");
- writer.write("\t\t\treturn pNew;\n\t\t}\n\t\telse\n\t\t{\n");
- writer.write(
- "\t\t\treturn new " + classname + "[nSize];\n\t\t}\n\t}\n");
- writer.write("\telse\n\t\treturn new " + classname + ";\n}\n\n");
- }
- private void writeDeleteGlobalMethod() throws IOException
- {
- writer.write("/*\n");
- writer.write(
- " * This static method delete a "
- + classname
- + " type of object\n");
- writer.write(" */\n");
- writer.write(
- "void Axis_Delete_"
- + classname
- + "("
- + classname
- + "* param, bool bArray = false, int nSize=0)\n");
- writer.write("{\n");
- writer.write("\tif (bArray)\n");
- writer.write("\t{\n");
- writer.write("\t\tdelete [] param;\n");
- writer.write("\t}\n");
- writer.write("\telse\n");
- writer.write("\t{\n");
- writer.write("\t\tdelete param;\n");
- writer.write("\t}\n");
- writer.write("}\n");
- }
- /* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeConstructors()
- */
- protected void writeConstructors() throws WrapperFault
- {
- try
- {
- writer.write("\n" + classname + "::" + classname + "()\n{\n");
- writer.write(
- "\t/*do not allocate memory to any pointer members here\n\t because deserializer will allocate memory anyway. */\n");
- for (int i = 0; i < attribs.length; i++)
- {
- if (attribs[i].isArray())
- {
- writer.write(
- "\t"
- + attribs[i].getParamNameAsMember()
- + ".m_Array = 0;\n");
- writer.write(
- "\t"
- + attribs[i].getParamNameAsMember()
- + ".m_Size = 0;\n");
- }
- else
- if (!attribs[i].isSimpleType())
- {
- writer.write(
- "\t" + attribs[i].getParamNameAsMember() + "=0;\n");
- }
- else
- {
- /* Needed for shared libraries */
- writer.write(
- "\tmemset( &"
- + attribs[i].getParamNameAsMember()
- + ", 0, sizeof( "
- + attribs[i].getTypeName()
- + "));\n");
- }
- }
- writer.write("}\n");
- }
- catch (IOException e)
- {
- throw new WrapperFault(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeDistructors()
- */
- protected void writeDestructors() throws WrapperFault
- {
- try
- {
- if (type.isFault())
- {
- writer.write("\n" + classname + "::~" + classname + "() throw ()\n{\n");
- }
- else
- {
- writer.write("\n" + classname + "::~" + classname + "()\n{\n");
- }
- writer.write("\t/*delete any pointer and array members here*/\n");
- for (int i = 0; i < attribs.length; i++)
- {
- if (attribs[i].isArray())
- {
- writer.write(
- "\tdelete [] (("
- + attribs[i].getTypeName()
- + "*)"
- + attribs[i].getParamNameAsMember()
- + ".m_Array);\n");
- }
- else
- if (!attribs[i].isSimpleType())
- {
- writer.write(
- "\tdelete "
- + attribs[i].getParamNameAsMember()
- + ";\n");
- }
- }
- writer.write("}\n");
- }
- catch (IOException e)
- {
- throw new WrapperFault(e);
- }
- }
-}
+ writer.write("\treturn pIWSDZ->getStatus();\n");
+ writer.write("}\n");
+ }
+
+ private void writeCreateGlobalMethod() throws IOException {
+ writer.write("void* Axis_Create_" + classname + "(" + classname
+ + "* pObj, bool bArray = false, int nSize=0)\n{\n");
+ writer
+ .write("\tif (bArray && (nSize > 0))\n\t{\n\t\tif (pObj)\n\t\t{\n");
+ writer.write("\t\t\t" + classname + "* pNew = new " + classname
+ + "[nSize];\n");
+ writer.write("\t\t\tmemcpy(pNew, pObj, sizeof(" + classname
+ + ")*nSize/2);\n");
+ writer.write("\t\t\tmemset(pObj, 0, sizeof(" + classname
+ + ")*nSize/2);\n");
+ writer.write("\t\t\tdelete [] pObj;\n");
+ writer.write("\t\t\treturn pNew;\n\t\t}\n\t\telse\n\t\t{\n");
+ writer
+ .write("\t\t\treturn new " + classname
+ + "[nSize];\n\t\t}\n\t}\n");
+ writer.write("\telse\n\t\treturn new " + classname + ";\n}\n\n");
+ }
+
+ private void writeDeleteGlobalMethod() throws IOException {
+ writer.write("/*\n");
+ writer.write(" * This static method delete a " + classname
+ + " type of object\n");
+ writer.write(" */\n");
+ writer.write("void Axis_Delete_" + classname + "(" + classname
+ + "* param, bool bArray = false, int nSize=0)\n");
+ writer.write("{\n");
+ writer.write("\tif (bArray)\n");
+ writer.write("\t{\n");
+ writer.write("\t\tdelete [] param;\n");
+ writer.write("\t}\n");
+ writer.write("\telse\n");
+ writer.write("\t{\n");
+ writer.write("\t\tdelete param;\n");
+ writer.write("\t}\n");
+ writer.write("}\n");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeConstructors()
+ */
+ protected void writeConstructors() throws WrapperFault {
+ try {
+ writer.write("\n" + classname + "::" + classname + "()\n{\n");
+ writer
+ .write("\t/*do not allocate memory to any pointer members here\n\t because deserializer will allocate memory anyway. */\n");
+ for (int i = 0; i < attribs.length; i++) {
+ if (attribs[i].isArray()) {
+ writer.write("\t" + attribs[i].getParamNameAsMember()
+ + ".m_Array = 0;\n");
+ writer.write("\t" + attribs[i].getParamNameAsMember()
+ + ".m_Size = 0;\n");
+ } else if (!attribs[i].isSimpleType()) {
+ writer.write("\t" + attribs[i].getParamNameAsMember()
+ + " = 0;\n");
+ }
+ // FJP Nillable vv
+ else if (isElementNillable(i)) {
+ writer.write("\t" + attribs[i].getParamNameAsMember()
+ + " = NULL;\n");
+ }
+ // FJP Nillable ^^
+ else {
+ /* Needed for shared libraries */
+ writer.write("\tmemset( &"
+ + attribs[i].getParamNameAsMember()
+ + ", 0, sizeof( " + attribs[i].getTypeName()
+ + "));\n");
+ }
+ }
+ writer.write("}\n");
+ } catch (IOException e) {
+ throw new WrapperFault(e);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeDistructors()
+ */
+ protected void writeDestructors() throws WrapperFault {
+ try {
+ if (type.isFault()) {
+ writer.write("\n" + classname + "::~" + classname
+ + "() throw ()\n{\n");
+ } else {
+ writer.write("\n" + classname + "::~" + classname + "()\n{\n");
+ }
+ writer.write("\t/*delete any pointer and array members here*/\n");
+ for (int i = 0; i < attribs.length; i++) {
+ if (attribs[i].isArray()) {
+ writer.write("\tdelete [] ((" + attribs[i].getTypeName()
+ + "*)" + attribs[i].getParamNameAsMember()
+ + ".m_Array);\n");
+ } else if (!attribs[i].isSimpleType()) {
+ writer.write("\tdelete "
+ + attribs[i].getParamNameAsMember() + ";\n");
+ }
+ }
+ writer.write("}\n");
+ } catch (IOException e) {
+ throw new WrapperFault(e);
+ }
+ }
+
+ // FJP Nillable vv
+ protected boolean isElementNillable(int index) {
+ ElementInfo ei = type.getElementForElementName(attribs[index]
+ .getParamName());
+ boolean bNillable = false;
+
+ if (ei != null
+ && !("xsd__string".equalsIgnoreCase(attribs[index]
+ .getTypeName()))
+ || "xsd__anyURI".equalsIgnoreCase(attribs[index].getTypeName())
+ || "xsd__QName".equalsIgnoreCase(attribs[index].getTypeName())
+ || "xsd__notation".equalsIgnoreCase(attribs[index]
+ .getTypeName())) {
+ bNillable = ei.getNillable();
+ }
+
+ return bNillable;
+ }
+ // FJP Nillable ^^
+}
\ No newline at end of file
1.32 +256 -280 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParmHeaderFileWriter.java
Index: ParmHeaderFileWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParmHeaderFileWriter.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- ParmHeaderFileWriter.java 18 May 2005 03:50:53 -0000 1.31
+++ ParmHeaderFileWriter.java 14 Jun 2005 14:45:00 -0000 1.32
@@ -1,6 +1,6 @@
/*
* Copyright 2003-2004 The Apache Software Foundation.
-// (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved
+ // (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,289 +34,265 @@
import org.apache.axis.wsdl.wsdl2ws.ParamWriter;
import org.apache.axis.wsdl.wsdl2ws.WSDL2Ws;
import org.apache.axis.wsdl.wsdl2ws.WrapperFault;
+import org.apache.axis.wsdl.wsdl2ws.info.ElementInfo;
+import org.apache.axis.wsdl.wsdl2ws.info.ParameterInfo;
import org.apache.axis.wsdl.wsdl2ws.info.Type;
import org.apache.axis.wsdl.wsdl2ws.info.WebServiceContext;
-public class ParmHeaderFileWriter extends ParamWriter
-{
- public ParmHeaderFileWriter(WebServiceContext wscontext, Type type)
- throws WrapperFault
- {
- super(wscontext, type);
- }
- public void writeSource() throws WrapperFault
- {
- try
- {
- this.writer =
- new BufferedWriter(new FileWriter(getFilePath(), false));
- writeClassComment();
- // if this headerfile not defined define it
- this.writer.write(
- "#if !defined(__"
- + classname.toUpperCase()
- + "_"
- + getFileType().toUpperCase()
- + "_H__INCLUDED_)\n");
- this.writer.write(
- "#define __"
- + classname.toUpperCase()
- + "_"
- + getFileType().toUpperCase()
- + "_H__INCLUDED_\n\n");
- writePreprocessorStatements();
-
- this.writer.write("class " + classname);
- if (this.type.isFault())
- this.writer.write(" : public SoapFaultException");
- this.writer.write("\n{\n");
-
- writeAttributes();
- writeGetSetMethods();
- writeConstructors();
- writeDestructors();
- this.writer.write("};\n\n");
- this.writer.write(
- "#endif /* !defined(__"
- + classname.toUpperCase()
- + "_"
- + getFileType().toUpperCase()
- + "_H__INCLUDED_)*/\n");
- writer.flush();
- writer.close();
- if (WSDL2Ws.verbose)
- {
- System.out.println(
- getFilePath().getAbsolutePath() + " created.....");
- }
- }
- catch (IOException e)
- {
- e.printStackTrace();
- throw new WrapperFault(e);
- }
- }
-
- protected void writeAttributes() throws WrapperFault
- {
- if (type.isArray())
- return;
- try
- {
- writer.write("public:\n");
- for (int i = 0; i < attribs.length; i++)
- {
- //chek if attrib name is same as class name and if so change
- if (classname.equals(attribs[i].getParamName()))
- {
- attribs[i].setParamName("m_" + attribs[i].getParamName());
- }
- writer.write(
- "\t"
- + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i])
- + " "
- + attribs[i].getParamName()
- + ";\n");
- }
- }
- catch (IOException e)
- {
- throw new WrapperFault(e);
- }
- }
-
-
- /**
- * Dushshantha:
- * This method writes getters and setters of the attributes.
- */
- protected void writeGetSetMethods() throws WrapperFault
- {
- if (type.isArray())
- {
- return;
- }
- try
- {
- for (int i = 0; i < attribs.length; i++)
- {
- /**
- * Dushshantha:
- * Write setter
- */
-
- writer.write(
- "\t"
- + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i])
- + " get"
- + attribs[i].getParamNameWithoutSymbols()
- + "();\n");
-
- /**
- * Dushshantha:
- * Write getter
- */
-
- writer.write(
- "\t"
- + "void set"
- + attribs[i].getParamNameWithoutSymbols()
- + "("
- + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i])
- + " InValue);\n\n");
-
-
- }
- }
- catch (IOException e)
- {
- throw new WrapperFault(e);
- }
- }
-
-
- protected void writeConstructors() throws WrapperFault
- {
- try
- {
- writer.write("\t" + classname + "();\n");
- }
- catch (IOException e)
- {
- throw new WrapperFault(e);
- }
- }
-
- protected void writeDestructors() throws WrapperFault
- {
- try
- {
- if (this.type.isFault())
- writer.write("\tvirtual ~" + classname + "() throw();\n");
- else
- writer.write("\tvirtual ~" + classname + "();\n");
- //damitha added virtual
- }
- catch (IOException e)
- {
- throw new WrapperFault(e);
- }
- }
-
- protected void writeMethods() throws WrapperFault
- {}
-
- protected File getFilePath() throws WrapperFault
- {
- return this.getFilePath(false);
- }
- protected File getFilePath(boolean useServiceName) throws WrapperFault
- {
- String targetOutputLocation =
- this.wscontext.getWrapInfo().getTargetOutputLocation();
- if (targetOutputLocation.endsWith("/"))
- {
- targetOutputLocation =
- targetOutputLocation.substring(
- 0,
- targetOutputLocation.length() - 1);
- }
- new File(targetOutputLocation).mkdirs();
-
- String fileName =
- targetOutputLocation + "/" + classname + CUtils.CPP_HEADER_SUFFIX;
-
- if (useServiceName)
- {
- fileName =
- targetOutputLocation
- + "/"
- + this.wscontext.getSerInfo().getServicename()
- + "_"
- + classname
- + CUtils.CPP_HEADER_SUFFIX;
- }
-
- return new File(fileName);
- }
-
- /* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.BasicFileWriter#writePreprocssorStatements()
- */
- protected void writePreprocessorStatements() throws WrapperFault
- {
- try
- {
- writer.write("#include <axis/AxisUserAPI.hpp>\n");
+public class ParmHeaderFileWriter extends ParamWriter {
+ public ParmHeaderFileWriter(WebServiceContext wscontext, Type type)
+ throws WrapperFault {
+ super(wscontext, type);
+ }
+
+ public void writeSource() throws WrapperFault {
+ try {
+ this.writer = new BufferedWriter(new FileWriter(getFilePath(),
+ false));
+ writeClassComment();
+ // if this headerfile not defined define it
+ this.writer.write("#if !defined(__" + classname.toUpperCase() + "_"
+ + getFileType().toUpperCase() + "_H__INCLUDED_)\n");
+ this.writer.write("#define __" + classname.toUpperCase() + "_"
+ + getFileType().toUpperCase() + "_H__INCLUDED_\n\n");
+ writePreprocessorStatements();
+
+ this.writer.write("class " + classname);
+ if (this.type.isFault())
+ this.writer.write(" : public SoapFaultException");
+ this.writer.write("\n{\n");
+
+ writeAttributes();
+ writeGetSetMethods();
+ writeConstructors();
+ writeDestructors();
+ this.writer.write("};\n\n");
+ this.writer.write("#endif /* !defined(__" + classname.toUpperCase()
+ + "_" + getFileType().toUpperCase() + "_H__INCLUDED_)*/\n");
+ writer.flush();
+ writer.close();
+ if (WSDL2Ws.verbose) {
+ System.out.println(getFilePath().getAbsolutePath()
+ + " created.....");
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new WrapperFault(e);
+ }
+ }
+
+ protected void writeAttributes() throws WrapperFault {
+ if (type.isArray())
+ return;
+ try {
+ writer.write("public:\n");
+ for (int i = 0; i < attribs.length; i++) {
+ //chek if attrib name is same as class name and if so change
+ if (classname.equals(attribs[i].getParamName())) {
+ attribs[i].setParamName("m_" + attribs[i].getParamName());
+ }
+ // FJP Nillable vv
+ if (isElementNillable(i)) {
+ writer
+ .write("\t"
+ + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i])
+ + " *\t" + attribs[i].getParamName()
+ + ";\n");
+ } else {
+ // FJP Nillable ^^
+ writer
+ .write("\t"
+ + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i])
+ + "\t" + attribs[i].getParamName() + ";\n");
+ }
+ }
+ } catch (IOException e) {
+ throw new WrapperFault(e);
+ }
+ }
+
+ /**
+ * Dushshantha: This method writes getters and setters of the attributes.
+ */
+ protected void writeGetSetMethods() throws WrapperFault {
+ if (type.isArray()) {
+ return;
+ }
+ try {
+ for (int i = 0; i < attribs.length; i++) {
+ // FJP Nillable vv
+ if (i == 0) {
+ writer.write("\n");
+ }
+ if (isElementNillable(i)) {
+ writer
+ .write("\t"
+ + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i])
+ + " * get"
+ + attribs[i].getParamNameWithoutSymbols()
+ + "();\n");
+
+ writer
+ .write("\t"
+ + "void set"
+ + attribs[i].getParamNameWithoutSymbols()
+ + "("
+ + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i])
+ + " * pInValue);\n\n");
+ } else {
+ // FJP Nillable ^^
+ /**
+ * Dushshantha: Write setter
+ */
+
+ writer
+ .write("\t"
+ + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i])
+ + " get"
+ + attribs[i].getParamNameWithoutSymbols()
+ + "();\n");
+
+ /**
+ * Dushshantha: Write getter
+ */
+
+ writer
+ .write("\t"
+ + "void set"
+ + attribs[i].getParamNameWithoutSymbols()
+ + "("
+ + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i])
+ + " InValue);\n\n");
+ }
+ }
+ } catch (IOException e) {
+ throw new WrapperFault(e);
+ }
+ }
+
+ protected void writeConstructors() throws WrapperFault {
+ try {
+ writer.write("\t" + classname + "();\n");
+ } catch (IOException e) {
+ throw new WrapperFault(e);
+ }
+ }
+
+ protected void writeDestructors() throws WrapperFault {
+ try {
if (this.type.isFault())
- {
+ writer.write("\tvirtual ~" + classname + "() throw();\n");
+ else
+ writer.write("\tvirtual ~" + classname + "();\n");
+ //damitha added virtual
+ } catch (IOException e) {
+ throw new WrapperFault(e);
+ }
+ }
+
+ protected void writeMethods() throws WrapperFault {
+ }
+
+ protected File getFilePath() throws WrapperFault {
+ return this.getFilePath(false);
+ }
+
+ protected File getFilePath(boolean useServiceName) throws WrapperFault {
+ String targetOutputLocation = this.wscontext.getWrapInfo()
+ .getTargetOutputLocation();
+ if (targetOutputLocation.endsWith("/")) {
+ targetOutputLocation = targetOutputLocation.substring(0,
+ targetOutputLocation.length() - 1);
+ }
+ new File(targetOutputLocation).mkdirs();
+
+ String fileName = targetOutputLocation + "/" + classname
+ + CUtils.CPP_HEADER_SUFFIX;
+
+ if (useServiceName) {
+ fileName = targetOutputLocation + "/"
+ + this.wscontext.getSerInfo().getServicename() + "_"
+ + classname + CUtils.CPP_HEADER_SUFFIX;
+ }
+
+ return new File(fileName);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.axis.wsdl.wsdl2ws.cpp.BasicFileWriter#writePreprocssorStatements()
+ */
+ protected void writePreprocessorStatements() throws WrapperFault {
+ try {
+ writer.write("#include <axis/AxisUserAPI.hpp>\n");
+ if (this.type.isFault()) {
writer.write("#include <axis/SoapFaultException.hpp>\n");
writer.write("using namespace std;\n");
}
- writer.write("AXIS_CPP_NAMESPACE_USE \n\n");
- HashSet typeSet = new HashSet();
- for (int i = 0; i < attribs.length; i++)
- {
- if ((attribs[i].isArray()) && (!attribs[i].isSimpleType()))
- {
- typeSet.add(attribs[i].getTypeName() + "_Array");
- }
- if (!(attribs[i].isSimpleType() || attribs[i].isAnyType()))
- {
- typeSet.add(attribs[i].getTypeName());
- }
-
- }
- Iterator itr = typeSet.iterator();
- while (itr.hasNext())
- {
- writer.write(
- "#include \""
- + itr.next().toString()
- + CUtils.CPP_HEADER_SUFFIX
- + "\"\n");
- }
-
- //Local name and the URI for the type
- writer.write("/*Local name and the URI for the type*/\n");
- writer.write(
- "static const char* Axis_URI_"
- + classname
- + " = \""
- + type.getName().getNamespaceURI()
- + "\";\n");
- writer.write(
- "static const char* Axis_TypeName_"
- + classname
- + " = \""
- + type.getName().getLocalPart()
- + "\";\n\n");
-
- // Define class to avoid compilation issue (cycle in includes).
- typeSet = new HashSet();
- for (int i = 0; i < attribs.length; i++)
- {
- //if (!attribs[i].isArray() && !attribs[i].isSimpleType())
- if (!attribs[i].isArray()
- && !attribs[i].isSimpleType()
- && !attribs[i].isAnyType())
- {
- typeSet.add(attribs[i].getTypeName());
- }
- }
- itr = typeSet.iterator();
- while (itr.hasNext())
- {
- writer.write("class " + itr.next().toString() + ";\n");
- }
- }
- catch (IOException e)
- {
- throw new WrapperFault(e);
- }
- }
- protected String getFileType()
- {
- return "Param";
- }
-}
+ writer.write("AXIS_CPP_NAMESPACE_USE \n\n");
+ HashSet typeSet = new HashSet();
+ for (int i = 0; i < attribs.length; i++) {
+ if ((attribs[i].isArray()) && (!attribs[i].isSimpleType())) {
+ typeSet.add(attribs[i].getTypeName() + "_Array");
+ }
+ if (!(attribs[i].isSimpleType() || attribs[i].isAnyType())) {
+ typeSet.add(attribs[i].getTypeName());
+ }
+
+ }
+ Iterator itr = typeSet.iterator();
+ while (itr.hasNext()) {
+ writer.write("#include \"" + itr.next().toString()
+ + CUtils.CPP_HEADER_SUFFIX + "\"\n");
+ }
+
+ //Local name and the URI for the type
+ writer.write("/*Local name and the URI for the type*/\n");
+ writer.write("static const char* Axis_URI_" + classname + " = \""
+ + type.getName().getNamespaceURI() + "\";\n");
+ writer.write("static const char* Axis_TypeName_" + classname
+ + " = \"" + type.getName().getLocalPart() + "\";\n\n");
+
+ // Define class to avoid compilation issue (cycle in includes).
+ typeSet = new HashSet();
+ for (int i = 0; i < attribs.length; i++) {
+ //if (!attribs[i].isArray() && !attribs[i].isSimpleType())
+ if (!attribs[i].isArray() && !attribs[i].isSimpleType()
+ && !attribs[i].isAnyType()) {
+ typeSet.add(attribs[i].getTypeName());
+ }
+ }
+ itr = typeSet.iterator();
+ while (itr.hasNext()) {
+ writer.write("class " + itr.next().toString() + ";\n");
+ }
+ } catch (IOException e) {
+ throw new WrapperFault(e);
+ }
+ }
+
+ protected String getFileType() {
+ return "Param";
+ }
+
+ // FJP Nillable vv
+ protected boolean isElementNillable(int index) {
+ ElementInfo ei = type.getElementForElementName(attribs[index]
+ .getParamName());
+ boolean bNillable = false;
+
+ if (ei != null
+ && !("xsd__string".equalsIgnoreCase(attribs[index]
+ .getTypeName()))
+ || "xsd__anyURI".equalsIgnoreCase(attribs[index].getTypeName())
+ || "xsd__QName".equalsIgnoreCase(attribs[index].getTypeName())
+ || "xsd__notation".equalsIgnoreCase(attribs[index]
+ .getTypeName())) {
+ bNillable = ei.getNillable();
+ }
+
+ return bNillable;
+ }
+ // FJP Nillable ^^
+}
\ No newline at end of file