FileDocCategorySizeDatePackage
ThrowableData.javaAPI DocAndroid 1.5 API4199Wed May 06 22:41:56 BST 2009android.server.data

ThrowableData

public class ThrowableData extends Object
Throwable data transfer object. Keep in sync. with the server side version.

Fields Summary
final String
message
final String
type
final StackTraceElementData[]
stackTrace
final ThrowableData
cause
Constructors Summary
public ThrowableData(Throwable throwable)

        this.type = throwable.getClass().getName();
        String message = throwable.getMessage();
        this.message = message == null ? "" : message;

        StackTraceElement[] elements = throwable.getStackTrace();
        this.stackTrace = new StackTraceElementData[elements.length];
        for (int i = 0; i < elements.length; i++) {
            this.stackTrace[i] = new StackTraceElementData(elements[i]);
        }

        Throwable cause = throwable.getCause();
        this.cause = cause == null ? null : new ThrowableData(cause);
    
public ThrowableData(DataInput in)

        int dataVersion = in.readInt();
        if (dataVersion != 0) {
            throw new IOException("Expected 0. Got: " + dataVersion);
        }

        this.message = in.readUTF();
        this.type = in.readUTF();

        int count = in.readInt();
        this.stackTrace = new StackTraceElementData[count];
        for (int i = 0; i < count; i++) {
            this.stackTrace[i] = new StackTraceElementData(in);
        }

        this.cause = in.readBoolean() ? new ThrowableData(in) : null;
    
Methods Summary
private static voidappend(java.lang.String prefix, java.lang.StringBuilder builder, android.server.data.ThrowableData throwableData)

        if (prefix != null) builder.append(prefix);
        builder.append(throwableData.getType())
                .append(": ")
                .append(throwableData.getMessage())
                .append('\n");
        for (StackTraceElementData element : throwableData.getStackTrace()) {
            if (prefix != null ) builder.append(prefix);
            builder.append("  at ")
                    .append(element.getClassName())
                    .append('.")
                    .append(element.getMethodName())
                    .append("(")
                    .append(element.getFileName())
                    .append(':")
                    .append(element.getLineNumber())
                    .append(")\n");

        }

        ThrowableData cause = throwableData.getCause();
        if (cause != null) {
            if (prefix != null ) builder.append(prefix);
            builder.append("Caused by: ");
            append(prefix, builder, cause);
        }
    
public android.server.data.ThrowableDatagetCause()

        return cause;
    
public java.lang.StringgetMessage()

        return message;
    
public StackTraceElementData[]getStackTrace()

        return stackTrace;
    
public java.lang.StringgetType()

        return type;
    
public java.lang.StringtoString()

        return toString(null);
    
public java.lang.StringtoString(java.lang.String prefix)

        StringBuilder builder = new StringBuilder();
        append(prefix, builder, this);
        return builder.toString();
    
public voidwrite(java.io.DataOutput out)

        out.writeInt(0); // version

        out.writeUTF(message);
        out.writeUTF(type);

        out.writeInt(stackTrace.length);
        for (StackTraceElementData elementData : stackTrace) {
            elementData.write(out);
        }

        out.writeBoolean(cause != null);
        if (cause != null) {
            cause.write(out);
        }