[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A little patch for toString() of Constructor and Method
From: |
Wu, Gansha |
Subject: |
A little patch for toString() of Constructor and Method |
Date: |
Tue, 31 Jul 2001 11:18:54 +0800 |
Constructor.java:
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append(Modifier.toString(getModifiers()));
sb.append(' ');
sb.append(getDeclaringClass().getName());
sb.append('(');
Class[] c = getParameterTypes();
if(c.length > 0) {
sb.append(c[0].getName());
for(int i = 1; i < c.length; i++) {
sb.append(',');
sb.append(c[i].getName());
}
}
+ sb.append(')');
+ c = getExceptionTypes();
+ if(c.length > 0) {
+ sb.append(" throws ");
+ sb.append(c[0].getName());
+ for(int i = 1; i < c.length; i++) {
+ sb.append(", ");
+ sb.append(c[i].getName());
+ }
+ }
return sb.toString();
}
Method.java:
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append(Modifier.toString(getModifiers()));
sb.append(' ');
sb.append(getReturnType());
sb.append(' ');
sb.append(getDeclaringClass().getName());
sb.append('.');
sb.append(getName());
sb.append('(');
Class[] c = getParameterTypes();
if(c.length > 0) {
sb.append(c[0].getName());
for(int i = 1; i < c.length; i++) {
sb.append(',');
sb.append(c[i].getName());
}
}
sb.append(')');
+ c = getExceptionTypes();
+ if(c.length > 0) {
+ sb.append(" throws ");
+ sb.append(c[0].getName());
+ for(int i = 1; i < c.length; i++) {
+ sb.append(", ");
+ sb.append(c[i].getName());
+ }
+ }
return sb.toString();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- A little patch for toString() of Constructor and Method,
Wu, Gansha <=