Package org.h2.store.fs.zip
Class FileZip
- java.lang.Object
-
- java.nio.channels.spi.AbstractInterruptibleChannel
-
- java.nio.channels.FileChannel
-
- org.h2.store.fs.FileBase
-
- org.h2.store.fs.zip.FileZip
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.nio.channels.ByteChannel
,java.nio.channels.Channel
,java.nio.channels.GatheringByteChannel
,java.nio.channels.InterruptibleChannel
,java.nio.channels.ReadableByteChannel
,java.nio.channels.ScatteringByteChannel
,java.nio.channels.SeekableByteChannel
,java.nio.channels.WritableByteChannel
class FileZip extends FileBase
The file is read from a stream. When reading from start to end, the same input stream is re-used, however when reading from end to start, a new input stream is opened for each request.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.zip.ZipEntry
entry
private java.util.zip.ZipFile
file
private java.io.InputStream
in
private long
inPos
private long
length
private long
pos
private static byte[]
SKIP_BUFFER
private boolean
skipUsingRead
-
Constructor Summary
Constructors Constructor Description FileZip(java.util.zip.ZipFile file, java.util.zip.ZipEntry entry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
force(boolean metaData)
protected void
implCloseChannel()
long
position()
java.nio.channels.FileChannel
position(long newPos)
int
read(java.nio.ByteBuffer dst)
private void
seek()
long
size()
java.nio.channels.FileChannel
truncate(long newLength)
java.nio.channels.FileLock
tryLock(long position, long size, boolean shared)
int
write(java.nio.ByteBuffer src)
-
Methods inherited from class org.h2.store.fs.FileBase
lock, map, read, read, transferFrom, transferTo, write, write
-
Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel
begin, close, end, isOpen
-
-
-
-
Field Detail
-
SKIP_BUFFER
private static final byte[] SKIP_BUFFER
-
file
private final java.util.zip.ZipFile file
-
entry
private final java.util.zip.ZipEntry entry
-
pos
private long pos
-
in
private java.io.InputStream in
-
inPos
private long inPos
-
length
private final long length
-
skipUsingRead
private boolean skipUsingRead
-
-
Method Detail
-
position
public long position()
- Specified by:
position
in interfacejava.nio.channels.SeekableByteChannel
- Specified by:
position
in classjava.nio.channels.FileChannel
-
size
public long size()
- Specified by:
size
in interfacejava.nio.channels.SeekableByteChannel
- Specified by:
size
in classjava.nio.channels.FileChannel
-
read
public int read(java.nio.ByteBuffer dst) throws java.io.IOException
- Specified by:
read
in interfacejava.nio.channels.ReadableByteChannel
- Specified by:
read
in interfacejava.nio.channels.SeekableByteChannel
- Specified by:
read
in classjava.nio.channels.FileChannel
- Throws:
java.io.IOException
-
seek
private void seek() throws java.io.IOException
- Throws:
java.io.IOException
-
position
public java.nio.channels.FileChannel position(long newPos)
- Specified by:
position
in interfacejava.nio.channels.SeekableByteChannel
- Specified by:
position
in classjava.nio.channels.FileChannel
-
truncate
public java.nio.channels.FileChannel truncate(long newLength) throws java.io.IOException
- Specified by:
truncate
in interfacejava.nio.channels.SeekableByteChannel
- Specified by:
truncate
in classjava.nio.channels.FileChannel
- Throws:
java.io.IOException
-
force
public void force(boolean metaData) throws java.io.IOException
-
write
public int write(java.nio.ByteBuffer src) throws java.io.IOException
- Specified by:
write
in interfacejava.nio.channels.SeekableByteChannel
- Specified by:
write
in interfacejava.nio.channels.WritableByteChannel
- Specified by:
write
in classjava.nio.channels.FileChannel
- Throws:
java.io.IOException
-
tryLock
public java.nio.channels.FileLock tryLock(long position, long size, boolean shared) throws java.io.IOException
-
implCloseChannel
protected void implCloseChannel() throws java.io.IOException
- Overrides:
implCloseChannel
in classFileBase
- Throws:
java.io.IOException
-
-