Top Description Fields Constructors Methods
nonapi.io.github.classgraph.fileslice.reader

public Class RandomAccessFileChannelReader

extends Object
implements RandomAccessReader
Class Inheritance
All Implemented Interfaces
nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader
Imports
java.io.File, .IOException, java.nio.Buffer, .BufferUnderflowException, .ByteBuffer, java.nio.channels.FileChannel, nonapi.io.github.classgraph.utils.StringUtils

RandomAccessReader for a File. Reads in little endian order, as required by the zipfile format.

Field Summary

Modifier and TypeField and Description
private final FileChannel
fileChannel

The file channel.

private ByteBuffer
reusableByteBuffer

The reusable byte buffer.

private final byte[]
scratchArr

The scratch arr.

private final ByteBuffer
scratchByteBuf

The scratch byte buf.

private final long
sliceLength

The slice length.

private final long
sliceStartPos

The slice start pos.

private byte[]
utf8Bytes

The utf 8 bytes.

Constructor Summary

AccessConstructor and Description
public
RandomAccessFileChannelReader(final FileChannel
the file channel
fileChannel
,
final long
the slice start pos
sliceStartPos
,
final long
the slice length
sliceLength
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public int
read(final long
The offset to start reading from.
srcOffset
,
final ByteBuffer
The ByteBuffer to write into.
dstBuf
,
final int
The offset within the destination buffer to start writing at.
dstBufStart
,
final int
The number of bytes to read.
numBytes
)

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.read.

Read bytes into a ByteBuffer.

public int
read(final long
The offset to start reading from.
srcOffset
,
final byte[]
The byte array to write into.
dstArr
,
final int
The offset within the destination array to start writing at.
dstArrStart
,
final int
The number of bytes to read.
numBytes
)

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.read.

Read bytes into a byte array.

public byte
readByte(final long
The buffer offset to read from.
offset
)

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readByte.

Read a byte at a specific offset (without changing the current cursor offset).

public int
readInt(final long
The buffer offset to read from.
offset
)

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readInt.

Read a int at a specific offset (without changing the current cursor offset).

public long
readLong(final long
The buffer offset to read from.
offset
)

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readLong.

Read a long at a specific offset (without changing the current cursor offset).

public short
readShort(final long
The buffer offset to read from.
offset
)

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readShort.

Read a short at a specific offset (without changing the current cursor offset).

public String
readString(final long
The start offset of the string.
offset
,
final int
The number of bytes of the UTF8 encoding of the string.
numBytes
,
final boolean
If true, replace '/' with '.'.
replaceSlashWithDot
,
final boolean
If true, string final ';' character.
stripLSemicolon
)

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readString.

Reads the "modified UTF8" format defined in the Java classfile spec, optionally replacing '/' with '.', and optionally removing the prefix "L" and the suffix ";".

public String
readString(final long
The start offset of the string.
offset
,
final int
The number of bytes of the UTF8 encoding of the string.
numBytes
)

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readString.

Reads the "modified UTF8" format defined in the Java classfile spec.

public int
readUnsignedByte(final long
The buffer offset to read from.
offset
)

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readUnsignedByte.

Read an unsigned byte at a specific offset (without changing the current cursor offset).

public long
readUnsignedInt(final long
The buffer offset to read from.
offset
)

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readUnsignedInt.

Read a unsigned int at a specific offset (without changing the current cursor offset).

public int
readUnsignedShort(final long
The buffer offset to read from.
offset
)

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readUnsignedShort.

Read a unsigned short at a specific offset (without changing the current cursor offset).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fileChannelback to summary
private final FileChannel fileChannel

The file channel.

reusableByteBufferback to summary
private ByteBuffer reusableByteBuffer

The reusable byte buffer.

scratchArrback to summary
private final byte[] scratchArr

The scratch arr.

scratchByteBufback to summary
private final ByteBuffer scratchByteBuf

The scratch byte buf.

sliceLengthback to summary
private final long sliceLength

The slice length.

sliceStartPosback to summary
private final long sliceStartPos

The slice start pos.

utf8Bytesback to summary
private byte[] utf8Bytes

The utf 8 bytes.

Constructor Detail

RandomAccessFileChannelReaderback to summary
public RandomAccessFileChannelReader(final FileChannel fileChannel, final long sliceStartPos, final long sliceLength)

Constructor.

Parameters
fileChannel:FileChannel

the file channel

sliceStartPos:long

the slice start pos

sliceLength:long

the slice length

Method Detail

readback to summary
public int read(final long srcOffset, final ByteBuffer dstBuf, final int dstBufStart, final int numBytes) throws IOException

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.read.

Doc from nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.read.

Read bytes into a ByteBuffer.

Parameters
srcOffset:long

The offset to start reading from.

dstBuf:ByteBuffer

The ByteBuffer to write into.

dstBufStart:int

The offset within the destination buffer to start writing at.

numBytes:int

The number of bytes to read.

Returns:int

The number of bytes actually read, or -1 if no more bytes could be read.

Annotations
@Override
Exceptions
IOException:
If there was an exception while reading.
readback to summary
public int read(final long srcOffset, final byte[] dstArr, final int dstArrStart, final int numBytes) throws IOException

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.read.

Doc from nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.read.

Read bytes into a byte array.

Parameters
srcOffset:long

The offset to start reading from.

dstArr:byte[]

The byte array to write into.

dstArrStart:int

The offset within the destination array to start writing at.

numBytes:int

The number of bytes to read.

Returns:int

The number of bytes actually read, or -1 if no more bytes could be read.

Annotations
@Override
Exceptions
IOException:
If there was an exception while reading.
readByteback to summary
public byte readByte(final long offset) throws IOException

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readByte.

Doc from nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readByte.

Read a byte at a specific offset (without changing the current cursor offset).

Parameters
offset:long

The buffer offset to read from.

Returns:byte

The byte at the offset.

Annotations
@Override
Exceptions
IOException:
If there was an exception while reading.
readIntback to summary
public int readInt(final long offset) throws IOException

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readInt.

Doc from nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readInt.

Read a int at a specific offset (without changing the current cursor offset).

Parameters
offset:long

The buffer offset to read from.

Returns:int

The int at the offset.

Annotations
@Override
Exceptions
IOException:
If there was an exception while reading.
readLongback to summary
public long readLong(final long offset) throws IOException

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readLong.

Doc from nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readLong.

Read a long at a specific offset (without changing the current cursor offset).

Parameters
offset:long

The buffer offset to read from.

Returns:long

The long at the offset.

Annotations
@Override
Exceptions
IOException:
If there was an exception while reading.
readShortback to summary
public short readShort(final long offset) throws IOException

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readShort.

Doc from nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readShort.

Read a short at a specific offset (without changing the current cursor offset).

Parameters
offset:long

The buffer offset to read from.

Returns:short

The short at the offset.

Annotations
@Override
Exceptions
IOException:
If there was an exception while reading.
readStringback to summary
public String readString(final long offset, final int numBytes, final boolean replaceSlashWithDot, final boolean stripLSemicolon) throws IOException

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readString.

Doc from nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readString.

Reads the "modified UTF8" format defined in the Java classfile spec, optionally replacing '/' with '.', and optionally removing the prefix "L" and the suffix ";".

Parameters
offset:long

The start offset of the string.

numBytes:int

The number of bytes of the UTF8 encoding of the string.

replaceSlashWithDot:boolean

If true, replace '/' with '.'.

stripLSemicolon:boolean

If true, string final ';' character.

Returns:String

The string.

Annotations
@Override
Exceptions
IOException:
If an I/O exception occurs.
readStringback to summary
public String readString(final long offset, final int numBytes) throws IOException

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readString.

Doc from nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readString.

Reads the "modified UTF8" format defined in the Java classfile spec.

Parameters
offset:long

The start offset of the string.

numBytes:int

The number of bytes of the UTF8 encoding of the string.

Returns:String

The string.

Annotations
@Override
Exceptions
IOException:
If an I/O exception occurs.
readUnsignedByteback to summary
public int readUnsignedByte(final long offset) throws IOException

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readUnsignedByte.

Doc from nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readUnsignedByte.

Read an unsigned byte at a specific offset (without changing the current cursor offset).

Parameters
offset:long

The buffer offset to read from.

Returns:int

The unsigned byte at the offset.

Annotations
@Override
Exceptions
IOException:
If there was an exception while reading.
readUnsignedIntback to summary
public long readUnsignedInt(final long offset) throws IOException

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readUnsignedInt.

Doc from nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readUnsignedInt.

Read a unsigned int at a specific offset (without changing the current cursor offset).

Parameters
offset:long

The buffer offset to read from.

Returns:long

The int at the offset, as a long.

Annotations
@Override
Exceptions
IOException:
If there was an exception while reading.
readUnsignedShortback to summary
public int readUnsignedShort(final long offset) throws IOException

Implements nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readUnsignedShort.

Doc from nonapi.io.github.classgraph.fileslice.reader.RandomAccessReader.readUnsignedShort.

Read a unsigned short at a specific offset (without changing the current cursor offset).

Parameters
offset:long

The buffer offset to read from.

Returns:int

The unsigned short at the offset.

Annotations
@Override
Exceptions
IOException:
If there was an exception while reading.