Class AbstractOnDemandInputStream<T extends OutputStream>
java.lang.Object
java.io.InputStream
org.jboss.shrinkwrap.impl.base.exporter.AbstractOnDemandInputStream<T>
- All Implemented Interfaces:
Closeable, AutoCloseable
- Direct Known Subclasses:
TarBz2OnDemandInputStream, TarGzOnDemandInputStream, TarOnDemandInputStreamBase, ZipOnDemandInputStream
Base for on-demand input streams. Encodes data on the fly, when read method is executed.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intNumber of bytes kept in buffer.private final ByteArrayOutputStreamBase for outputStream.private ByteArrayInputStreamStream to the buffer.private InputStreamStream of currently processed Node.private ArchivePathCurrently processed archive path - for displaying exception.Iterator over nodes contained in base archive.protected TCreated by abstract method.private booleanIf output stream was closed - we should finish. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractOnDemandInputStream(Archive<?> archive) Creates stream directly from archive. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidcloseEntry(T outputStream) Closes the current entry context for the specifiedOutputStream.protected abstract TcreateOutputStream(OutputStream outputStream) Creates the realOutputStreamto which we'll write, wrapping the provided target.private voiddoCopy()Performs copy operation between currentNodeStream and outputStream using buffer length.private voidendAsset()Close entry in stream.protected abstract voidputNextEntry(T outputStream, String context) Writes the next entry (demarcates a new file/folder is to be written).intread()private voidstartAsset(String path) Start entry in stream.Methods inherited from class InputStream
available, close, mark, markSupported, read, read, reset, skip
-
Field Details
-
BUFFER_LENGTH
private static final int BUFFER_LENGTHNumber of bytes kept in buffer.- See Also:
-
nodesIterator
-
outputStream
Created by abstract method. -
bufferedOutputStream
Base for outputStream. -
currentNodeStream
Stream of currently processed Node. -
bufferInputStream
Stream to the buffer. -
outputStreamClosed
private boolean outputStreamClosedIf output stream was closed - we should finish. -
currentPath
Currently processed archive path - for displaying exception.
-
-
Constructor Details
-
AbstractOnDemandInputStream
Creates stream directly from archive.- Parameters:
archive-
-
-
Method Details
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
doCopy
Performs copy operation between currentNodeStream and outputStream using buffer length.- Throws:
IOException
-
startAsset
Start entry in stream.- Parameters:
path-- Throws:
IOException
-
endAsset
-
createOutputStream
Creates the realOutputStreamto which we'll write, wrapping the provided target.- Parameters:
outputStream-- Returns:
- Throws:
IOException- If an error occurred in creating the stream
-
putNextEntry
Writes the next entry (demarcates a new file/folder is to be written).- Parameters:
outputStream-context-- Throws:
IOException- If an error occurred writing the entry
-
closeEntry
Closes the current entry context for the specifiedOutputStream.- Parameters:
outputStream-- Throws:
IOException
-