Class MemoryData

  • All Implemented Interfaces:
    Data

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

      Fields 
      Modifier and Type Field Description
      private MIMEConfig config  
      private byte[] data  
      private int len  
      private static java.util.logging.Logger LOGGER  
    • Constructor Summary

      Constructors 
      Constructor Description
      MemoryData​(java.nio.ByteBuffer buf, MIMEConfig config)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Data createNext​(DataHead dataHead, java.nio.ByteBuffer buf)
      Factory method to create a Data.
      byte[] read()
      TODO: should the return type be ByteBuffer ?? Return part's partial data.
      int size()
      size of the chunk given by the parser
      long writeTo​(DataFile file)
      Write this partial data to a file
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOGGER

        private static final java.util.logging.Logger LOGGER
      • data

        private final byte[] data
      • len

        private final int len
    • Constructor Detail

      • MemoryData

        MemoryData​(java.nio.ByteBuffer buf,
                   MIMEConfig config)
    • Method Detail

      • 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,
                               java.nio.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 -
        buf -
        Returns: