FileDocCategorySizeDatePackage
DocumentInfo.javaAPI DocAndroid 5.1 API10195Thu Mar 12 22:22:40 GMT 2015com.android.documentsui.model

DocumentInfo

public class DocumentInfo extends Object implements Durable, android.os.Parcelable
Representation of a {@link Document}.

Fields Summary
private static final int
VERSION_INIT
private static final int
VERSION_SPLIT_URI
private static final Collator
sCollator
public String
authority
public String
documentId
public String
mimeType
public String
displayName
public long
lastModified
public int
flags
public String
summary
public long
size
public int
icon
public android.net.Uri
derivedUri
Derived fields that aren't persisted
public static final Creator
CREATOR
public static final char
DIR_PREFIX
String prefix used to indicate the document is a directory.
Constructors Summary
public DocumentInfo()

        reset();
    
Methods Summary
public static java.io.FileNotFoundExceptionasFileNotFoundException(java.lang.Throwable t)

        if (t instanceof FileNotFoundException) {
            throw (FileNotFoundException) t;
        }
        final FileNotFoundException fnfe = new FileNotFoundException(t.getMessage());
        fnfe.initCause(t);
        throw fnfe;
    
public static intcompareToIgnoreCaseNullable(java.lang.String lhs, java.lang.String rhs)
Compare two strings against each other using system default collator in a case-insensitive mode. Clusters strings prefixed with {@link #DIR_PREFIX} before other items.


                                
           
        final boolean leftEmpty = TextUtils.isEmpty(lhs);
        final boolean rightEmpty = TextUtils.isEmpty(rhs);

        if (leftEmpty && rightEmpty) return 0;
        if (leftEmpty) return -1;
        if (rightEmpty) return 1;

        final boolean leftDir = (lhs.charAt(0) == DIR_PREFIX);
        final boolean rightDir = (rhs.charAt(0) == DIR_PREFIX);

        if (leftDir && !rightDir) return -1;
        if (rightDir && !leftDir) return 1;

        return sCollator.compare(lhs, rhs);
    
private voidderiveFields()

        derivedUri = DocumentsContract.buildDocumentUri(authority, documentId);
    
public intdescribeContents()

        return 0;
    
public static com.android.documentsui.model.DocumentInfofromCursor(android.database.Cursor cursor, java.lang.String authority)

        final DocumentInfo info = new DocumentInfo();
        info.updateFromCursor(cursor, authority);
        return info;
    
public static com.android.documentsui.model.DocumentInfofromDirectoryCursor(android.database.Cursor cursor)


         
        final String authority = getCursorString(cursor, RootCursorWrapper.COLUMN_AUTHORITY);
        return fromCursor(cursor, authority);
    
public static com.android.documentsui.model.DocumentInfofromUri(android.content.ContentResolver resolver, android.net.Uri uri)

        final DocumentInfo info = new DocumentInfo();
        info.updateFromUri(resolver, uri);
        return info;
    
public static intgetCursorInt(android.database.Cursor cursor, java.lang.String columnName)
Missing or null values are returned as 0.

        final int index = cursor.getColumnIndex(columnName);
        return (index != -1) ? cursor.getInt(index) : 0;
    
public static longgetCursorLong(android.database.Cursor cursor, java.lang.String columnName)
Missing or null values are returned as -1.

        final int index = cursor.getColumnIndex(columnName);
        if (index == -1) return -1;
        final String value = cursor.getString(index);
        if (value == null) return -1;
        try {
            return Long.parseLong(value);
        } catch (NumberFormatException e) {
            return -1;
        }
    
public static java.lang.StringgetCursorString(android.database.Cursor cursor, java.lang.String columnName)

        final int index = cursor.getColumnIndex(columnName);
        return (index != -1) ? cursor.getString(index) : null;
    
public booleanisCreateSupported()

        return (flags & Document.FLAG_DIR_SUPPORTS_CREATE) != 0;
    
public booleanisDeleteSupported()

        return (flags & Document.FLAG_SUPPORTS_DELETE) != 0;
    
public booleanisDirectory()

        return Document.MIME_TYPE_DIR.equals(mimeType);
    
public booleanisGridPreferred()

        return (flags & Document.FLAG_DIR_PREFERS_GRID) != 0;
    
public booleanisGridTitlesHidden()

        return (flags & Document.FLAG_DIR_HIDE_GRID_TITLES) != 0;
    
public booleanisThumbnailSupported()

        return (flags & Document.FLAG_SUPPORTS_THUMBNAIL) != 0;
    
public voidread(java.io.DataInputStream in)

        final int version = in.readInt();
        switch (version) {
            case VERSION_INIT:
                throw new ProtocolException("Ignored upgrade");
            case VERSION_SPLIT_URI:
                authority = DurableUtils.readNullableString(in);
                documentId = DurableUtils.readNullableString(in);
                mimeType = DurableUtils.readNullableString(in);
                displayName = DurableUtils.readNullableString(in);
                lastModified = in.readLong();
                flags = in.readInt();
                summary = DurableUtils.readNullableString(in);
                size = in.readLong();
                icon = in.readInt();
                deriveFields();
                break;
            default:
                throw new ProtocolException("Unknown version " + version);
        }
    
public voidreset()

        authority = null;
        documentId = null;
        mimeType = null;
        displayName = null;
        lastModified = -1;
        flags = 0;
        summary = null;
        size = -1;
        icon = 0;

        derivedUri = null;
    
public java.lang.StringtoString()

        return "Document{docId=" + documentId + ", name=" + displayName + "}";
    
public voidupdateFromCursor(android.database.Cursor cursor, java.lang.String authority)

        this.authority = authority;
        this.documentId = getCursorString(cursor, Document.COLUMN_DOCUMENT_ID);
        this.mimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
        this.documentId = getCursorString(cursor, Document.COLUMN_DOCUMENT_ID);
        this.mimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
        this.displayName = getCursorString(cursor, Document.COLUMN_DISPLAY_NAME);
        this.lastModified = getCursorLong(cursor, Document.COLUMN_LAST_MODIFIED);
        this.flags = getCursorInt(cursor, Document.COLUMN_FLAGS);
        this.summary = getCursorString(cursor, Document.COLUMN_SUMMARY);
        this.size = getCursorLong(cursor, Document.COLUMN_SIZE);
        this.icon = getCursorInt(cursor, Document.COLUMN_ICON);
        this.deriveFields();
    
public voidupdateFromUri(android.content.ContentResolver resolver, android.net.Uri uri)

        ContentProviderClient client = null;
        Cursor cursor = null;
        try {
            client = DocumentsApplication.acquireUnstableProviderOrThrow(
                    resolver, uri.getAuthority());
            cursor = client.query(uri, null, null, null, null);
            if (!cursor.moveToFirst()) {
                throw new FileNotFoundException("Missing details for " + uri);
            }
            updateFromCursor(cursor, uri.getAuthority());
        } catch (Throwable t) {
            throw asFileNotFoundException(t);
        } finally {
            IoUtils.closeQuietly(cursor);
            ContentProviderClient.releaseQuietly(client);
        }
    
public voidupdateSelf(android.content.ContentResolver resolver)
Update a possibly stale restored document against a live {@link DocumentsProvider}.

        updateFromUri(resolver, derivedUri);
    
public voidwrite(java.io.DataOutputStream out)

        out.writeInt(VERSION_SPLIT_URI);
        DurableUtils.writeNullableString(out, authority);
        DurableUtils.writeNullableString(out, documentId);
        DurableUtils.writeNullableString(out, mimeType);
        DurableUtils.writeNullableString(out, displayName);
        out.writeLong(lastModified);
        out.writeInt(flags);
        DurableUtils.writeNullableString(out, summary);
        out.writeLong(size);
        out.writeInt(icon);
    
public voidwriteToParcel(android.os.Parcel dest, int flags)

        DurableUtils.writeToParcel(dest, this);