Class DataHead

java.lang.Object
org.jvnet.mimepull.DataHead

final class DataHead extends Object
Represents an attachment part in a MIME message. MIME message parsing is done lazily using a pull parser, so the part may not have all the data. read() and readOnce may trigger the actual parsing the message. In fact, parsing of an attachment part may be triggered by calling read() methods on some other attachment parts. All this happens behind the scenes so the application developer need not worry about these details.
  • Field Details

    • tail

      volatile Chunk tail
      Linked list to keep the part's content
    • dataFile

      DataFile dataFile
      If the part is stored in a file, non-null.
    • part

      private final MIMEPart part
    • readOnce

      boolean readOnce
    • inMemory

      volatile long inMemory
    • consumedAt

      private Throwable consumedAt
      Used only for debugging. This records where readOnce() is called.
  • Constructor Details

  • Method Details

    • addBody

      void addBody(ByteBuffer buf)
    • doneParsing

      void doneParsing()
    • moveTo

      void moveTo(File f)
    • close

      void close()
    • read

      public InputStream read()
      Can get the attachment part's content multiple times. That means the full content needs to be there in memory or on the file system. Calling this method would trigger parsing for the part's data. So do not call this unless it is required(otherwise, just wrap MIMEPart into a object that returns InputStream for e.g DataHandler)
      Returns:
      data for the part's content
    • unconsumed

      private boolean unconsumed()
      Used for an assertion. Returns true when readOnce() is not already called. or otherwise throw an exception.

      Calling this method also marks the stream as 'consumed'

      Returns:
      true if readOnce() is not called before
    • readOnce

      public InputStream readOnce()
      Can get the attachment part's content only once. The content will be lost after the method. Content data is not be stored on the file system or is not kept in the memory for the following case: - Attachement parts contents are accessed sequentially In general, take advantage of this when the data is used only once.
      Returns:
      data for the part's content