Package org.jboss.vfs
Class VirtualJarFileInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.jboss.vfs.VirtualJarFileInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class VirtualJarFileInputStream extends java.io.InputStream
An input stream that can be used to wrap an VirtualJarInputStream (so any VFS dir) and produce a byte stream following the Zip standard.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
VirtualJarFileInputStream.ByteBuffer
private class
VirtualJarFileInputStream.ProcessedEntry
private static class
VirtualJarFileInputStream.State
Basic state machine that will allow the process to transition between the different process states.
-
Field Summary
Fields Modifier and Type Field Description private VirtualJarFileInputStream.ByteBuffer
buffer
private long
centralOffset
private java.util.zip.CRC32
crc
private int
currentCentralEntryIdx
private VirtualJarFileInputStream.ProcessedEntry
currentEntry
private VirtualJarFileInputStream.State
currentState
private static int
MINIMUM_BUFFER_LENGTH
private java.util.List<VirtualJarFileInputStream.ProcessedEntry>
processedEntries
private long
totalRead
private VirtualJarInputStream
virtualJarInputStream
-
Constructor Summary
Constructors Constructor Description VirtualJarFileInputStream(VirtualJarInputStream virtualJarInputStream)
Create with the minimum put lengthVirtualJarFileInputStream(VirtualJarInputStream virtualJarInputStream, int bufferLength)
Create with the a specified put size
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
buffer(byte b)
Buffer a single byteprivate void
buffer(byte[] bytes)
Buffer a byte arrayprivate void
bufferCentralDirectoryEnd()
Write the central file header records.private void
bufferInt(long i)
Buffer a 32-bit integer in little-endianprivate boolean
bufferLocalFileHeader()
Buffer the content of the local file header for a single entry.private boolean
bufferNextCentralFileHeader()
Buffer the central file header record for a single entry.private void
bufferShort(int i)
Buffer a 16-bit short in little-endianvoid
close()
private void
closeCurrent()
Close the current entry, and calculate the crc value.int
read()
-
-
-
Field Detail
-
MINIMUM_BUFFER_LENGTH
private static final int MINIMUM_BUFFER_LENGTH
- See Also:
- Constant Field Values
-
virtualJarInputStream
private final VirtualJarInputStream virtualJarInputStream
-
currentState
private VirtualJarFileInputStream.State currentState
-
processedEntries
private final java.util.List<VirtualJarFileInputStream.ProcessedEntry> processedEntries
-
currentEntry
private VirtualJarFileInputStream.ProcessedEntry currentEntry
-
buffer
private final VirtualJarFileInputStream.ByteBuffer buffer
-
crc
private final java.util.zip.CRC32 crc
-
currentCentralEntryIdx
private int currentCentralEntryIdx
-
centralOffset
private long centralOffset
-
totalRead
private long totalRead
-
-
Constructor Detail
-
VirtualJarFileInputStream
public VirtualJarFileInputStream(VirtualJarInputStream virtualJarInputStream)
Create with the minimum put length- Parameters:
virtualJarInputStream
- The virtual jar input stream to base the stream off of
-
VirtualJarFileInputStream
public VirtualJarFileInputStream(VirtualJarInputStream virtualJarInputStream, int bufferLength)
Create with the a specified put size- Parameters:
virtualJarInputStream
- The virtual jar input stream to base the stream off ofbufferLength
- The length of put to use
-
-
Method Detail
-
read
public int read() throws java.io.IOException
- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
-
closeCurrent
private void closeCurrent() throws java.io.IOException
Close the current entry, and calculate the crc value.- Throws:
java.io.IOException
- if any problems occur
-
bufferLocalFileHeader
private boolean bufferLocalFileHeader() throws java.io.IOException
Buffer the content of the local file header for a single entry.- Returns:
- true if the next local file header was buffered
- Throws:
java.io.IOException
- if any problems occur
-
bufferNextCentralFileHeader
private boolean bufferNextCentralFileHeader() throws java.io.IOException
Buffer the central file header record for a single entry.- Returns:
- true if the next central file header was buffered
- Throws:
java.io.IOException
- if any problems occur
-
bufferCentralDirectoryEnd
private void bufferCentralDirectoryEnd() throws java.io.IOException
Write the central file header records. This is repeated until all entries have been added to the central file header.- Throws:
java.io.IOException
- if any problem occur
-
bufferInt
private void bufferInt(long i)
Buffer a 32-bit integer in little-endian- Parameters:
i
- A long representation of a 32 bit int
-
bufferShort
private void bufferShort(int i)
Buffer a 16-bit short in little-endian- Parameters:
i
- An int representation of a 16 bit short
-
buffer
private void buffer(byte b)
Buffer a single byte- Parameters:
b
- The byte
-
buffer
private void buffer(byte[] bytes)
Buffer a byte array- Parameters:
bytes
- The bytes
-
-