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

public Class RandomAccessArrayReader

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

RandomAccessReader backed by a byte array. Reads in little endian order, as required by the zipfile format.

Field Summary

Modifier and TypeField and Description
private final byte[]
arr

The array.

private final int
sliceLength

The length of the slice within the array.

private final int
sliceStartPos

The start index of the slice within the array.

Constructor Summary

AccessConstructor and Description
public
RandomAccessArrayReader(final byte[]
the array to slice.
arr
,
final int
the start index of the slice within the array.
sliceStartPos
,
final int
the length of the slice within the array.
sliceLength
)

Constructor for slicing an array.

Method Summary

Modifier and TypeMethod and Description
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 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 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

arrback to summary
private final byte[] arr

The array.

sliceLengthback to summary
private final int sliceLength

The length of the slice within the array.

sliceStartPosback to summary
private final int sliceStartPos

The start index of the slice within the array.

Constructor Detail

RandomAccessArrayReaderback to summary
public RandomAccessArrayReader(final byte[] arr, final int sliceStartPos, final int sliceLength)

Constructor for slicing an array.

Parameters
arr:byte[]

the array to slice.

sliceStartPos:int

the start index of the slice within the array.

sliceLength:int

the length of the slice within the array.

Method Detail

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.
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.
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.