Class Chunk


  • public class Chunk
    extends java.lang.Object
    Class for handling data belonging to a single chunk.
    • Constructor Summary

      Constructors 
      Constructor Description
      Chunk​(java.io.DataInput input, int offset, byte[] reusableBuffer)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] fill​(long upToPosition)
      Copy data from the input source to the chunk buffer.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Chunk

        public Chunk​(java.io.DataInput input,
                     int offset,
                     byte[] reusableBuffer)
              throws java.io.IOException,
                     org.openjdk.jmc.flightrecorder.internal.InvalidJfrFileException
        Parameters:
        input - input to read chunk data from
        offset - initial position
        reusableBuffer - a byte array for holding read chunk data
        Throws:
        java.io.IOException
        org.openjdk.jmc.flightrecorder.internal.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,
                           org.openjdk.jmc.flightrecorder.internal.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
        org.openjdk.jmc.flightrecorder.internal.InvalidJfrFileException
      • skip

        public void skip​(long upToPosition)
                  throws java.io.IOException,
                         org.openjdk.jmc.flightrecorder.internal.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
        org.openjdk.jmc.flightrecorder.internal.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