FileDocCategorySizeDatePackage
CatchHandlerList.javaAPI DocAndroid 1.5 API6656Wed May 06 22:41:02 BST 2009com.android.dx.dex.code

CatchHandlerList

public final class CatchHandlerList extends com.android.dx.util.FixedSizeList implements Comparable
Ordered list of (exception type, handler address) entries.

Fields Summary
public static final CatchHandlerList
EMPTY
non-null; empty instance
Constructors Summary
public CatchHandlerList(int size)
Constructs an instance. All indices initially contain null.

param
size >= 0; the size of the list


                          
       
        super(size);
    
Methods Summary
public booleancatchesAll()
Returns whether or not this instance ends with a "catch-all" handler.

return
true if this instance ends with a "catch-all" handler or false if not

        int size = size();

        if (size == 0) {
            return false;
        }

        Entry last = get(size - 1);
        return last.getExceptionType().equals(CstType.OBJECT);
    
public intcompareTo(com.android.dx.dex.code.CatchHandlerList other)
{@inheritDoc}

        if (this == other) {
            // Easy out.
            return 0;
        }

        int thisSize = size();
        int otherSize = other.size();
        int checkSize = Math.min(thisSize, otherSize);

        for (int i = 0; i < checkSize; i++) {
            Entry thisEntry = get(i);
            Entry otherEntry = other.get(i);
            int compare = thisEntry.compareTo(otherEntry);
            if (compare != 0) {
                return compare;
            }
        }

        if (thisSize < otherSize) {
            return -1;
        } else if (thisSize > otherSize) {
            return 1;
        }

        return 0;
    
public com.android.dx.dex.code.CatchHandlerList$Entryget(int n)
Gets the element at the given index. It is an error to call this with the index for an element which was never set; if you do that, this will throw NullPointerException.

param
n >= 0, < size(); which index
return
non-null; element at that index

        return (Entry) get0(n);
    
public voidset(int n, com.android.dx.rop.cst.CstType exceptionType, int handler)
Sets the entry at the given index.

param
n >= 0, < size(); which index
param
exceptionType non-null; type of exception handled
param
handler >= 0; exception handler address

        set0(n, new Entry(exceptionType, handler));
    
public voidset(int n, com.android.dx.dex.code.CatchHandlerList$Entry entry)
Sets the entry at the given index.

param
n >= 0, < size(); which index
param
entry non-null; the entry to set at n

        set0(n, entry);
    
public java.lang.StringtoHuman()
{@inheritDoc}

        return toHuman("", "");
    
public java.lang.StringtoHuman(java.lang.String prefix, java.lang.String header)
Get the human form of this instance, prefixed on each line with the string.

param
prefix non-null; the prefix for every line
param
header non-null; the header for the first line (after the first prefix)
return
non-null; the human form

        StringBuilder sb = new StringBuilder(100);
        int size = size();

        sb.append(prefix);
        sb.append(header);
        sb.append("catch ");

        for (int i = 0; i < size; i++) {
            Entry entry = get(i);

            if (i != 0) {
                sb.append(",\n");
                sb.append(prefix);
                sb.append("  ");
            }

            if ((i == (size - 1)) && catchesAll()) {
                sb.append("<any>");
            } else {
                sb.append(entry.getExceptionType().toHuman());
            }
            
            sb.append(" -> ");
            sb.append(Hex.u2or4(entry.getHandler()));
        }

        return sb.toString();