FileDocCategorySizeDatePackage
RootCursorWrapper.javaAPI DocAndroid 5.1 API3714Thu Mar 12 22:22:40 GMT 2015com.android.documentsui

RootCursorWrapper

public class RootCursorWrapper extends android.database.AbstractCursor
Cursor wrapper that adds columns to identify which root a document came from.

Fields Summary
private final String
mAuthority
private final String
mRootId
private final android.database.Cursor
mCursor
private final int
mCount
private final String[]
mColumnNames
private final int
mAuthorityIndex
private final int
mRootIdIndex
public static final String
COLUMN_AUTHORITY
public static final String
COLUMN_ROOT_ID
Constructors Summary
public RootCursorWrapper(String authority, String rootId, android.database.Cursor cursor, int maxCount)


             
        mAuthority = authority;
        mRootId = rootId;
        mCursor = cursor;

        final int count = cursor.getCount();
        if (maxCount > 0 && count > maxCount) {
            mCount = maxCount;
        } else {
            mCount = count;
        }

        if (cursor.getColumnIndex(COLUMN_AUTHORITY) != -1
                || cursor.getColumnIndex(COLUMN_ROOT_ID) != -1) {
            throw new IllegalArgumentException("Cursor contains internal columns!");
        }
        final String[] before = cursor.getColumnNames();
        mColumnNames = new String[before.length + 2];
        System.arraycopy(before, 0, mColumnNames, 0, before.length);
        mAuthorityIndex = before.length;
        mRootIdIndex = before.length + 1;
        mColumnNames[mAuthorityIndex] = COLUMN_AUTHORITY;
        mColumnNames[mRootIdIndex] = COLUMN_ROOT_ID;
    
Methods Summary
public voidclose()

        super.close();
        mCursor.close();
    
public java.lang.String[]getColumnNames()

        return mColumnNames;
    
public intgetCount()

        return mCount;
    
public doublegetDouble(int column)

        return mCursor.getDouble(column);
    
public android.os.BundlegetExtras()

        return mCursor.getExtras();
    
public floatgetFloat(int column)

        return mCursor.getFloat(column);
    
public intgetInt(int column)

        return mCursor.getInt(column);
    
public longgetLong(int column)

        return mCursor.getLong(column);
    
public shortgetShort(int column)

        return mCursor.getShort(column);
    
public java.lang.StringgetString(int column)

        if (column == mAuthorityIndex) {
            return mAuthority;
        } else if (column == mRootIdIndex) {
            return mRootId;
        } else {
            return mCursor.getString(column);
        }
    
public intgetType(int column)

        return mCursor.getType(column);
    
public booleanisNull(int column)

        return mCursor.isNull(column);
    
public booleanonMove(int oldPosition, int newPosition)

        return mCursor.moveToPosition(newPosition);