Class ContentSlice

java.lang.Object
zeroecho.core.io.ContentSlice
All Implemented Interfaces:
AutoCloseable, RepeatableContent

public final class ContentSlice extends Object implements RepeatableContent
Immutable repeatable bounded view over another repeatable content source.

A slice opens a fresh source pass and skips incrementally; it never copies the represented bytes. Closing the slice does not close its source because source ownership remains with the creator.

  • Constructor Details

    • ContentSlice

      public ContentSlice(RepeatableContent source, long offset, long length)
      Creates a repeatable slice.
      Parameters:
      source - repeatable source
      offset - non-negative source offset
      length - non-negative slice length
      Throws:
      IllegalArgumentException - if a range is negative or exceeds a known source length
  • Method Details

    • openStream

      public InputStream openStream() throws IOException
      Description copied from interface: RepeatableContent
      Opens a new sequential reader.
      Specified by:
      openStream in interface RepeatableContent
      Returns:
      newly opened content stream
      Throws:
      IOException - if the immutable content cannot be opened or its integrity cannot be established
    • length

      public OptionalLong length()
      Description copied from interface: RepeatableContent
      Returns the known aggregate length when cheaply and authoritatively available.
      Specified by:
      length in interface RepeatableContent
      Returns:
      non-negative length, or empty when the length is unknown
    • contentId

      public String contentId()
      Description copied from interface: RepeatableContent
      Returns a stable, non-secret identifier for integrity and durable provenance.

      The identifier is metadata, not authorization, and must not expose a temporary physical path.

      Specified by:
      contentId in interface RepeatableContent
      Returns:
      stable non-blank identifier
    • close

      public void close()
      Description copied from interface: RepeatableContent
      Releases implementation-owned resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface RepeatableContent