aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2004-08-03 03:02:37 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2004-08-03 03:02:37 +0000
commit2a6f1c826d9110fdebe20687aac9ecb63024ab59 (patch)
tree87fe4f933e269f78034c81c76096bf5adc8cea66 /src/main
parent3b946e08d56d6f0327ef5d501f9f2c5363e0f544 (diff)
downloadjavassist-2a6f1c826d9110fdebe20687aac9ecb63024ab59.tar.gz
javassist-2a6f1c826d9110fdebe20687aac9ecb63024ab59.zip
modified CtClass#toString()
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@121 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main')
-rw-r--r--src/main/javassist/CtArray.java5
-rw-r--r--src/main/javassist/CtClass.java7
-rw-r--r--src/main/javassist/CtClassType.java34
-rw-r--r--src/main/javassist/CtNewClass.java2
-rw-r--r--src/main/javassist/CtPrimitiveType.java2
5 files changed, 36 insertions, 14 deletions
diff --git a/src/main/javassist/CtArray.java b/src/main/javassist/CtArray.java
index baf010a2..df7b84e6 100644
--- a/src/main/javassist/CtArray.java
+++ b/src/main/javassist/CtArray.java
@@ -27,11 +27,6 @@ final class CtArray extends CtClass {
pool = cp;
}
- protected void extendToString(StringBuffer buffer) {
- buffer.append(" pool=");
- buffer.append(pool);
- }
-
public ClassPool getClassPool() {
return pool;
}
diff --git a/src/main/javassist/CtClass.java b/src/main/javassist/CtClass.java
index 0ef8491d..f4464c14 100644
--- a/src/main/javassist/CtClass.java
+++ b/src/main/javassist/CtClass.java
@@ -168,9 +168,6 @@ public abstract class CtClass {
buf.append("@");
buf.append(Integer.toHexString(hashCode()));
buf.append("[");
- buf.append(Modifier.toString(getModifiers()));
- buf.append(' ');
- buf.append(getName());
extendToString(buf);
buf.append("]");
return buf.toString();
@@ -180,7 +177,9 @@ public abstract class CtClass {
* Implemented in subclasses to add to the {@link #toString()} result.
* Subclasses should put a space before each token added to the buffer.
*/
- abstract protected void extendToString(StringBuffer buffer);
+ protected void extendToString(StringBuffer buffer) {
+ buffer.append(getName());
+ }
/**
* Returns a <code>ClassPool</code> for this class.
diff --git a/src/main/javassist/CtClassType.java b/src/main/javassist/CtClassType.java
index 2949bcba..5ca4b69f 100644
--- a/src/main/javassist/CtClassType.java
+++ b/src/main/javassist/CtClassType.java
@@ -71,10 +71,40 @@ class CtClassType extends CtClass {
protected void extendToString(StringBuffer buffer) {
if (wasChanged)
- buffer.append(" changed");
+ buffer.append("changed ");
if (wasFrozen)
- buffer.append(" frozen");
+ buffer.append("frozen ");
+
+ buffer.append(Modifier.toString(getModifiers()));
+ buffer.append(" class ");
+ buffer.append(getName());
+
+ try {
+ CtClass ext = getSuperclass();
+ if (ext != null) {
+ String name =ext.getName();
+ if (!name.equals("java.lang.Object"))
+ buffer.append(" extends " + ext.getName());
+ }
+ }
+ catch (NotFoundException e) {
+ buffer.append(" extends ??");
+ }
+
+ try {
+ CtClass[] intf = getInterfaces();
+ if (intf.length > 0)
+ buffer.append(" implements ");
+
+ for (int i = 0; i < intf.length; ++i) {
+ buffer.append(intf[i].getName());
+ buffer.append(", ");
+ }
+ }
+ catch (NotFoundException e) {
+ buffer.append(" extends ??");
+ }
CtField field = getFieldsCache();
buffer.append(" fields=");
diff --git a/src/main/javassist/CtNewClass.java b/src/main/javassist/CtNewClass.java
index c0acc9d5..bfc513b8 100644
--- a/src/main/javassist/CtNewClass.java
+++ b/src/main/javassist/CtNewClass.java
@@ -43,7 +43,7 @@ class CtNewClass extends CtClassType {
protected void extendToString(StringBuffer buffer) {
if (hasConstructor)
- buffer.append(" hasConstructor");
+ buffer.append("hasConstructor ");
super.extendToString(buffer);
}
diff --git a/src/main/javassist/CtPrimitiveType.java b/src/main/javassist/CtPrimitiveType.java
index ee2ee56c..14fe57b8 100644
--- a/src/main/javassist/CtPrimitiveType.java
+++ b/src/main/javassist/CtPrimitiveType.java
@@ -41,8 +41,6 @@ public final class CtPrimitiveType extends CtClass {
dataSize = size;
}
- protected void extendToString(StringBuffer buffer) {}
-
/**
* Returns <code>true</code> if this object represents a primitive
* Java type: boolean, byte, char, short, int, long, float, double,