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.InputStreamAn 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 classVirtualJarFileInputStream.ByteBufferprivate classVirtualJarFileInputStream.ProcessedEntryprivate static classVirtualJarFileInputStream.StateBasic state machine that will allow the process to transition between the different process states.
-
Field Summary
Fields Modifier and Type Field Description private VirtualJarFileInputStream.ByteBufferbufferprivate longcentralOffsetprivate java.util.zip.CRC32crcprivate intcurrentCentralEntryIdxprivate VirtualJarFileInputStream.ProcessedEntrycurrentEntryprivate VirtualJarFileInputStream.StatecurrentStateprivate static intMINIMUM_BUFFER_LENGTHprivate java.util.List<VirtualJarFileInputStream.ProcessedEntry>processedEntriesprivate longtotalReadprivate VirtualJarInputStreamvirtualJarInputStream
-
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 voidbuffer(byte b)Buffer a single byteprivate voidbuffer(byte[] bytes)Buffer a byte arrayprivate voidbufferCentralDirectoryEnd()Write the central file header records.private voidbufferInt(long i)Buffer a 32-bit integer in little-endianprivate booleanbufferLocalFileHeader()Buffer the content of the local file header for a single entry.private booleanbufferNextCentralFileHeader()Buffer the central file header record for a single entry.private voidbufferShort(int i)Buffer a 16-bit short in little-endianvoidclose()private voidcloseCurrent()Close the current entry, and calculate the crc value.intread()
-
-
-
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:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
closeCurrent
private void closeCurrent() throws java.io.IOExceptionClose the current entry, and calculate the crc value.- Throws:
java.io.IOException- if any problems occur
-
bufferLocalFileHeader
private boolean bufferLocalFileHeader() throws java.io.IOExceptionBuffer 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.IOExceptionBuffer 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.IOExceptionWrite 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
-
-