Author: keith
Date: Tue Apr 22 02:28:13 2008
New Revision: 15934

Log:

Adding JavaDoc comments


Modified:
   
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/SchemaGenerator.java

Modified: 
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/SchemaGenerator.java
==============================================================================
--- 
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/SchemaGenerator.java
      (original)
+++ 
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/SchemaGenerator.java
      Tue Apr 22 02:28:13 2008
@@ -48,29 +48,41 @@
 
     private TypeTable typeTable = new TypeTable();
 
-    public NamespaceMap getNamespaceMap() {
-        return nameSpacesMap;
-    }
-
     private NamespaceMap nameSpacesMap = new NamespaceMap();
 
+    /**
+     * This class is used to genarate the XMLSchema for input and output 
messages on JavaScript
+     * services
+     * @param schemaTargetNamespace The schema Target Namespace for this 
service
+     */
     public SchemaGenerator(String schemaTargetNamespace) {
         this.schemaTargetNamespace = schemaTargetNamespace;
+
+        // Initialize XmlSchema and XmlSchemaCollection
         XmlSchemaCollection xmlSchemaCollection = new XmlSchemaCollection();
         xmlSchema = new XmlSchema(this.schemaTargetNamespace, 
xmlSchemaCollection);
+
+        // Setting attributeFormDefault and elementFormDefault to unqualified
         xmlSchema.setAttributeFormDefault(new 
XmlSchemaForm(XmlSchemaForm.UNQUALIFIED));
         xmlSchema.setElementFormDefault(new 
XmlSchemaForm(XmlSchemaForm.UNQUALIFIED));
 
+        // Adding the schema Namespace Prefix and the default prefix to the 
namespace map
         nameSpacesMap.put(Java2WSDLConstants.DEFAULT_SCHEMA_NAMESPACE_PREFIX,
                           Java2WSDLConstants.URI_2001_SCHEMA_XSD);
         nameSpacesMap.put(prefix, this.schemaTargetNamespace);
         xmlSchema.setNamespaceContext(nameSpacesMap);
     }
 
-    public XmlSchema getSchema() {
-        return xmlSchema;
-    }
-
+    /**
+     * This method creates a XmlSchemaElement for the input message
+     * @param message The in AxisMessage
+     * @param input The input objets
+     * @param functionName The operation name
+     * @param params The parameters of the function as a String array
+     * @param methodName The JavaScript method name
+     * @return XmlSchemaElement A XmlSchemaElement corresponding to the input 
message
+     * @throws MashupFault Thrown in case an exception occurs while genarating 
the schema
+     */
     public XmlSchemaElement createInputElement(AxisMessage message, Object 
input,
                                                String functionName, String[] 
params,
                                                String methodName)
@@ -78,10 +90,24 @@
         return createElement(message, functionName, input, functionName, 
params, methodName);
     }
 
+    /**
+     * This method creates a XmlSchemaElement for the output message
+     * @param message The out AxisMessage
+     * @param output The output objets
+     * @param functionName The operation name
+     * @param params The output parameter of the function as a String array
+     * @param methodName The JavaScript method name
+     * @return XmlSchemaElement A XmlSchemaElement corresponding to the output 
message
+     * @throws MashupFault Thrown in case an exception occurs while genarating 
the schema
+     */
     public XmlSchemaElement createOutputElement(AxisMessage message, Object 
output,
                                                 String functionName, String[] 
params,
                                                 String methodName)
             throws MashupFault {
+
+        // If the output of the function is complex we need to get the 
parameter names of the
+        // complex object into an array so that we can reuse the same function 
we use to genarate
+        // schema for the input message
         if (output instanceof NativeObject) {
             NativeObject nativeObject = (NativeObject) output;
             Object[] objects = ScriptableObject.getPropertyIds(nativeObject);
@@ -89,6 +115,8 @@
             if (length == 0) {
                 return null;
             }
+
+            // Get all the parameter names into a String array
             String[] innerParams = new String[length];
             for (int j = 0; j < length; j++) {
                 Object object = objects[j];
@@ -101,6 +129,8 @@
                                  innerParams, methodName);
         } else if (output instanceof String) {
             String outputString = (String) output;
+
+            // The XmlSchemaElement been null corresponds to #none in wsdl2
             if ("".equals(outputString) || "none".equals(outputString)) {
                 return null;
             }
@@ -110,6 +140,17 @@
                              params, methodName);
     }
 
+    /**
+     * A Native object in JavaScript means that it corresponds to a complex 
Type in XML schema.
+     * Hence this method returns XmlSchemaElement which has a complex Type
+     * @param axisMessage The corresponding AxisMessage
+     * @param nativeObject The JsvsScript NativeObject that holds the type 
information
+     * @param elementName The element Name of this complex type
+     * @param params A String array which hold the parameter names
+     * @param methodName The JavaScript nethod name
+     * @return XmlSchemaElement which wrappes the nativeObject
+     * @throws MashupFault Thrown in case an exception occurs
+     */
     private XmlSchemaElement handleNativeObject(AxisMessage axisMessage, 
NativeObject nativeObject,
                                                 String elementName, String[] 
params,
                                                 String methodName) throws 
