Class MemoryData

java.lang.Object
org.jvnet.mimepull.MemoryData
All Implemented Interfaces:
Data

final class MemoryData extends Object implements Data
Keeps the Part's partial content data in memory.
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • data

      private final byte[] data
    • len

      private final int len
    • config

      private final MIMEConfig config
    • DELETE_ON_EXIT

      private static final boolean DELETE_ON_EXIT
  • Constructor Details

  • Method Details

    • size

      public int size()
      Description copied from interface: Data
      size of the chunk given by the parser
      Specified by:
      size in interface Data
      Returns:
      size of the chunk
    • read

      public byte[] read()
      Description copied from interface: Data
      TODO: should the return type be ByteBuffer ?? Return part's partial data. The data is read only.
      Specified by:
      read in interface Data
      Returns:
      a byte array which contains {#size()} bytes. The returned array may be larger than {#size()} bytes and contains data from offset 0.
    • writeTo

      public long writeTo(DataFile file)
      Description copied from interface: Data
      Write this partial data to a file
      Specified by:
      writeTo in interface Data
      Parameters:
      file - to which the data needs to be written
      Returns:
      file pointer before the write operation(at which the data is written from)
    • createNext

      public Data createNext(DataHead dataHead, ByteBuffer buf)
      Description copied from interface: Data
      Factory method to create a Data. The implementation could be file based one or memory based one.
      Specified by:
      createNext in interface Data
      Parameters:
      dataHead - start of the linked list of data objects
      buf - contains partial content for a part
      Returns:
      Data
    • createTempFile

      private static File createTempFile(String prefix, String suffix, File dir) throws IOException
      Throws:
      IOException