Class ChildBuffer

java.lang.Object
org.eclipse.handly.buffer.Buffer
org.eclipse.handly.buffer.ChildBuffer
All Implemented Interfaces:
AutoCloseable, IBuffer, ISnapshotProvider, IReferenceCountable

public final class ChildBuffer extends Buffer
A child buffer is created on top of a parent IBuffer and inherits the parent's contents initially, but is modified independently. Saving the child buffer propagates its contents to the parent buffer and also to the parent buffer's underlying resource.

An instance of this class is safe for use by multiple threads.

  • Constructor Details

    • ChildBuffer

      public ChildBuffer(IBuffer parent)
      Creates a new child buffer instance on top of the given parent buffer and initializes it with the parent's contents.

      The child buffer takes an independent ownership of the parent buffer to ensure that it is kept open as long as the child buffer is in use. The client still owns the parent buffer, but may release it immediately.

      It is the client responsibility to release the created buffer after it is no longer needed.

      Parameters:
      parent - the parent buffer (not null)
      Throws:
      IllegalStateException - if the child buffer could not be created because of an inappropriate state of the parent buffer
  • Method Details