Author: jochen
Date: Fri Aug 12 12:12:33 2005
New Revision: 232358

URL: http://svn.apache.org/viewcvs?rev=232358&view=rev
Log:
Added several methods for modifying and querying a methods signature.

Modified:
    webservices/jaxme/branches/b0_5/build.xml
    
webservices/jaxme/branches/b0_5/src/js/org/apache/ws/jaxme/js/AbstractJavaMethod.java
    webservices/jaxme/branches/b0_5/status.xml

Modified: webservices/jaxme/branches/b0_5/build.xml
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/branches/b0_5/build.xml?rev=232358&r1=232357&r2=232358&view=diff
==============================================================================
--- webservices/jaxme/branches/b0_5/build.xml (original)
+++ webservices/jaxme/branches/b0_5/build.xml Fri Aug 12 12:12:33 2005
@@ -14,7 +14,7 @@
  * limitations under the License.
 -->
 <project name="JaxMe" default="all">
-    <property name="version" value="0.5"/>
+    <property name="version" value="0.5.1-dev"/>
     <property name="debug" value="true"/>
     <property name="optimize" value="false"/>   
 

Modified: 
webservices/jaxme/branches/b0_5/src/js/org/apache/ws/jaxme/js/AbstractJavaMethod.java
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/branches/b0_5/src/js/org/apache/ws/jaxme/js/AbstractJavaMethod.java?rev=232358&r1=232357&r2=232358&view=diff
==============================================================================
--- 
webservices/jaxme/branches/b0_5/src/js/org/apache/ws/jaxme/js/AbstractJavaMethod.java
 (original)
+++ 
webservices/jaxme/branches/b0_5/src/js/org/apache/ws/jaxme/js/AbstractJavaMethod.java
 Fri Aug 12 12:12:33 2005
@@ -12,191 +12,193 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
-
+ 
  */
 package org.apache.ws.jaxme.js;
 
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import java.util.StringTokenizer;
 
 import org.apache.ws.jaxme.js.JavaSource.Protection;
 
 
-/**
- * @author <a href="mailto:[EMAIL PROTECTED]">Jochen Wiedmann</a>
+/** Base class of methods, constructors, and the like.
  */
