Package com.tnsai.rag

Record Class DocumentInput

java.lang.Object
java.lang.Record
com.tnsai.rag.DocumentInput
Record Components:
id - stable source-local identifier
bytes - source bytes
format - detected concrete format
mediaType - detected or declared media type
source - canonical source URI
metadata - immutable source metadata

public record DocumentInput(String id, byte[] bytes, DocumentFormat format, String mediaType, URI source, Map<String,Object> metadata) extends Record
Immutable byte input passed to a ContentExtractor after detection.

The byte array is defensively copied on construction and access. Its contents are deliberately omitted from toString() so diagnostics do not disclose source documents.

Media types are limited to 256 printable ASCII characters and must contain a type/subtype slash.

Metadata accepts immutable scalar values (String, boxed primitive values, BigInteger, BigDecimal, URI, enums, and JDK java.time values) plus recursively nested Map<String, ?>, collections, sets, and arrays. Containers are copied, arrays are normalized to immutable lists, nulls and other mutable object types are rejected. A metadata snapshot is limited to 16 levels, 4,096 keys and values, 1,048,576 characters per string, and 4,194,304 characters across scalar values and keys. Enums are normalized to stable declaring-class#constant-name strings.

Since:
0.13.0
  • Constructor Details

    • DocumentInput

      public DocumentInput(String id, byte[] bytes, DocumentFormat format, String mediaType, URI source, Map<String,Object> metadata)
      Creates an instance of a DocumentInput record class.
      Parameters:
      id - the value for the id record component
      bytes - the value for the bytes record component
      format - the value for the format record component
      mediaType - the value for the mediaType record component
      source - the value for the source record component
      metadata - the value for the metadata record component
  • Method Details

    • bytes

      public byte[] bytes()
      Returns the value of the bytes record component.
      Returns:
      the value of the bytes record component
    • byteLength

      public int byteLength()
      Returns the source byte length without copying the payload.
    • equals

      public boolean equals(Object candidate)
      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. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      candidate - the object with which to compare
      Returns:
      true if this object is the same as the candidate argument; false otherwise.
    • hashCode

      public 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
    • toString

      public 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
    • id

      public String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • format

      public DocumentFormat format()
      Returns the value of the format record component.
      Returns:
      the value of the format record component
    • mediaType

      public String mediaType()
      Returns the value of the mediaType record component.
      Returns:
      the value of the mediaType record component
    • source

      public URI source()
      Returns the value of the source record component.
      Returns:
      the value of the source record component
    • metadata

      public Map<String,Object> metadata()
      Returns the value of the metadata record component.
      Returns:
      the value of the metadata record component