Class Segment

java.lang.Object
org.aoju.bus.core.io.Segment

public class Segment extends Object
缓冲区的一段 缓冲区中的每个段都是一个循环链表节点,它引用以下内容和 缓冲区中前面的段 池中的每个段都是一个单链列表节点,引用池 段的底层字节数组可以在缓冲区和字节字符串之间共享 当一个 段不能回收,也不能改变它的字节数据 唯一的例外是允许所有者段附加到段中,写入数据 limit及以上 每个字节数组都有一个单独的拥有段 的立场, 限制、prev和next引用不共享
Since:
Java 17+
Author:
Kimi Liu
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final byte[]
     
    int
    准备写入的可用数据的第一个字节.
    链表或循环链表中的下一段.
    boolean
    如果这个段拥有字节数组并可以向其追加,则为True,扩展limit.
    int
    此段中要读取的应用程序数据字节的下一个字节.
    循环链表中的前一段.
    static final int
    这样做避免了这么多字节的arraycopy()时,将被共享
    boolean
    如果其他段或字节字符串使用相同的字节数组,则为真.
    static final int
    所有段的大小(以字节为单位)
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    Segment(byte[] data, int pos, int limit, boolean shared, boolean owner)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    final Segment
    pop()
     
    push(Segment segment)
     
    final Segment
     
    split(int byteCount)
     
    final Segment
     
    void
    writeTo(Segment sink, int byteCount)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SIZE

      public static final int SIZE
      所有段的大小(以字节为单位)
      See Also:
    • SHARE_MINIMUM

      public static final int SHARE_MINIMUM
      这样做避免了这么多字节的arraycopy()时,将被共享
      See Also:
    • data

      public final byte[] data
    • pos

      public int pos
      此段中要读取的应用程序数据字节的下一个字节.
    • limit

      public int limit
      准备写入的可用数据的第一个字节.
    • shared

      public boolean shared
      如果其他段或字节字符串使用相同的字节数组,则为真.
    • owner

      public boolean owner
      如果这个段拥有字节数组并可以向其追加,则为True,扩展limit.
    • next

      public Segment next
      链表或循环链表中的下一段.
    • prev

      public Segment prev
      循环链表中的前一段.
  • Constructor Details

    • Segment

      public Segment()
    • Segment

      public Segment(byte[] data, int pos, int limit, boolean shared, boolean owner)
  • Method Details

    • sharedCopy

      public final Segment sharedCopy()
    • unsharedCopy

      public final Segment unsharedCopy()
    • pop

      public final Segment pop()
    • push

      public Segment push(Segment segment)
    • split

      public Segment split(int byteCount)
    • compact

      public void compact()
    • writeTo

      public void writeTo(Segment sink, int byteCount)