-public abstract class AbstractJavaMethod
-    extends ConditionalIndentationJavaSourceObject {
-  private List exceptions = new ArrayList();
-  private List params = new ArrayList();
-  public AbstractJavaMethod(String pName, JavaQName pType,
-                            Protection pProtection) {
-    super(pName, pType, pProtection);
-  }
-
-  /** <p>Returns whether the method is throwing the given exception.
-   * Note that this method doesn't care for inheritance. For example,
-   * if the method declares to be throwing an [EMAIL PROTECTED] 
java.io.IOException},
-   * then the value 
<code>isThrowing(java.net.MalformedURLException.class)</code>
-   * is still false.</p>
-   */
-  public boolean isThrowing(JavaQName e) {
-    if (e == null) {
-      throw new NullPointerException("The exception argument must not be 
null.");
-    }
-    for (Iterator iter = exceptions.iterator();  iter.hasNext();  ) {
-      if (e.equals(iter.next())) {
-        return true;
-      }
-    }
-    return false;
-  }
-
-  /** <p>Returns whether the method is throwing the given exception.
-   * Note that this method doesn't care for inheritance. For example,
-   * if the method declares to be throwing an [EMAIL PROTECTED] 
java.io.IOException},
-   * then the value 
<code>isThrowing(java.net.MalformedURLException.class)</code>
-   * is still false.</p>
-   */
-  public boolean isThrowing(Class e) {
-    if (e == null) {
-      throw new NullPointerException("The exception argument must not be 
null.");
-    }
-    return isThrowing(JavaQNameImpl.getInstance(e));
-  }
-
-  /** <p>Adds an exception to this methods list of exceptions.</p>
-   *
-   * @see #getExceptions
-   */
-  public void addThrows(JavaQName e) {
-    if (e == null) {
-      throw new NullPointerException("The exception argument must not be 
null.");
-    }
-    if (!exceptions.contains(e)) {
-      exceptions.add(e);
-    }
-  }
-
-  /** <p>Adds an exception to this methods list of exceptions.</p>
-   *
-   * @see #getExceptions
-   */
-  public void addThrows(Class e) {
-    if (e == null) {
-      throw new NullPointerException("The exception argument must not be 
null.");
-    }
-    exceptions.add(JavaQNameImpl.getInstance(e));
-  }
-
-  /** <p>Adds an exception to this methods list of exceptions.</p>
-   *
-   * @see #getExceptions
-   * @deprecated Use [EMAIL PROTECTED] #addThrows(JavaQName)}
-   */
-  public void addThrows(String e) {
-    exceptions.add(JavaQNameImpl.getInstance(e));
-    if (e == null) {
-      throw new NullPointerException("The exception argument must not be 
null.");
-    }
-  }
-
-
-  /** <p>Adds a parameter that this method takes.</p>
-   *
-   * @see #getParams
-   * @deprecated Use [EMAIL PROTECTED] #addParam(JavaQName, String)}
-   */
-  public void addParam(String p) {
-    if (p == null) {
-      throw new NullPointerException("param argument must not be null");
-    }
-    StringTokenizer st = new StringTokenizer(p);
-    if (!st.hasMoreTokens()) {
-      throw new IllegalArgumentException("param argument must have two tokens: 
type name");
-    }
-    String type = st.nextToken();
-    if (!st.hasMoreTokens()) {
-      throw new IllegalArgumentException("param argument must have two tokens: 
type name");
-    }
-    String name = st.nextToken();
-    if (st.hasMoreTokens()) {
-      throw new IllegalArgumentException("param argument must have exactly two 
tokens: type name");
-    }
-    addParam(type, name);
-  }
-
-  /** <p>Adds a parameter that this method takes.</p>
-   *
-   * @see #getParams
-   * @deprecated Use [EMAIL PROTECTED] #addParam(JavaQName, String)}
-   */
-  public void addParam(String p, String v) {
-    if (p == null) {
-      throw new NullPointerException("param argument must not be null");
-    }
-    p = p.trim();
-    addParam(JavaQNameImpl.getInstance(p), v);
-  }
-
-  /** <p>Adds a parameter that this method takes.</p>
-   *
-   * @see #getParams
-   * @return An object to use for referencing the parameter inside the method.
-   */
-  public Parameter addParam(Class p, String v) {
-    return addParam(JavaQNameImpl.getInstance(p), v);
-  }
-
-  /** <p>Adds a parameter that this method takes.</p>
-   *
-   * @see #getParams
-   * @return An object to use for referencing the parameter inside the method.
-   */
-  public Parameter addParam(JavaQName pType, String pName) {
-    if (pType == null) {
-      throw new NullPointerException("Type argument must not be null");
-    }
-    if (pName == null) {
-      throw new NullPointerException("Parameter name argument must not be 
null");
-    }
-    Parameter p = new Parameter(pType, pName);
-    params.add(p);
-    return p;
-  }
-
-  /** <p>Adds a parameter that this method takes.</p>
-   *
-   * @see #getParams
-   * @return An object to use for referencing the parameter inside the method.
-   */
-  public Parameter addParam(Parameter pParam) {
-    return addParam(pParam.getType(), pParam.getName());
-  }
-
-  /** <p>Clears the list of parameters.</p>
-   */
-  public void clearParams() {
-    params.clear();
-  }
-
-  /** <p>Returns the list of exceptions thrown by this method.</p>
-   *
-   * @see #addThrows(JavaQName)
-   */
-  public JavaQName[] getExceptions() {
-    return (JavaQName[]) exceptions.toArray(new JavaQName[exceptions.size()]);
-  }
-
-
-  /** <p>Returns the list of parameters that this method takes. Any element
-   * in the list is an instance of [EMAIL PROTECTED] Parameter}.</p>
-   *
-   * @see #addParam(JavaQName, String)
-   */
-  public Parameter[] getParams() {
-         return (Parameter[]) params.toArray(new Parameter[params.size()]);
-  }
+public abstract class AbstractJavaMethod extends 
ConditionalIndentationJavaSourceObject {
+       private List exceptions = new ArrayList();
+       private List params = new ArrayList();
+       
+       protected AbstractJavaMethod(String pName, JavaQName pType,
+                       Protection pProtection) {
+               super(pName, pType, pProtection);
+       }
+       
+       /** <p>Returns whether the method is throwing the given exception.
+        * Note that this method doesn't care for inheritance. For example,
+        * if the method declares to be throwing an [EMAIL PROTECTED] 
java.net.MalformedURLException},
+        * then the value <code>isThrowing(java.io.IOException.class)</code>
+        * is still false.</p>
+        */
+       public boolean isThrowing(JavaQName e) {
+               if (e == null) {
+                       throw new NullPointerException("The exception argument 
must not be null.");
+               }
+               for (Iterator iter = exceptions.iterator();  iter.hasNext();  ) 
{
+                       if (e.equals(iter.next())) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+       
+       /** <p>Returns whether the method is throwing the given exception.
+        * Note that this method doesn't care for inheritance. For example,
+        * if the method declares to be throwing an [EMAIL PROTECTED] 
java.net.MalformedURLException},
+        * then the value <code>isThrowing(java.io.IOException.class)</code>
+        * is still false.</p>
+        */
+       public boolean isThrowing(Class e) {
+               if (e == null) {
+                       throw new NullPointerException("The exception argument 
must not be null.");
+               }
+               return isThrowing(JavaQNameImpl.getInstance(e));
+       }
+       
+       /** <p>Adds an exception to this methods list of exceptions.</p>
+        *
+        * @see #getExceptions
+        */
+       public void addThrows(JavaQName e) {
+               if (e == null) {
+                       throw new NullPointerException("The exception argument 
must not be null.");
+               }
+               if (!exceptions.contains(e)) {
+                       exceptions.add(e);
+               }
+       }
+       
+       /** <p>Adds an exception to this methods list of exceptions.</p>
+        *
+        * @see #getExceptions
+        */
+       public void addThrows(Class e) {
+               if (e == null) {
+                       throw new NullPointerException("The exception argument 
must not be null.");
+               }
+               exceptions.add(JavaQNameImpl.getInstance(e));
+       }
+       
+       /** <p>Adds a parameter that this method takes.</p>
+        *
+        * @see #getParams
+        * @return An object to use for referencing the parameter inside the 
method.
+        */
+       public Parameter addParam(Class p, String v) {
+               return addParam(JavaQNameImpl.getInstance(p), v);
+       }
+       
+       /** <p>Adds a parameter that this method takes.</p>
+        *
+        * @see #getParams
+        * @return An object to use for referencing the parameter inside the 
method.
+        */
+       public Parameter addParam(JavaQName pType, String pName) {
+               if (pType == null) {
+                       throw new NullPointerException("Type argument must not 
be null");
+               }
+               if (pName == null) {
+                       throw new NullPointerException("Parameter name argument 
must not be null");
+               }
+               for (Iterator iter = params.iterator(); iter.hasNext();) {
+                       Parameter param = (Parameter) iter.next();
+                       if (param.getName().equals(pName)) {
+                               throw new IllegalArgumentException("Parameter 
name '" + pName + "' is already used for a parameter of type " + 
param.getType());
+                       }
+               }
+               Parameter p = new Parameter(pType, pName);
+               params.add(p);
+               return p;
+       }
+       
+       /** <p>Adds a parameter that this method takes.</p>
+        *
+        * @see #getParams
+        * @return An object to use for referencing the parameter inside the 
method.
+        */
+       public Parameter addParam(Parameter pParam) {
+               return addParam(pParam.getType(), pParam.getName());
+       }
+       
+       /** <p>Clears the list of parameters.</p>
+        */
+       public void clearParams() {
+               params.clear();
+       }
+       
+       /** <p>Returns the list of exceptions thrown by this method.</p>
+        *
+        * @see #addThrows(JavaQName)
+        */
+       public JavaQName[] getExceptions() {
+               return (JavaQName[]) exceptions.toArray(new 
JavaQName[exceptions.size()]);
+       }
+       
+       
+       /** <p>Returns the list of parameters that this method takes. Any 
element
+        * in the list is an instance of [EMAIL PROTECTED] Parameter}.</p>
+        *
+        * @return the list of parameters
+        * @see #addParam(JavaQName, String)
+        */
+       public Parameter[] getParams() {
+               return (Parameter[]) params.toArray(new 
Parameter[params.size()]);
+       }
+       
+       /** <p>Returns a list of the parameter names that this method takes. 
Any element
+        * in the list is an instance of [EMAIL PROTECTED] 
java.lang.String}.</p>
+        *
+        * @return the list of parameter names
+        * @see #addParam(JavaQName, String)
+        */
+       public String[] getParamNames() {
+               String[] res = new String[params.size()];
+               for (int i = 0;  i < params.size();  i++) {
+                       res[i++] = ((Parameter) params.get(i)).getName();       
 
+               }
+               return res;
+       }
+       
+       /** <p>Returns an array of the parameter types that this method takes. 
This array can be used for JavaSource.getMethod() or 
JavaSource.getConstructor().</p>
+        *
+        * @return the list of parameter types
+        * @see #addParam(JavaQName, String)
+        */
+       public JavaQName[] getParamTypes() {
+               JavaQName[] res = new JavaQName[params.size()];
+               for (int i = 0;  i < params.size();  i++) {
+                       res[i++] = ((Parameter) params.get(i)).getType();       
 
+               }
+               return res;
+       }
+       
+       /** <p>Removes an exception from this methods list of exceptions, if it 
is declared to be thrown.</p>
+        * @param exc the exception to be removed 
+        */
+       public void removeThrows(JavaQName exc) {
+               exceptions.remove(exc);
+       }
+       
+       /** <p>Removes an exception from this methods list of exceptions, if it 
is declared to be thrown.</p>
+        * @param exc the exception to be removed 
+        */
+       public void removeThrows(Class exc) {
+               removeThrows(JavaQNameImpl.getInstance(exc));
+       }
+
+       /** <p>Clears the list of thrown exceptions.</p>
+        */
+       public void clearThrows() {
+               exceptions.clear();
+       }
 }

Modified: webservices/jaxme/branches/b0_5/status.xml
URL: 
http://svn.apache.org/viewcvs/webservices/jaxme/branches/b0_5/status.xml?rev=232358&r1=232357&r2=232358&view=diff
==============================================================================
--- webservices/jaxme/branches/b0_5/status.xml (original)
+++ webservices/jaxme/branches/b0_5/status.xml Fri Aug 12 12:12:33 2005
@@ -30,7 +30,14 @@
   </todo>
 
   <changes>
-       <release version="0.5" date="Not yet published">
+    <release version="0.5.1-dev" date="Not yet published">
+      <action dev="JW" type="enhancement" context="js">
+        Added several methods for modifying and querying the
+        methods signature.
+               (Frederic Ahring, fahring at de.ibm.com)
+      </action>
+    </release>
+       <release version="0.5" date="2005-Aug-08">
       <action dev="JW" type="enhancement" context="js">
         Added JavaSource.getConstructor(JavaQName[]).
                (Frederic Ahring, fahring at de.ibm.com)



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to