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 di...@apache.org on 2004/11/11 17:24:02 UTC
cvs commit: ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info ElementInfo.java ParameterInfo.java ServiceInfo.java WebServiceContext.java
dicka 2004/11/11 08:24:02
Modified: c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info
ElementInfo.java ParameterInfo.java
ServiceInfo.java WebServiceContext.java
Log:
Improvements to code readability of WSDL2Ws
Submitted by: Adrian Dick
Revision Changes Path
1.4 +104 -84 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/ElementInfo.java
Index: ElementInfo.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/ElementInfo.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ElementInfo.java 9 Apr 2004 08:49:34 -0000 1.3
+++ ElementInfo.java 11 Nov 2004 16:24:02 -0000 1.4
@@ -21,89 +21,109 @@
/**
* @author Srinath Perera(hemapani@opensource.lk)
*/
-public class ElementInfo {
- public static int UNBOUNDED = 999999999;
- private QName name;
- private Type type;
- private int maxOccurs = 1;
- private int minOccurs = 1;
-
-
- public ElementInfo(QName name,Type type){
- this.name = name;
- this.type = type;
-
- if(this.name == null || this.type == null)
- throw new RuntimeException("name or type of the ElementInfo can not be null ");
- }
-
- /**
- * @return int
- */
- public int getMaxOccurs() {
- return maxOccurs;
- }
-
- /**
- * @return int
- */
- public int getMinOccurs() {
- return minOccurs;
- }
-
- /**
- * @return QName
- */
- public QName getName() {
- return name;
- }
-
- /**
- * @return QName
- */
- public Type getType() {
- return type;
- }
-
- /**
- * Sets the maxOccurs.
- * @param maxOccurs The maxOccurs to set
- */
- public void setMaxOccurs(int maxOccurs) {
- this.maxOccurs = maxOccurs;
- }
-
- /**
- * Sets the minOccurs.
- * @param minOccurs The minOccurs to set
- */
- public void setMinOccurs(int minOccurs) {
- this.minOccurs = minOccurs;
- }
-
- /**
- * Sets the name.
- * @param name The name to set
- */
- public void setName(QName name) {
- this.name = name;
- }
-
- /**
- * Sets the type.
- * @param type The type to set
- */
- public void setType(Type type) {
- this.type = type;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- String str = "("+name+","+type.getName()+"| max = "+maxOccurs+" min ="+minOccurs+"|)\n";
- return str;
- }
-
+public class ElementInfo
+{
+ public static int UNBOUNDED = 999999999;
+ private QName name;
+ private Type type;
+ private int maxOccurs = 1;
+ private int minOccurs = 1;
+
+ public ElementInfo(QName name, Type type)
+ {
+ this.name = name;
+ this.type = type;
+
+ if (this.name == null || this.type == null)
+ {
+ throw new RuntimeException("name or type of the ElementInfo can not be null ");
+ }
+ }
+
+ /**
+ * @return int
+ */
+ public int getMaxOccurs()
+ {
+ return maxOccurs;
+ }
+
+ /**
+ * @return int
+ */
+ public int getMinOccurs()
+ {
+ return minOccurs;
+ }
+
+ /**
+ * @return QName
+ */
+ public QName getName()
+ {
+ return name;
+ }
+
+ /**
+ * @return QName
+ */
+ public Type getType()
+ {
+ return type;
+ }
+
+ /**
+ * Sets the maxOccurs.
+ * @param maxOccurs The maxOccurs to set
+ */
+ public void setMaxOccurs(int maxOccurs)
+ {
+ this.maxOccurs = maxOccurs;
+ }
+
+ /**
+ * Sets the minOccurs.
+ * @param minOccurs The minOccurs to set
+ */
+ public void setMinOccurs(int minOccurs)
+ {
+ this.minOccurs = minOccurs;
+ }
+
+ /**
+ * Sets the name.
+ * @param name The name to set
+ */
+ public void setName(QName name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Sets the type.
+ * @param type The type to set
+ */
+ public void setType(Type type)
+ {
+ this.type = type;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ String str =
+ "("
+ + name
+ + ","
+ + type.getName()
+ + "| max = "
+ + maxOccurs
+ + " min ="
+ + minOccurs
+ + "|)\n";
+ return str;
+ }
}
1.15 +159 -114 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/ParameterInfo.java
Index: ParameterInfo.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/ParameterInfo.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ParameterInfo.java 8 Nov 2004 02:57:47 -0000 1.14
+++ ParameterInfo.java 11 Nov 2004 16:24:02 -0000 1.15
@@ -24,114 +24,153 @@
* this class represents Parameter(message in the wsdl)
* @author Srinath Perera(hemapani@opensource.lk)
*/
-public class ParameterInfo {
+public class ParameterInfo
+{
protected Type type;
protected String attribName;
- protected QName elementName;
- private boolean isAnyType = false;
- protected boolean isArray = false;
- private boolean isAttribute = false;
-
- /**
- * @return boolean
- */
- public boolean isArray() {
- return isArray;
- }
-
- /**
- * Sets the isArray.
- * @param isArray The isArray to set
- */
- public void setArray(boolean isArray) {
- this.isArray = isArray;
- }
-
- public boolean isAttribute(){
- return this.isAttribute;
- }
-
- public void setAttribute(boolean isAttribute)
- {
- this.isAttribute = isAttribute;
- }
-
- public String getParamName() {
- // TODO: design review needed
- // - If type and name are equals add "_Ref" ie : ref="..."
- String result;
-
- if (attribName.lastIndexOf(SymbolTable.ANON_TOKEN) > 1 )
- {
- attribName =attribName.substring(attribName.lastIndexOf(SymbolTable.ANON_TOKEN)+1,attribName.length());
- }
- // Samisa: This second call to TypeMap.resoleveWSDL2LanguageNameClashes
- // is made to make sure after replacinf ANON_TOKEN it is still not a keyword
- attribName = TypeMap.resolveWSDL2LanguageNameClashes(attribName, WrapperConstants.LANGUAGE_CPP);
-
- if (isReference())
- result = attribName + "_Ref";
- else
- result = attribName;
- return result;
- }
-
- public String getParamNameAsSOAPElement() {
- String result = attribName;
-
- if (attribName.lastIndexOf(SymbolTable.ANON_TOKEN) > 1 )
- {
- result =attribName.substring(attribName.lastIndexOf(SymbolTable.ANON_TOKEN)+1,attribName.length());
- }
- return result;
- }
-
- /**
- * @return boolean
- */
- public boolean isReference() {
- return type != null && attribName.equals(type.getLanguageSpecificName());
- }
+ protected QName elementName;
+ private boolean isAnyType = false;
+ protected boolean isArray = false;
+ private boolean isAttribute = false;
- public void setParamName(String paramName) {
+ /**
+ * @return boolean
+ */
+ public boolean isArray()
+ {
+ return isArray;
+ }
+
+ /**
+ * Sets the isArray.
+ * @param isArray The isArray to set
+ */
+ public void setArray(boolean isArray)
+ {
+ this.isArray = isArray;
+ }
+
+ public boolean isAttribute()
+ {
+ return this.isAttribute;
+ }
+
+ public void setAttribute(boolean isAttribute)
+ {
+ this.isAttribute = isAttribute;
+ }
+
+ public String getParamName()
+ {
+ // TODO: design review needed
+ // - If type and name are equals add "_Ref" ie : ref="..."
+ String result;
+
+ if (attribName.lastIndexOf(SymbolTable.ANON_TOKEN) > 1)
+ {
+ attribName =
+ attribName.substring(
+ attribName.lastIndexOf(SymbolTable.ANON_TOKEN) + 1,
+ attribName.length());
+ }
+ // Samisa: This second call to TypeMap.resoleveWSDL2LanguageNameClashes
+ // is made to make sure after replacinf ANON_TOKEN it is still not a keyword
+ attribName =
+ TypeMap.resolveWSDL2LanguageNameClashes(
+ attribName,
+ WrapperConstants.LANGUAGE_CPP);
+
+ if (isReference())
+ {
+ result = attribName + "_Ref";
+ }
+ else
+ {
+ result = attribName;
+ }
+ return result;
+ }
+
+ public String getParamNameAsSOAPElement()
+ {
+ String result = attribName;
+
+ if (attribName.lastIndexOf(SymbolTable.ANON_TOKEN) > 1)
+ {
+ result =
+ attribName.substring(
+ attribName.lastIndexOf(SymbolTable.ANON_TOKEN) + 1,
+ attribName.length());
+ }
+ return result;
+ }
+
+ /**
+ * @return boolean
+ */
+ public boolean isReference()
+ {
+ return type != null
+ && attribName.equals(type.getLanguageSpecificName());
+ }
+
+ public void setParamName(String paramName)
+ {
//Samisa: 21/08/2004
- if (paramName.lastIndexOf(SymbolTable.ANON_TOKEN) > 1 )
+ if (paramName.lastIndexOf(SymbolTable.ANON_TOKEN) > 1)
{
- paramName = paramName.substring(paramName.lastIndexOf(SymbolTable.ANON_TOKEN)+1,paramName.length());
+ paramName =
+ paramName.substring(
+ paramName.lastIndexOf(SymbolTable.ANON_TOKEN) + 1,
+ paramName.length());
}
- paramName = TypeMap.resolveWSDL2LanguageNameClashes(paramName, WrapperConstants.LANGUAGE_CPP);
+ paramName =
+ TypeMap.resolveWSDL2LanguageNameClashes(
+ paramName,
+ WrapperConstants.LANGUAGE_CPP);
//Samisa
this.attribName = paramName;
}
- public ParameterInfo(Type type,String attribName) {
+ public ParameterInfo(Type type, String attribName)
+ {
this.type = type;
this.attribName = attribName;
}
- public Type getType() {
+ public Type getType()
+ {
return type;
}
- /**
- *
- */
- public ParameterInfo() {}
+ /**
+ *
+ */
+ public ParameterInfo()
+ {}
/**
* @return
*/
- public QName getElementName() {
+ public QName getElementName()
+ {
return elementName;
}
//Samisa 21/08/2004
- public String getElementNameAsString() {
+ public String getElementNameAsString()
+ {
String paramName = elementName.getLocalPart();
- if (paramName.lastIndexOf(SymbolTable.ANON_TOKEN) > 1 )
+ if (paramName.lastIndexOf(SymbolTable.ANON_TOKEN) > 1)
{
- paramName = paramName.substring(paramName.lastIndexOf(SymbolTable.ANON_TOKEN)+1,paramName.length());
+ paramName =
+ paramName.substring(
+ paramName.lastIndexOf(SymbolTable.ANON_TOKEN) + 1,
+ paramName.length());
}
- paramName = TypeMap.resolveWSDL2LanguageNameClashes(paramName, WrapperConstants.LANGUAGE_CPP);
- return paramName;
+ paramName =
+ TypeMap.resolveWSDL2LanguageNameClashes(
+ paramName,
+ WrapperConstants.LANGUAGE_CPP);
+ return paramName;
}
//Samisa
@@ -139,38 +178,44 @@
/**
* @param name
*/
- public void setElementName(QName name) {
+ public void setElementName(QName name)
+ {
elementName = name;
}
-
- public QName getSchemaName(){
- return this.type.getName();
- }
-
- public String getLangName(){
- return this.type.getLanguageSpecificName();
- }
-
- /**
- * Sets the type.
- * @param type The type to set
- */
- public void setType(Type type) {
- this.type = type;
- }
-
- /**
- * @return
- */
- public boolean isAnyType() {
- return isAnyType;
- }
-
- /**
- * @param b
- */
- public void setAnyType(boolean b) {
- isAnyType = b;
- }
-
+
+ public QName getSchemaName()
+ {
+ return this.type.getName();
+ }
+
+ public String getLangName()
+ {
+ return this.type.getLanguageSpecificName();
+ }
+
+ /**
+ * Sets the type.
+ * @param type The type to set
+ */
+ public void setType(Type type)
+ {
+ this.type = type;
+ }
+
+ /**
+ * @return
+ */
+ public boolean isAnyType()
+ {
+ return isAnyType;
+ }
+
+ /**
+ * @param b
+ */
+ public void setAnyType(boolean b)
+ {
+ isAnyType = b;
+ }
+
}
1.4 +28 -9 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/ServiceInfo.java
Index: ServiceInfo.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/ServiceInfo.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ServiceInfo.java 9 Apr 2004 08:49:34 -0000 1.3
+++ ServiceInfo.java 11 Nov 2004 16:24:02 -0000 1.4
@@ -26,44 +26,63 @@
import org.apache.axis.wsdl.wsdl2ws.WrapperFault;
import org.apache.axis.wsdl.wsdl2ws.WrapperUtils;
-public class ServiceInfo {
+public class ServiceInfo
+{
private String servicename;
private String qualifiedServiceName;
private ArrayList methods;
private String[][] parameters;
- public ServiceInfo(String servicename,
- String qualifiedServiceName, ArrayList methods) throws WrapperFault {
+ public ServiceInfo(
+ String servicename,
+ String qualifiedServiceName,
+ ArrayList methods)
+ throws WrapperFault
+ {
this.methods = methods;
this.qualifiedServiceName = qualifiedServiceName;
this.servicename = servicename;
//validate the infomormation
- if (this.qualifiedServiceName == null) throw new WrapperFault("The fully qualified parameter name can't be null");
- if (servicename == null) servicename = WrapperUtils.getClassNameFromFullyQualifiedName(qualifiedServiceName);
+ if (this.qualifiedServiceName == null)
+ {
+ throw new WrapperFault("The fully qualified parameter name can't be null");
+ }
+ if (servicename == null)
+ {
+ servicename =
+ WrapperUtils.getClassNameFromFullyQualifiedName(
+ qualifiedServiceName);
+ }
if (this.methods == null || this.methods.size() == 0)
+ {
throw new WrapperFault("service with no methods no point writing a wrapper");
+ }
if (this.parameters == null)
+ {
this.parameters = new String[0][0];
+ }
}
/**
* @return String[]
*/
- public ArrayList getMethods() {
+ public ArrayList getMethods()
+ {
return methods;
}
-
- public String getQualifiedServiceName() {
+ public String getQualifiedServiceName()
+ {
return qualifiedServiceName;
}
/**
* @return String
*/
- public String getServicename() {
+ public String getServicename()
+ {
return servicename;
}
}
1.4 +33 -20 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/WebServiceContext.java
Index: WebServiceContext.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/WebServiceContext.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- WebServiceContext.java 12 Jun 2004 03:57:12 -0000 1.3
+++ WebServiceContext.java 11 Nov 2004 16:24:02 -0000 1.4
@@ -31,51 +31,64 @@
import org.apache.axis.wsdl.wsdl2ws.WrapperFault;
-public class WebServiceContext {
+public class WebServiceContext
+{
private WrapperInfo wrapInfo;
private ServiceInfo serInfo;
private TypeMap typemap;
-
- private HashSet generatedFileList = new HashSet();
-
- public WebServiceContext(WrapperInfo wrapInfo, ServiceInfo serInfo, TypeMap typemap) throws WrapperFault {
+
+ private HashSet generatedFileList = new HashSet();
+
+ public WebServiceContext(
+ WrapperInfo wrapInfo,
+ ServiceInfo serInfo,
+ TypeMap typemap)
+ throws WrapperFault
+ {
this.wrapInfo = wrapInfo;
this.serInfo = serInfo;
this.typemap = typemap;
if (wrapInfo == null || this.serInfo == null || this.typemap == null)
- throw new WrapperFault("Insuficent Info");
+ {
+ throw new WrapperFault("Insufficient Info");
+ }
}
/**
* @return ServiceInfo
*/
- public ServiceInfo getSerInfo() {
+ public ServiceInfo getSerInfo()
+ {
return serInfo;
}
- /**
- * Adds a name of the generated file
- * @param filename
- */
- public void addGeneratedFile(String filename){
- generatedFileList.add(filename);
- }
-
- public HashSet getGeneratedFileList(){
- return generatedFileList;
- }
+ /**
+ * Adds a name of the generated file
+ * @param filename
+ */
+ public void addGeneratedFile(String filename)
+ {
+ generatedFileList.add(filename);
+ }
+
+ public HashSet getGeneratedFileList()
+ {
+ return generatedFileList;
+ }
/**
* @return TypeMap
*/
- public TypeMap getTypemap() {
+ public TypeMap getTypemap()
+ {
return typemap;
}
/**
* @return WrapperInfo
*/
- public WrapperInfo getWrapInfo() {
+ public WrapperInfo getWrapInfo()
+ {
return wrapInfo;
}