git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@40 30ef5769-5b8d-40dd-aea6-55b5d6557bb3tags/rel_3_17_1_ga
@@ -27,6 +27,11 @@ final class CtArray extends CtClass { | |||
pool = cp; | |||
} | |||
protected void extendToString(StringBuffer buffer) { | |||
buffer.append(" pool="); | |||
buffer.append(pool); | |||
} | |||
public ClassPool getClassPool() { | |||
return pool; | |||
} |
@@ -32,6 +32,13 @@ public abstract class CtBehavior extends CtMember { | |||
methodInfo = minfo; | |||
} | |||
protected void extendToString(StringBuffer buffer) { | |||
buffer.append(' '); | |||
buffer.append(getName()); | |||
buffer.append(' '); | |||
buffer.append(methodInfo.getDescriptor()); | |||
} | |||
/** | |||
* Returns the MethodInfo representing this member in the | |||
* class file. |
@@ -147,6 +147,28 @@ public abstract class CtClass { | |||
qualifiedName = name; | |||
} | |||
/** | |||
* Converts the object to a string. | |||
*/ | |||
public String toString() { | |||
StringBuffer buf = new StringBuffer(getClass().getName()); | |||
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(); | |||
} | |||
/** | |||
* 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); | |||
/** | |||
* Returns a <code>ClassPool</code> for this class. | |||
*/ |
@@ -65,6 +65,38 @@ class CtClassType extends CtClass { | |||
qualifiedName = classfile.getName(); | |||
} | |||
protected void extendToString(StringBuffer buffer) { | |||
if (wasChanged) | |||
buffer.append(" changed"); | |||
if (wasFrozen) | |||
buffer.append(" frozen"); | |||
CtField field = getFieldsCache(); | |||
buffer.append(" fields="); | |||
while (field != null) { | |||
buffer.append(field); | |||
buffer.append(", "); | |||
field = field.next; | |||
} | |||
CtConstructor c = getConstructorsCache(); | |||
buffer.append(" constructors="); | |||
while (c != null) { | |||
buffer.append(c); | |||
buffer.append(", "); | |||
c = c.next; | |||
} | |||
CtMethod m = getMethodsCache(); | |||
buffer.append(" methods="); | |||
while (m != null) { | |||
buffer.append(m); | |||
buffer.append(", "); | |||
m = m.next; | |||
} | |||
} | |||
protected void eraseCache() { | |||
fieldsCache = null; | |||
constructorsCache = null; |
@@ -98,6 +98,13 @@ public class CtField extends CtMember { | |||
next = null; | |||
} | |||
protected void extendToString(StringBuffer buffer) { | |||
buffer.append(' '); | |||
buffer.append(getName()); | |||
buffer.append(' '); | |||
buffer.append(fieldInfo.getDescriptor()); | |||
} | |||
/* Javac.CtFieldWithInit overrides. | |||
*/ | |||
protected ASTree getInitAST() { return null; } |
@@ -24,6 +24,26 @@ public abstract class CtMember { | |||
protected CtMember(CtClass clazz) { declaringClass = clazz; } | |||
public String toString() { | |||
StringBuffer buffer = new StringBuffer(getClass().getName()); | |||
buffer.append("@"); | |||
buffer.append(Integer.toHexString(hashCode())); | |||
buffer.append("["); | |||
buffer.append(Modifier.toString(getModifiers())); | |||
extendToString(buffer); | |||
buffer.append("]"); | |||
return buffer.toString(); | |||
} | |||
/** | |||
* Invoked by {@link #toString()} to add to the buffer and provide the | |||
* complete value. Subclasses should invoke this method, adding a | |||
* space before each token. The modifiers for the member are | |||
* provided first; subclasses should provide additional data such | |||
* as return type, field or method name, etc. | |||
*/ | |||
protected abstract void extendToString(StringBuffer buffer); | |||
/** | |||
* Returns the class that declares this member. | |||
*/ |
@@ -41,6 +41,13 @@ class CtNewClass extends CtClassType { | |||
hasConstructor = isInterface; | |||
} | |||
protected void extendToString(StringBuffer buffer) { | |||
if (hasConstructor) | |||
buffer.append(" hasConstructor"); | |||
super.extendToString(buffer); | |||
} | |||
public void addConstructor(CtConstructor c) | |||
throws CannotCompileException | |||
{ |
@@ -41,6 +41,8 @@ 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, |