Class InferenceUnit

java.lang.Object
org.apache.tika.parser.inference.InferenceUnit

public final class InferenceUnit extends Object
One thing offered to the dispatcher: the bytes of an image, a page render, a media clip, with the document they came from and, when known, its parent. Captured at the offer so a task can run after the document has closed; the bytes live in a file the dispatcher owns until the flush, and the id paths let the flush find the metadata the recursive wrapper kept once the parser's own objects are no longer read. A task writes its result on the destination, which the dispatcher decides: the parent for an inline part or a page render, the document itself otherwise, and the top-level document for everything when the parse produces one metadata object.
  • Constructor Details

  • Method Details

    • lifts

      public static boolean lifts(Metadata target)
      Whether results for this document belong on the one it is part of, not on it.
    • getDestination

      public Metadata getDestination()
      Where a task writes this unit's results.
    • isLifted

      public boolean isLifted()
      Whether the results go on another document than the target, which a locator then names.
    • getText

      public String getText()
      The text of a InputKind.TEXT unit; null for the rest.
    • getPage

      public int getPage()
      The 1-based page this unit renders, for InputKind.PAGES; -1 otherwise.
    • getKind

      public InputKind getKind()
    • getType

      public MediaType getType()
    • getTarget

      public Metadata getTarget()
      The document the bytes belong to.
    • getParent

      public Metadata getParent()
      The document the target is embedded in; null at top level.
    • getTargetIdPath

      public String getTargetIdPath()
    • getParentIdPath

      public String getParentIdPath()
    • getPath

      public Path getPath()
    • getSize

      public long getSize()
    • getBytes

      public byte[] getBytes() throws IOException
      Readable during a task run only; the file is deleted when the flush ends.
      Throws:
      IOException