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

DocumentStack

public class DocumentStack extends LinkedList implements Durable
Representation of a stack of {@link DocumentInfo}, usually the result of a user-driven traversal.

Fields Summary
private static final int
VERSION_INIT
private static final int
VERSION_ADD_ROOT
public RootInfo
root
Constructors Summary
Methods Summary
public java.lang.StringbuildKey()
Build key that uniquely identifies this stack. It omits most of the raw details included in {@link #write(DataOutputStream)}, since they change too regularly to be used as a key.

        final StringBuilder builder = new StringBuilder();
        if (root != null) {
            builder.append(root.authority).append('#");
            builder.append(root.rootId).append('#");
        } else {
            builder.append("[null]").append('#");
        }
        for (DocumentInfo doc : this) {
            builder.append(doc.documentId).append('#");
        }
        return builder.toString();
    
public java.lang.StringgetTitle()


       
        if (size() == 1 && root != null) {
            return root.title;
        } else if (size() > 1) {
            return peek().displayName;
        } else {
            return null;
        }
    
public booleanisRecents()

        return size() == 0;
    
public voidread(java.io.DataInputStream in)

        final int version = in.readInt();
        switch (version) {
            case VERSION_INIT:
                throw new ProtocolException("Ignored upgrade");
            case VERSION_ADD_ROOT:
                if (in.readBoolean()) {
                    root = new RootInfo();
                    root.read(in);
                }
                final int size = in.readInt();
                for (int i = 0; i < size; i++) {
                    final DocumentInfo doc = new DocumentInfo();
                    doc.read(in);
                    add(doc);
                }
                break;
            default:
                throw new ProtocolException("Unknown version " + version);
        }
    
public voidreset()

        clear();
        root = null;
    
public voidupdateDocuments(android.content.ContentResolver resolver)
Update a possibly stale restored stack against a live {@link DocumentsProvider}.

        for (DocumentInfo info : this) {
            info.updateSelf(resolver);
        }
    
public voidupdateRoot(java.util.Collection matchingRoots)

        for (RootInfo root : matchingRoots) {
            if (root.equals(this.root)) {
                this.root = root;
                return;
            }
        }
        throw new FileNotFoundException("Failed to find matching root for " + root);
    
public voidwrite(java.io.DataOutputStream out)

        out.writeInt(VERSION_ADD_ROOT);
        if (root != null) {
            out.writeBoolean(true);
            root.write(out);
        } else {
            out.writeBoolean(false);
        }
        final int size = size();
        out.writeInt(size);
        for (int i = 0; i < size; i++) {
            final DocumentInfo doc = get(i);
            doc.write(out);
        }