[patch] FieldOrMethod.java, added two convenience methods

Neeme Praks <[email protected]>
Newsgroups gmane.comp.jakarta.bcel.devel
Message-ID <[email protected]>
I added two convenience methods to FieldOrMethod class:
* Type getReturnType()
* Type[] getArgumentTypes()

So, instead of:
     String signature = method.getSignature();
     Type returnType = Type.getReturnType(signature);
     Type[] argumentTypes = Type.getArgumentTypes(signature);
you can do:
     Type returnType = method.getReturnType();
     Type[] argumentTypes = method.getArgumentTypes();

In order to do this, I had to do an import:
import org.apache.bcel.generic.Type;

I hope this dependency is acceptable?

Rgds,
Neeme

--
To unsubscribe, e-mail:   <mailto:[email protected]>
For additional commands, e-mail: <mailto:[email protected]>
FieldOrMethod.java.diff.txt (text/plain, 909 B)
Index: FieldOrMethod.java
===================================================================
RCS file: /home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/classfile/FieldOrMethod.java,v
retrieving revision 1.3
diff -u -r1.3 FieldOrMethod.java
--- FieldOrMethod.java	24 Apr 2002 11:01:30 -0000	1.3
+++ FieldOrMethod.java	3 Dec 2002 12:28:27 -0000
@@ -54,6 +54,8 @@
  * <http://www.apache.org/>.
  */
 import  org.apache.bcel.Constants;
+import org.apache.bcel.generic.Type;
+
 import java.io.*;
 
 /** 
@@ -202,6 +204,20 @@
     return c.getBytes();
   }
 
+  /**
+   * @return return type of a method
+   */
+  public Type getReturnType() {
+    return Type.getReturnType(getSignature());
+  }
+
+  /**
+   * @return array of method argument types
+   */
+  public Type[] getArgumentTypes() {
+    return Type.getArgumentTypes(getSignature());
+  }
+  
   /**
    * @return deep copy of this field
    */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.