@Override public String toString() { return "\"" + name + "\"" + " (" + (isFile() ? "Document" : (isDirectory() ? "Directory" : "Root")) + (parent != null ? ", parent: \"" + parent.getName() + "\"" : "") + (isFile() ? "" : ", children: " + (children != null ? String.valueOf(children.size()) : "(unknown)")) + ", SId=" + startSId + ", length=" + streamSize + ")"; }
/** * Returns the length of this entry * * @return the length of the stream for this entry, or {@code 0} if this is * a directory {@code Entry} * @see #getInputStream() */ public long length() { if (isDirectory()) { return 0L; } return streamSize; }
/** * Returns the {@code InputStream} for this {@code Entry} * * @return an {@code InputStream} containing the data for this * {@code Entry} or {@code null} if this is a directory {@code Entry} * @throws java.io.IOException if an I/O exception occurs * @see #length() */ public SeekableInputStream getInputStream() throws IOException { if (isDirectory()) { return null; } return mDocument.getInputStreamForSId(startSId, streamSize); }
@Test public void testRoot() throws IOException { try (CompoundDocument document = createTestDocument()) { Entry root = document.getRootEntry(); assertNotNull(root); assertEquals("Root Entry", root.getName()); assertTrue(root.isRoot()); assertFalse(root.isFile()); assertFalse(root.isDirectory()); assertEquals(0, root.length()); assertNull(root.getInputStream()); } }
@Override public String toString() { return "\"" + name + "\"" + " (" + (isFile() ? "Document" : (isDirectory() ? "Directory" : "Root")) + (mParent != null ? ", parent: \"" + mParent.getName() + "\"" : "") + (isFile() ? "" : ", children: " + (mChildren != null ? String.valueOf(mChildren.size()) : "(unknown)")) + ", SId=" + startSId + ", length=" + streamSize + ")"; }
@Override public String toString() { return "\"" + name + "\"" + " (" + (isFile() ? "Document" : (isDirectory() ? "Directory" : "Root")) + (parent != null ? ", parent: \"" + parent.getName() + "\"" : "") + (isFile() ? "" : ", children: " + (children != null ? String.valueOf(children.size()) : "(unknown)")) + ", SId=" + startSId + ", length=" + streamSize + ")"; }
@Test public void testRoot() throws IOException { CompoundDocument document = createTestDocument(); Entry root = document.getRootEntry(); assertNotNull(root); assertEquals("Root Entry", root.getName()); assertTrue(root.isRoot()); assertFalse(root.isFile()); assertFalse(root.isDirectory()); assertEquals(0, root.length()); assertNull(root.getInputStream()); }