public abstract class Slice
extends java.lang.Object
implements java.io.Closeable
File, ByteBuffer or InputStream. A single Slice instance should only
be used by a single thread.| Modifier and Type | Field and Description |
|---|---|
long |
inflatedLengthHint
If the slice is a deflated zip entry, this is the expected uncompressed length, or -1L if unknown.
|
boolean |
isDeflatedZipEntry
If true, the slice is a deflated zip entry, and needs to be inflated to access the content.
|
protected NestedJarHandler |
nestedJarHandler
The
NestedJarHandler. |
protected Slice |
parentSlice
The parent slice.
|
long |
sliceLength
The length of the slice, or -1L if unknown (for
InputStream). |
long |
sliceStartPos
The start position of the slice.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Slice(long length,
boolean isDeflatedZipEntry,
long inflatedLengthHint,
NestedJarHandler nestedJarHandler)
Constructor.
|
protected |
Slice(Slice parentSlice,
long offset,
long length,
boolean isDeflatedZipEntry,
long inflatedLengthHint,
NestedJarHandler nestedJarHandler)
Constructor for treating a range of a slice as a sub-slice.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
abstract byte[] |
load()
Load the slice as a byte array.
|
java.lang.String |
loadAsString()
Load the slice as a string.
|
java.io.InputStream |
open()
Open this
Slice as an InputStream. |
java.io.InputStream |
open(Resource resourceToClose)
Open this
Slice as an InputStream. |
abstract RandomAccessReader |
randomAccessReader()
Create a new
RandomAccessReader for this Slice. |
java.nio.ByteBuffer |
read()
Read the slice into a
ByteBuffer. |
abstract Slice |
slice(long offset,
long length,
boolean isDeflatedZipEntry,
long inflatedLengthHint)
|
protected final NestedJarHandler nestedJarHandler
NestedJarHandler.protected final Slice parentSlice
public final long sliceStartPos
public long sliceLength
InputStream).public final boolean isDeflatedZipEntry
public final long inflatedLengthHint
protected Slice(Slice parentSlice, long offset, long length, boolean isDeflatedZipEntry, long inflatedLengthHint, NestedJarHandler nestedJarHandler)
parentSlice - the parent sliceoffset - the offset of the sub-slice within the parent slicelength - the length of the sub-sliceisDeflatedZipEntry - true if this is a deflated zip entryinflatedLengthHint - the uncompressed size of a deflated zip entry, or -1 if unknown, or 0 of this is not a deflated
zip entry.nestedJarHandler - the nested jar handlerprotected Slice(long length,
boolean isDeflatedZipEntry,
long inflatedLengthHint,
NestedJarHandler nestedJarHandler)
length - the lengthisDeflatedZipEntry - true if this is a deflated zip entryinflatedLengthHint - the uncompressed size of a deflated zip entry, or -1 if unknown, or 0 of this is not a deflated
zip entry.nestedJarHandler - the nested jar handlerpublic abstract Slice slice(long offset, long length, boolean isDeflatedZipEntry, long inflatedLengthHint)
Slice from this parent Slice. The child slice must be smaller than the parent
slice, and completely contained within it.offset - The offset to start slicing from, relative to this parent slice's start position.length - The length of the slice.isDeflatedZipEntry - true if this is a deflated zip entryinflatedLengthHint - the uncompressed size of a deflated zip entry, or -1 if unknown, or 0 of this is not a deflated
zip entry.public java.io.InputStream open()
throws java.io.IOException
Slice as an InputStream.java.io.IOException - if an inflater cannot be created for this Slice.public java.io.InputStream open(Resource resourceToClose) throws java.io.IOException
Slice as an InputStream.public abstract RandomAccessReader randomAccessReader()
RandomAccessReader for this Slice.public abstract byte[] load()
throws java.io.IOException
java.io.IOException - Signals that an I/O exception has occurred.public java.lang.String loadAsString()
throws java.io.IOException
java.io.IOException - if slice cannot be read.public java.nio.ByteBuffer read()
throws java.io.IOException
ByteBuffer.java.io.IOException - Signals that an I/O exception has occurred.public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Object