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 int
Number of bytes kept in buffer.private final ByteArrayOutputStream
Base for outputStream.private ByteArrayInputStream
Stream to the buffer.private InputStream
Stream of currently processed Node.private ArchivePath
Currently processed archive path - for displaying exception.Iterator over nodes contained in base archive.protected T
Created by abstract method.private boolean
If output stream was closed - we should finish. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractOnDemandInputStream
(Archive<?> archive) Creates stream directly from archive. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
closeEntry
(T outputStream) Closes the current entry context for the specifiedOutputStream
.protected abstract T
createOutputStream
(OutputStream outputStream) Creates the realOutputStream
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, String context) Writes the next entry (demarcates a new file/folder is to be written).int
read()
private void
startAsset
(String path) Start entry in stream.Methods inherited from class java.io.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
Iterator over nodes contained in base archive. -
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:
read
in 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
Close entry in stream.- Throws:
IOException
-
createOutputStream
Creates the realOutputStream
to 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
-