From: chiba Date: Tue, 3 Aug 2004 03:02:37 +0000 (+0000) Subject: modified CtClass#toString() X-Git-Tag: rel_3_17_1_ga~492 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2a6f1c826d9110fdebe20687aac9ecb63024ab59;p=javassist.git modified CtClass#toString() git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@121 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- 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 ClassPool 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 true if this object represents a primitive * Java type: boolean, byte, char, short, int, long, float, double,