Module bus.core

Class AssignSink

java.lang.Object
org.miaixz.bus.core.io.sink.AssignSink
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, Sink
Direct Known Subclasses:
FaultHideSink

public abstract class AssignSink extends Object implements Sink
将操作转发给另一个 Sink 的抽象接收器。
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Summary

    Constructors
    Constructor
    Description
    AssignSink(Sink delegate)
    构造方法,初始化代理接收器。
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    关闭代理接收器并释放资源。
    final Sink
    获取代理的接收器。
    void
    将缓冲数据刷新到代理接收器。
    获取代理接收器的超时配置。
    返回对象的字符串表示。
    void
    write(Buffer source, long byteCount)
    从源缓冲区读取指定字节数并写入代理接收器。

    Methods inherited from class java.lang.Object

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

    • AssignSink

      public AssignSink(Sink delegate)
      构造方法,初始化代理接收器。
      Parameters:
      delegate - 代理的接收器,不能为 null
      Throws:
      IllegalArgumentException - 如果 delegate 为 null
  • Method Details

    • delegate

      public final Sink delegate()
      获取代理的接收器。
      Returns:
      代理的接收器
    • write

      public void write(Buffer source, long byteCount) throws IOException
      从源缓冲区读取指定字节数并写入代理接收器。
      Specified by:
      write in interface Sink
      Parameters:
      source - 数据源缓冲区
      byteCount - 要读取的字节数
      Throws:
      IOException - 如果写入失败
    • flush

      public void flush() throws IOException
      将缓冲数据刷新到代理接收器。
      Specified by:
      flush in interface Flushable
      Specified by:
      flush in interface Sink
      Throws:
      IOException - 如果刷新失败
    • timeout

      public Timeout timeout()
      获取代理接收器的超时配置。
      Specified by:
      timeout in interface Sink
      Returns:
      超时对象
    • close

      public void close() throws IOException
      关闭代理接收器并释放资源。
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface Sink
      Throws:
      IOException - 如果关闭失败
    • toString

      public String toString()
      返回对象的字符串表示。
      Overrides:
      toString in class Object
      Returns:
      字符串表示,包含类名和代理接收器的字符串表示