Class Chunk
- java.lang.Object
-
- org.openjdk.jmc.flightrecorder.internal.parser.Chunk
-
public class Chunk extends java.lang.Object
Class for handling data belonging to a single chunk.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]
data
private java.io.DataInput
input
private short
majorVersion
private short
minorVersion
private int
position
-
Constructor Summary
Constructors Constructor Description Chunk(java.io.DataInput input, int offset, byte[] reusableBuffer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
fill(long upToPosition)
Copy data from the input source to the chunk buffer.private static int
getArrayPosition(long pos)
short
getMajorVersion()
short
getMinorVersion()
int
getPosition()
byte[]
getReusableBuffer()
Return the current data buffer.void
skip(long upToPosition)
Skip reading data from the input source up to a specified position.
-
-
-
Constructor Detail
-
Chunk
public Chunk(java.io.DataInput input, int offset, byte[] reusableBuffer) throws java.io.IOException, InvalidJfrFileException
- Parameters:
input
- input to read chunk data fromoffset
- initial positionreusableBuffer
- a byte array for holding read chunk data- Throws:
java.io.IOException
InvalidJfrFileException
-
-
Method Detail
-
getMajorVersion
public short getMajorVersion()
-
getMinorVersion
public short getMinorVersion()
-
getPosition
public int getPosition()
-
fill
public byte[] fill(long upToPosition) throws java.io.IOException, InvalidJfrFileException
Copy data from the input source to the chunk buffer. Note that this may replace the buffer if it is not large enough.- Parameters:
upToPosition
- position to fill buffer to- Returns:
- the current buffer for the chunk data
- Throws:
java.io.IOException
InvalidJfrFileException
-
skip
public void skip(long upToPosition) throws java.io.IOException, InvalidJfrFileException
Skip reading data from the input source up to a specified position. Note that the skipped data can not be read later from the same input source.- Parameters:
upToPosition
- chunk relative position- Throws:
java.io.IOException
InvalidJfrFileException
-
getReusableBuffer
public byte[] getReusableBuffer()
Return the current data buffer. Note that the returned array is only guaranteed to contain data up to the read position when this method is called. If the buffer is filled more later, then that data may end up in a new array.- Returns:
- the current chunk data buffer
-
getArrayPosition
private static int getArrayPosition(long pos) throws InvalidJfrFileException
- Throws:
InvalidJfrFileException
-
-