User: user57
Date: 02/04/05 20:48:30
Modified: src/main/org/jboss/proxy/compiler Utility.java
Log:
o reformat so I could read
Revision Changes Path
1.2 +61 -36 jboss/src/main/org/jboss/proxy/compiler/Utility.java
Index: Utility.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/proxy/compiler/Utility.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Utility.java 7 Mar 2002 17:03:53 -0000 1.1
+++ Utility.java 6 Apr 2002 04:48:30 -0000 1.2
@@ -4,19 +4,20 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
-package org.jboss.proxy.compiler;
+package org.jboss.proxy.compiler;
import org.apache.bcel.Constants;
import org.apache.bcel.generic.BasicType;
-import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.ObjectType;
import org.apache.bcel.generic.Type;
+import org.jboss.util.UnreachableStatementException;
+
/**
* Some Routines to convert from <code>java.lang.Class</code> to
* <code>org.apache.bcel.generic.Type</code>. These get round some
- * inconsistencies with Class.getName() wrt primitives
+ * inconsistencies with Class.getName() wrt primitives.
*
* <pre>
* e.g.
@@ -24,17 +25,20 @@
* <code>Character.Type.getName()</code> returns char.
*
* </pre>
+ *
+ * <p>
* I think it should return C. Don't know if this is a code bug. But there's a bug
* on Bug Parade (#4369208) about the javadoc being misleading.
*
* @see java.lang.Class#getName
*
+ * @version <tt>$Revision: 1.2 $</tt>
* @author <a href="mailto:[EMAIL PROTECTED]">Neale Swinnerton</a>
- * @version $Revision: 1.1 $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
*/
-public abstract class Utility extends org.apache.bcel.classfile.Utility {
-
-
+public abstract class Utility
+ extends org.apache.bcel.classfile.Utility
+{
/**
* Get the <code>org.apache.bcel.generic.Type</code> for a class.
* This handles the case where the class represents an n-dimensional
@@ -50,58 +54,69 @@
*
* @see Utility
*
- * @param clazz a <code>Class</code> value
- * @return a <code>Type</code> value
+ * @param clazz a <code>Class</code> value
+ * @return a <code>Type</code> value
*/
public static Type getType(Class clazz) {
- if (clazz.isPrimitive() ) {
+ if (clazz.isPrimitive()) {
if (clazz.equals(Boolean.TYPE) ) {
return Type.BOOLEAN;
- } else if (clazz.equals(Byte.TYPE) ) {
+ }
+ else if (clazz.equals(Byte.TYPE) ) {
return Type.BYTE;
- } else if (clazz.equals(Character.TYPE) ) {
+ }
+ else if (clazz.equals(Character.TYPE) ) {
return Type.CHAR;
- } else if (clazz.equals(Double.TYPE) ) {
+ }
+ else if (clazz.equals(Double.TYPE) ) {
return Type.DOUBLE;
- } else if (clazz.equals(Float.TYPE) ) {
+ }
+ else if (clazz.equals(Float.TYPE) ) {
return Type.FLOAT;
- } else if (clazz.equals(Integer.TYPE) ) {
+ }
+ else if (clazz.equals(Integer.TYPE) ) {
return Type.INT;
- } else if (clazz.equals(Long.TYPE) ) {
+ }
+ else if (clazz.equals(Long.TYPE) ) {
return Type.LONG;
- } else if (clazz.equals(Short.TYPE) ) {
+ }
+ else if (clazz.equals(Short.TYPE) ) {
return Type.SHORT;
- } else if (clazz.equals(Void.TYPE) ) {
+ }
+ else if (clazz.equals(Void.TYPE) ) {
return Type.VOID;
}
- } else {
- String name = clazz.getName();
- if (clazz.isArray() ) {
- return Type.getType(name);
- } else {
- return new ObjectType(name);
- }
- }
+
+ // should never get here
+ throw new UnreachableStatementException();
+ }
+
+ // if we get this far it is not a primitive
+ String name = clazz.getName();
+
+ if (clazz.isArray()) {
+ return Type.getType(name);
+ }
- return Type.VOID;
+ return new ObjectType(name);
}
-
/**
* Get the <code>org.apache.bcel.generic.Type</code> for an array of Classes
*
- * @param classes a <code>Class[]</code> value
- * @return a <code>Type[]</code> value
+ * @param classes a <code>Class[]</code> value
+ * @return a <code>Type[]</code> value
*/
public static Type[] getTypes(Class[] classes) {
Type[] types = new Type[classes.length];
- for ( int i = 0; i < classes.length; i++ ) {
+
+ for (int i = 0; i < classes.length; i++) {
types[i] = getType(classes[i]);
}
+
return types;
}
-
/**
* Get the Object equivalent Class name for a primitive
*
@@ -113,29 +128,39 @@
*
* </pre>
*
- * @param t a <code>BasicType</code> value
- * @return a <code>String</code> value
+ * @param t a <code>BasicType</code> value
+ * @return a <code>String</code> value
+ *
+ * @throws IllegalArgumentException Unexpected type
*/
public static String getObjectEquivalentClassName(BasicType t) {
- switch(t.getType()) {
+ switch (t.getType()) {
case Constants.T_INT:
return "java.lang.Integer";
+
case Constants.T_SHORT:
return "java.lang.Short";
+
case Constants.T_BOOLEAN:
return "java.lang.Boolean";
+
case Constants.T_CHAR:
return "java.lang.Character";
+
case Constants.T_BYTE:
return "java.lang.Byte";
+
case Constants.T_FLOAT:
return "java.lang.Float";
+
case Constants.T_DOUBLE:
return "java.lang.Double";
+
case Constants.T_LONG:
return "java.lang.Long";
+
default:
- throw new RuntimeException("Unexpected Type: " + t);
+ throw new IllegalArgumentException("Unexpected Type: " + t);
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development