/** * Creates a read only {@code CompoundDocument}. * * @param pInput the input to read from. * * @throws IOException if an I/O exception occurs while reading the header */ public CompoundDocument(final InputStream pInput) throws IOException { this(new MemoryCacheSeekableStream(pInput)); }
protected SeekableInputStream makeInputStream(final InputStream pStream) { return new MemoryCacheSeekableStream(pStream); } }
@Override protected CompoundDocument.SeekableLittleEndianDataInputStream makeInputStream(byte[] pBytes) { return new CompoundDocument.SeekableLittleEndianDataInputStream(new MemoryCacheSeekableStream(new ByteArrayInputStream(pBytes))); }
SeekableInputStream getInputStreamForSId(final int pStreamId, final int pStreamSize) throws IOException { SIdChain chain = getSIdChain(pStreamId, pStreamSize); // TODO: Detach? Means, we have to copy to a byte buffer, or keep track of // positions, and seek back and forth (would be cool, but difficult).. int sectorSize = pStreamSize < minStreamSize ? shortSectorSize : this.sectorSize; return new MemoryCacheSeekableStream(new Stream(chain, pStreamSize, sectorSize, this)); }
@Test public void testReadCatalogSeekableStream() throws IOException { InputStream input = getClass().getResourceAsStream(SAMPLE_DATA); assertNotNull("Missing test resource!", input); CompoundDocument document = new CompoundDocument(new MemoryCacheSeekableStream(input)); Entry root = document.getRootEntry(); assertNotNull(root); assertEquals(25, root.getChildEntries().size()); Entry catalog = root.getChildEntry("Catalog"); assertNotNull(catalog); assertNotNull("Input stream may not be null", catalog.getInputStream()); }
protected SeekableInputStream makeInputStream(final InputStream pStream) { return new MemoryCacheSeekableStream(pStream); } }
protected SeekableInputStream makeInputStream(final InputStream pStream) { return new MemoryCacheSeekableStream(pStream); } }
@Override protected CompoundDocument.SeekableLittleEndianDataInputStream makeInputStream(byte[] pBytes) { return new CompoundDocument.SeekableLittleEndianDataInputStream(new MemoryCacheSeekableStream(new ByteArrayInputStream(pBytes))); }
CompoundDocument document = new CompoundDocument(new MemoryCacheSeekableStream(input));
SeekableInputStream getInputStreamForSId(final int pStreamId, final int pStreamSize) throws IOException { SIdChain chain = getSIdChain(pStreamId, pStreamSize); // TODO: Detach? Means, we have to copy to a byte buffer, or keep track of // positions, and seek back and forth (would be cool, but difficult).. int sectorSize = pStreamSize < minStreamSize ? shortSectorSize : this.sectorSize; return new MemoryCacheSeekableStream(new Stream(chain, pStreamSize, sectorSize, this)); }
@Test public void testReadCatalogSeekableStream() throws IOException { InputStream input = getClass().getResourceAsStream(SAMPLE_DATA); assertNotNull("Missing test resource!", input); CompoundDocument document = new CompoundDocument(new MemoryCacheSeekableStream(input)); Entry root = document.getRootEntry(); assertNotNull(root); assertEquals(25, root.getChildEntries().size()); Entry catalog = root.getChildEntry("Catalog"); assertNotNull(catalog); assertNotNull("Input stream may not be null", catalog.getInputStream()); }
CompoundDocument document = new CompoundDocument(new MemoryCacheSeekableStream(input));