Package com.tnsai.rag

Enum Class DocumentFormat

java.lang.Object
java.lang.Enum<DocumentFormat>
com.tnsai.rag.DocumentFormat
All Implemented Interfaces:
Serializable, Comparable<DocumentFormat>, Constable

public enum DocumentFormat extends Enum<DocumentFormat>
Canonical content format for a file-backed knowledge source.

The format is separate from the source location: a Knowledge.Type.FILE source says where documents come from, while this enum says how their contents must be interpreted. At this contract stage, AUTO uses bounded content detection with registered file-name aliases as a fallback hint. An explicit format is strict and its registered aliases are part of the declaration contract.

Declaring a format does not imply that an extractor is installed. Textual formats are handled by the bundled file-ingestion path; binary document formats require an optional ContentExtractor provider.

  • Enum Constant Details

    • AUTO

      public static final DocumentFormat AUTO
      Infer each candidate independently, with content detection downstream.
    • TEXT

      public static final DocumentFormat TEXT
      Raw UTF-8 text. Explicit TEXT intentionally accepts any file name.
    • MARKDOWN

      public static final DocumentFormat MARKDOWN
      Markdown text.
    • HTML

      public static final DocumentFormat HTML
      HTML text.
    • CSV

      public static final DocumentFormat CSV
      Comma-separated values.
    • TSV

      public static final DocumentFormat TSV
      Tab-separated values.
    • JSON

      public static final DocumentFormat JSON
      JSON document.
    • JSONL

      public static final DocumentFormat JSONL
      Newline-delimited JSON document.
    • YAML

      public static final DocumentFormat YAML
      YAML document.
    • XML

      public static final DocumentFormat XML
      XML document.
    • PDF

      public static final DocumentFormat PDF
      Portable Document Format document.
    • DOCX

      public static final DocumentFormat DOCX
      Office Open XML word-processing document.
    • XLSX

      public static final DocumentFormat XLSX
      Office Open XML spreadsheet.
    • PPTX

      public static final DocumentFormat PPTX
      Office Open XML presentation.
    • EPUB

      public static final DocumentFormat EPUB
      EPUB publication.
    • SOURCE_CODE

      public static final DocumentFormat SOURCE_CODE
      Source-code family; language detection is performed after selection.
  • Method Details

    • values

      public static DocumentFormat[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static DocumentFormat valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • isTextual

      public boolean isTextual()
      Returns whether the bundled file path can decode this format as UTF-8. Structural extraction may still require a format-specific extractor.
    • extensions

      public Set<String> extensions()
      Returns the registered lowercase extensions, without a leading dot.
    • matchesFileName

      public boolean matchesFileName(String fileName)
      Returns whether a file name carries one of this format's aliases.

      TEXT is intentionally special at ingestion time and may be used with any file name; this method still reports only its registered .txt alias.

    • fromFileName

      public static Optional<DocumentFormat> fromFileName(String fileName)
      Resolves a registered format from a file name, if one is known.