Record Class ChunkedFileProcessor.Chunk

java.lang.Object
java.lang.Record
cloud.opencode.base.io.file.ChunkedFileProcessor.Chunk
Record Components:
index - the chunk index (0-based) - 块索引(从0开始)
offset - the byte offset in the file - 文件中的字节偏移
data - the chunk data - 块数据
size - the actual data size (may be less than data.length for last chunk) - 实际数据大小
isLast - whether this is the last chunk - 是否是最后一块
Enclosing class:
ChunkedFileProcessor

public static record ChunkedFileProcessor.Chunk(long index, long offset, byte[] data, int size, boolean isLast) extends Record
Represents a chunk of file data. 表示文件数据块。
Since:
JDK 25, opencode-base-io V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Constructor Summary

    Constructors
    Constructor
    Description
    Chunk(long index, long offset, byte[] data, int size, boolean isLast)
    Compact constructor - defensive copy of mutable byte array.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Gets the actual data as a trimmed byte array.
    byte[]
    Returns the value of the data record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    long
    Returns the value of the index record component.
    boolean
    Returns the value of the isLast record component.
    long
    Returns the value of the offset record component.
    int
    Returns the value of the size record component.
    Gets a read-only ByteBuffer view of the data.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Chunk

      public Chunk(long index, long offset, byte[] data, int size, boolean isLast)
      Compact constructor - defensive copy of mutable byte array. 紧凑构造器 - 可变字节数组的防御性复制。
  • Method Details

    • toByteBuffer

      public ByteBuffer toByteBuffer()
      Gets a read-only ByteBuffer view of the data. 获取数据的只读ByteBuffer视图。
      Returns:
      a read-only ByteBuffer - 只读ByteBuffer
    • bytes

      public byte[] bytes()
      Gets the actual data as a trimmed byte array. 获取修剪后的实际数据字节数组。
      Returns:
      the data bytes - 数据字节
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • index

      public long index()
      Returns the value of the index record component.
      Returns:
      the value of the index record component
    • offset

      public long offset()
      Returns the value of the offset record component.
      Returns:
      the value of the offset record component
    • data

      public byte[] data()
      Returns the value of the data record component.
      Returns:
      the value of the data record component
    • size

      public int size()
      Returns the value of the size record component.
      Returns:
      the value of the size record component
    • isLast

      public boolean isLast()
      Returns the value of the isLast record component.
      Returns:
      the value of the isLast record component