Class RTFPictStreamParser

java.lang.Object
org.apache.tika.parser.microsoft.rtf.jflex.RTFPictStreamParser
All Implemented Interfaces:
Closeable, AutoCloseable

public class RTFPictStreamParser extends Object implements Closeable
Streams decoded bytes from an RTF \pict group to a temp file.

Pict data is raw image bytes (after hex-pair decoding). There is no header to parse -- bytes are written directly to a temp file. On onComplete(Metadata), a TikaInputStream is returned whose close will clean up the temp file via TemporaryResources.

  • Constructor Details

    • RTFPictStreamParser

      public RTFPictStreamParser(long maxBytes) throws IOException
      Parameters:
      maxBytes - maximum number of bytes to accept (-1 for unlimited)
      Throws:
      IOException
  • Method Details

    • onByte

      public void onByte(int b) throws IOException, TikaException
      Receive a single decoded byte from the pict hex stream.
      Throws:
      IOException
      TikaException
    • onComplete

      public TikaInputStream onComplete(Metadata metadata) throws IOException
      Called when the pict group closes. Returns a TikaInputStream backed by the temp file. The caller owns the TikaInputStream -- closing it will delete the temp file.
      Returns:
      a TikaInputStream, or null if no bytes were written
      Throws:
      IOException
    • getBytesWritten

      public long getBytesWritten()
      Returns the number of bytes written so far.
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException