Interface Digester

All Known Implementing Classes:
BouncyCastleDigester, CommonsDigester, CompositeDigester, InputStreamDigester

public interface Digester
Interface for digester implementations. See InputStreamDigester for an implementation in tika-core, or CommonsDigester in tika-parser-digest-commons.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    digest(TikaInputStream tis, Metadata m, ParseContext parseContext)
    Digests a TikaInputStream and sets the appropriate value(s) in the metadata.
    default DigestSink
    digestSink(Metadata m, ParseContext parseContext)
    A sink that digests whatever is written to it and sets the value(s) in the metadata when committed and closed.
  • Method Details

    • digest

      void digest(TikaInputStream tis, Metadata m, ParseContext parseContext) throws IOException
      Digests a TikaInputStream and sets the appropriate value(s) in the metadata. The Digester is responsible for calling TikaInputStream.enableRewind() and TikaInputStream.rewind() to ensure the stream can be read by subsequent processing after digesting.

      The stream must not be closed by the digester.

      Parameters:
      tis - TikaInputStream to digest
      m - Metadata to set the values for
      parseContext - ParseContext
      Throws:
      IOException - on I/O error
    • digestSink

      default DigestSink digestSink(Metadata m, ParseContext parseContext) throws IOException
      A sink that digests whatever is written to it and sets the value(s) in the metadata when committed and closed. For producers that only write (an embedded-stream translator, say) this digests the bytes as they are produced, with no buffer and no temp file. See DigestSink for the commit/close contract.

      The default buffers what is written -- in memory below a fixed threshold, in a temp file above it -- and runs digest(org.apache.tika.io.TikaInputStream, org.apache.tika.metadata.Metadata, org.apache.tika.parser.ParseContext) over it when committed, so one that only overrides digest keeps working unchanged. It does not get the streaming behaviour: override this method to provide it.

      Parameters:
      m - Metadata the values are set on when the sink is committed
      parseContext - ParseContext
      Returns:
      a sink; the caller must close it, and the values are set only if it was committed
      Throws:
      IOException