FileDocCategorySizeDatePackage
CatchHandlerList.javaAPI DocAndroid 5.1 API6726Thu Mar 12 22:18:28 GMT 2015com.android.dexgen.dex.code

CatchHandlerList

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

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

param
size {@code >= 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
{@code true} if this instance ends with a "catch-all" handler or {@code 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.dexgen.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.dexgen.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 {@code NullPointerException}.

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

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

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

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

param
n {@code >= 0, < size();} which index
param
entry {@code non-null;} the entry to set at {@code 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 {@code non-null;} the prefix for every line
param
header {@code non-null;} the header for the first line (after the first prefix)
return
{@code 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();