public abstract class AbstractOnDemandInputStream<T extends java.io.OutputStream>
extends java.io.InputStream
Modifier and Type | Field and Description |
---|---|
private static int |
BUFFER_LENGTH
Number of bytes kept in buffer.
|
private java.io.ByteArrayOutputStream |
bufferedOutputStream
Base for outputStream.
|
private java.io.ByteArrayInputStream |
bufferInputStream
Stream to the buffer.
|
private java.io.InputStream |
currentNodeStream
Stream of currently processed Node.
|
private ArchivePath |
currentPath
Currently processed archive path - for displaying exception.
|
private java.util.Iterator<Node> |
nodesIterator
Iterator over nodes contained in base archive.
|
protected T |
outputStream
Created by abstract method.
|
private boolean |
outputStreamClosed
If output stream was closed - we should finish.
|
Constructor and Description |
---|
AbstractOnDemandInputStream(Archive<?> archive)
Creates stream directly from archive.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
closeEntry(T outputStream)
Closes the current entry context for the specified
OutputStream . |
protected abstract T |
createOutputStream(java.io.OutputStream outputStream)
Creates the real
OutputStream to which we'll write, wrapping the provided target. |
private void |
doCopy()
Performs copy operation between currentNodeStream and outputStream using buffer length.
|
private void |
endAsset()
Close entry in stream.
|
protected abstract void |
putNextEntry(T outputStream,
java.lang.String context)
Writes the next entry (demarcates a new file/folder is to be written).
|
int |
read() |
private void |
startAsset(java.lang.String path)
Start entry in stream.
|
private static final int BUFFER_LENGTH
private final java.util.Iterator<Node> nodesIterator
protected T extends java.io.OutputStream outputStream
private final java.io.ByteArrayOutputStream bufferedOutputStream
private java.io.InputStream currentNodeStream
private java.io.ByteArrayInputStream bufferInputStream
private boolean outputStreamClosed
private ArchivePath currentPath
public AbstractOnDemandInputStream(Archive<?> archive)
archive
- public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
private void doCopy() throws java.io.IOException
java.io.IOException
private void startAsset(java.lang.String path) throws java.io.IOException
path
- java.io.IOException
private void endAsset() throws java.io.IOException
java.io.IOException
protected abstract T createOutputStream(java.io.OutputStream outputStream) throws java.io.IOException
OutputStream
to which we'll write, wrapping the provided target.outputStream
- java.io.IOException
- If an error occurred in creating the streamprotected abstract void putNextEntry(T outputStream, java.lang.String context) throws java.io.IOException
outputStream
- context
- java.io.IOException
- If an error occurred writing the entryprotected abstract void closeEntry(T outputStream) throws java.io.IOException
OutputStream
.outputStream
- java.io.IOException