FileDocCategorySizeDatePackage
ArchivePathElement.javaAPI DocAndroid 5.1 API3069Thu Mar 12 22:18:30 GMT 2015com.android.multidex

ArchivePathElement

public class ArchivePathElement extends Object implements ClassPathElement
A zip element.

Fields Summary
private final ZipFile
archive
Constructors Summary
public ArchivePathElement(ZipFile archive)

        this.archive = archive;
    
Methods Summary
public voidclose()

        archive.close();
    
public java.lang.Iterablelist()

        return new Iterable<String>() {

            @Override
            public Iterator<String> iterator() {
                return new Iterator<String>() {
                    Enumeration<? extends ZipEntry> delegate = archive.entries();
                    ZipEntry next = null;

                    @Override
                    public boolean hasNext() {
                        while (next == null && delegate.hasMoreElements()) {
                            next = delegate.nextElement();
                            if (next.isDirectory()) {
                                next = null;
                            }
                        }
                        return next != null;
                    }

                    @Override
                    public String next() {
                        if (hasNext()) {
                            String name = next.getName();
                            next = null;
                            return name;
                        } else {
                            throw new NoSuchElementException();
                        }
                    }

                    @Override
                    public void remove() {
                        throw new UnsupportedOperationException();
                    }
                };
            }
        };
    
public java.io.InputStreamopen(java.lang.String path)

        ZipEntry entry = archive.getEntry(path);
        if (entry == null) {
            throw new FileNotFoundException("File \"" + path + "\" not found");
        } else if (entry.isDirectory()) {
            throw new DirectoryEntryException();
        } else {
            return archive.getInputStream(entry);
        }