FileDocCategorySizeDatePackage
StringRepresentation.javaAPI DocJava SE 5 API7430Fri Aug 26 14:55:26 BST 2005com.sun.org.apache.bcel.internal.verifier.statics

StringRepresentation

public class StringRepresentation extends EmptyVisitor implements Visitor
BCEL's Node classes (those from the classfile API that accept() Visitor instances) have toString() methods that were not designed to be robust, this gap is closed by this class. When performing class file verification, it may be useful to output which entity (e.g. a Code instance) is not satisfying the verifier's constraints, but in this case it could be possible for the toString() method to throw a RuntimeException. A (new StringRepresentation(Node n)).toString() never throws any exception. Note that this class also serves as a placeholder for more sophisticated message handling in future versions of JustIce.
version
$Id: StringRepresentation.java,v 1.1.1.1 2001/10/29 20:00:37 jvanzyl Exp $
author
Enver Haase

Fields Summary
private String
tostring
The string representation, created by a visitXXX() method, output by toString().
Constructors Summary
public StringRepresentation(Node n)
Creates a new StringRepresentation object which is the representation of n.

see
#toString()

		n.accept(this);
	
Methods Summary
public java.lang.StringtoString()
Returns the String representation.

		return tostring;
	
private java.lang.StringtoString(com.sun.org.apache.bcel.internal.classfile.Node obj)
Returns the String representation of the Node object obj; this is obj.toString() if it does not throw any RuntimeException, or else it is a string derived only from obj's class name.

		String ret;
		try{
			ret = obj.toString();
		}
		catch(RuntimeException e){
			String s = obj.getClass().getName();
			s = s.substring(s.lastIndexOf(".")+1);
			ret = "<<"+s+">>";
		}
		return ret;
	
public voidvisitCode(com.sun.org.apache.bcel.internal.classfile.Code obj)

		//tostring = toString(obj);
		tostring = "<CODE>"; // We don't need real code outputs.
	
public voidvisitCodeException(com.sun.org.apache.bcel.internal.classfile.CodeException obj)

		tostring = toString(obj);
	
public voidvisitConstantClass(com.sun.org.apache.bcel.internal.classfile.ConstantClass obj)

		tostring = toString(obj);
	
public voidvisitConstantDouble(com.sun.org.apache.bcel.internal.classfile.ConstantDouble obj)

		tostring = toString(obj);
	
public voidvisitConstantFieldref(com.sun.org.apache.bcel.internal.classfile.ConstantFieldref obj)

		tostring = toString(obj);
	
public voidvisitConstantFloat(com.sun.org.apache.bcel.internal.classfile.ConstantFloat obj)

		tostring = toString(obj);
	
public voidvisitConstantInteger(com.sun.org.apache.bcel.internal.classfile.ConstantInteger obj)

		tostring = toString(obj);
	
public voidvisitConstantInterfaceMethodref(com.sun.org.apache.bcel.internal.classfile.ConstantInterfaceMethodref obj)

		tostring = toString(obj);
	
public voidvisitConstantLong(com.sun.org.apache.bcel.internal.classfile.ConstantLong obj)

		tostring = toString(obj);
	
public voidvisitConstantMethodref(com.sun.org.apache.bcel.internal.classfile.ConstantMethodref obj)

		tostring = toString(obj);
	
public voidvisitConstantNameAndType(com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType obj)

		tostring = toString(obj);
	
public voidvisitConstantPool(com.sun.org.apache.bcel.internal.classfile.ConstantPool obj)

		tostring = toString(obj);
 	
public voidvisitConstantString(com.sun.org.apache.bcel.internal.classfile.ConstantString obj)

		tostring = toString(obj);
	
public voidvisitConstantUtf8(com.sun.org.apache.bcel.internal.classfile.ConstantUtf8 obj)

		tostring = toString(obj);
	
public voidvisitConstantValue(com.sun.org.apache.bcel.internal.classfile.ConstantValue obj)

		tostring = toString(obj);
	
public voidvisitDeprecated(com.sun.org.apache.bcel.internal.classfile.Deprecated obj)

		tostring = toString(obj);
	
public voidvisitExceptionTable(com.sun.org.apache.bcel.internal.classfile.ExceptionTable obj)

		tostring = toString(obj);
	
public voidvisitField(com.sun.org.apache.bcel.internal.classfile.Field obj)

		tostring = toString(obj);
	
public voidvisitInnerClass(com.sun.org.apache.bcel.internal.classfile.InnerClass obj)

		tostring = toString(obj);
	
public voidvisitInnerClasses(com.sun.org.apache.bcel.internal.classfile.InnerClasses obj)

		tostring = toString(obj);
	
public voidvisitJavaClass(com.sun.org.apache.bcel.internal.classfile.JavaClass obj)

		tostring = toString(obj);
	
public voidvisitLineNumber(com.sun.org.apache.bcel.internal.classfile.LineNumber obj)

		tostring = toString(obj);
	
public voidvisitLineNumberTable(com.sun.org.apache.bcel.internal.classfile.LineNumberTable obj)

		tostring = "<LineNumberTable: "+toString(obj)+">";
	
public voidvisitLocalVariable(com.sun.org.apache.bcel.internal.classfile.LocalVariable obj)

		tostring = toString(obj);
	
public voidvisitLocalVariableTable(com.sun.org.apache.bcel.internal.classfile.LocalVariableTable obj)

		tostring = "<LocalVariableTable: "+toString(obj)+">";
	
public voidvisitMethod(com.sun.org.apache.bcel.internal.classfile.Method obj)

		tostring = toString(obj);
	
public voidvisitSourceFile(com.sun.org.apache.bcel.internal.classfile.SourceFile obj)

		tostring = toString(obj);
	
public voidvisitSynthetic(com.sun.org.apache.bcel.internal.classfile.Synthetic obj)

		tostring = toString(obj);
	
public voidvisitUnknown(com.sun.org.apache.bcel.internal.classfile.Unknown obj)

		tostring = toString(obj);