MashupFault {
@@ -126,6 +167,11 @@
         return xmlSchemaElement;
     }
 
+    /**
+     * Given a set of params returns a JavaScript nativeObject object that 
holds those parameters
+     * @param params A String array that holds the parameters
+     * @return NativeObject that wrapps the parameters
+     */
     private NativeObject createNativeObject(String params[]) {
         NativeObject nativeObject = new NativeObject();
         for (int i = 0; i < params.length; i++) {
@@ -134,6 +180,17 @@
         return nativeObject;
     }
 
+    /**
+     * This method creates a XmlSchemaElement for the message
+     * @param message The AxisMessage
+     * @param object Object that represents the parameters
+     * @param functionName The operation name
+     * @param elementName The element Name to be used
+     * @param params The parameters of the function as a String array
+     * @param methodName The JavaScript method name
+     * @return XmlSchemaElement A XmlSchemaElement corresponding to the message
+     * @throws MashupFault Thrown in case an exception occurs while genarating 
the schema
+     */
     private XmlSchemaElement createElement(AxisMessage message, String 
functionName, Object object,
                                            String elementName,
                                            String[] params, String methodName)
@@ -165,7 +222,8 @@
                 return null;
             }
         } else if ((params.length == 1) && "".equals(params[0].trim())) {
-            // If no annotations are present and if the function does not have 
any parameters no need any schema stuff
+            // If no annotations are present and if the function does not have 
any parameters no
+            // need any schema stuff
             return null;
         } else {
             xmlSchemaElement = handleNativeObject(message, 
createNativeObject(params), elementName,
@@ -181,13 +239,23 @@
         return xmlSchemaElement;
     }
 
+    /**
+     * Given a String this function creates a complex Type for it
+     * @param axisMessage The AxisMessage
+     * @param functionName The operation name
+     * @param params The parameters as a String array
+     * @param name The name of the complex type
+     * @param type The type
+     * @return XmlSchemaElement the created complex Type
+     * @throws MashupFault Thrown in case an exception occurs
+     */
     private XmlSchemaElement createComplexTypeFromString(AxisMessage 
axisMessage,
                                                          String functionName, 
String[] params,
                                                          String name,
                                                          String type) throws 
MashupFault {
         String paramName = params[0].trim();
-        // If the type is none we just return null so that in the WSDL2 it 
will be #none and WSDL 1.1 will show no
-        // input message
+        // If the type is none we just return null so that in the WSDL2 it 
will be #none and
+        // WSDL 1.1 will show no input message
         if ("none".equalsIgnoreCase(type) ||
                 ("".equals(paramName) && (("".equals(type)) || 
"#raw".equalsIgnoreCase(type)))) {
             return null;
@@ -218,6 +286,16 @@
         return xmlSchemaElement;
     }
 
+    /**
+     * Given a JavaScript native object creates a complex type
+     * @param axisMessage The AxisMessage
+     * @param elementName The name of the element
+     * @param inputObject The JavaScript NativeObject
+     * @param params An array holding the parameters
+     * @param method The JavaScript method name
+     * @return XmlSchemaComplexType whcih represents the JavaScript 
NativeObject
+     * @throws MashupFault Thrown in case an exception occurs
+     */
     private XmlSchemaComplexType createComplexType(AxisMessage axisMessage, 
String elementName,
                                                    NativeObject inputObject,
                                                    String[] params, String 
method)
@@ -286,6 +364,13 @@
         return complexType;
     }
 
+    /**
+     * Given a name and a type creates an XmlSchemaElement for it
+     * @param name The name of the elemnt
+     * @param paramType The type of the element
+     * @return XmlSchemaElement representing the name and the type
+     * @throws MashupFault Thrown in case an exception occurs
+     */
     private XmlSchemaElement createXMLSchemaElement(String name, Object 
paramType)
             throws MashupFault {
         XmlSchemaElement xmlSchemaElement = new XmlSchemaElement();
@@ -342,11 +427,34 @@
         return null;
     }
 
+    /**
+     * Returns the schemaTargetNamespace for the service
+     *
+     * @return String The schemaTargetNamespace for the service
+     */
     public String getSchemaTargetNamespace() {
         return schemaTargetNamespace;
     }
 
     /**
+     * Returns the nameSpacesMap for the service
+     *
+     * @return NamespaceMap The nameSpacesMap for the service
+     */
+    public NamespaceMap getNamespaceMap() {
+        return nameSpacesMap;
+    }
+
+    /**
+     * Returns the complete schema for the service
+     *
+     * @return XmlSchema the complete schema for the service
+     */
+    public XmlSchema getSchema() {
+        return xmlSchema;
+    }
+
+    /**
      * If the inputType annotations match the pattern of enumeration create 
the appropriate schema element to handle
      * that.
      *
@@ -373,4 +481,4 @@
 
         return simpleType;
     }
-}
+}
\ No newline at end of file

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to