User: juha
Date: 00/10/18 06:23:16
Modified: src/main/org/jboss/verifier/event VerificationEvent.java
Log:
Added method arguments to messages.
Revision Changes Path
1.6 +68 -37 jboss/src/main/org/jboss/verifier/event/VerificationEvent.java
Index: VerificationEvent.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/verifier/event/VerificationEvent.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- VerificationEvent.java 2000/10/18 08:59:25 1.5
+++ VerificationEvent.java 2000/10/18 13:23:16 1.6
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* This package and its source code is available at www.jboss.org
- * $Id: VerificationEvent.java,v 1.5 2000/10/18 08:59:25 juha Exp $
+ * $Id: VerificationEvent.java,v 1.6 2000/10/18 13:23:16 juha Exp $
*/
@@ -36,7 +36,7 @@
/**
*
* @author Juha Lindfors ([EMAIL PROTECTED])
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
* @since JDK 1.3
*/
public class VerificationEvent extends EventObject {
@@ -138,49 +138,26 @@
public String getVerbose() {
- StringBuffer buf = new StringBuffer();
+ StringBuffer buf = new StringBuffer(512);
String linebreak = System.getProperty("line.separator");
buf.append(linebreak + "Class : " + beanName + linebreak);
if (method != null) {
- String returnClassName = method.getReturnType().getName();
- int len = returnClassName.length();
- int roffset = returnClassName.lastIndexOf(".");
-
- String returnType = "";
-
- if (roffset == -1)
- returnType = returnClassName;
- else
- returnType = returnClassName.substring(roffset+1, len);
-
- Class[] exceptions = method.getExceptionTypes();
- StringBuffer excbuf = new StringBuffer(100);
-
- for (int i = 0; i < exceptions.length; ++i) {
- String exceptionClassName = exceptions[i].getName();
- int elen = exceptionClassName.length();
- int eoffset = exceptionClassName.lastIndexOf(".");
-
- String exceptionType = "";
-
- if (eoffset == -1)
- exceptionType = exceptionClassName;
- else
- exceptionType = exceptionClassName.substring(eoffset+1, elen);
-
- excbuf.append(exceptionType)
- .append(", ");
- }
- if (excbuf.length() > 2)
- excbuf.delete(excbuf.length()-2, excbuf.length());
+ String returnType = getShortClassName(method.getReturnType());
+
+ Class[] arguments = method.getParameterTypes();
+ String arglist =
getCommaSeparatedList(getShortClassNames(arguments));
+
+ Class[] exceptions = method.getExceptionTypes();
+ String exclist =
getCommaSeparatedList(getShortClassNames(exceptions));
buf.append("Method : " + Modifier.toString(method.getModifiers()) + " "
+
returnType + " " +
- method.getName() + "()");
- if (excbuf.length() > 0)
- buf.append(" throws " + excbuf.toString());
+ method.getName() + "(" +
+ arglist + ")");
+ if (exclist.length() > 0)
+ buf.append(" throws " + exclist.toString());
buf.append(linebreak);
}
@@ -199,6 +176,60 @@
return beanName;
}
+/*
+ *************************************************************************
+ *
+ * PRIVATE INSTANCE METHODS
+ *
+ *************************************************************************
+ */
+
+ private String[] getShortClassNames(Class[] c) {
+ String[] names = new String[c.length];
+
+ for (int i = 0; i < c.length; ++i)
+ names[i] = getShortClassName(c[i]);
+
+ return names;
+ }
+
+ /*
+ * Returns class name without package path
+ */
+ private String getShortClassName(Class c) {
+
+ String className = c.getName();
+ int len = className.length();
+ int offset = className.lastIndexOf(".");
+
+ String name = "";
+
+ if (offset == -1)
+ name = className;
+ else
+ name = className.substring(offset+1, len);
+
+ return name;
+ }
+
+ /*
+ * builds a comma separated string list of objects
+ */
+ private String getCommaSeparatedList(Object[] list) {
+ if (list == null || list.length <= 0)
+ return "";
+
+ if (list.length == 1)
+ return list[0].toString();
+
+ StringBuffer buf = new StringBuffer(256);
+ buf.append(list[0]);
+
+ for (int i = 1; i < list.length; ++i)
+ buf.append(", ").append(list[i]);
+
+ return buf.toString();
+ }
/*
* String constants