Class FileData

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

final class FileData extends Object implements Data
Keeps the Part's partial content data in a file.
  • Field Details

    • file

      private final DataFile file
    • pointer

      private final long pointer
    • length

      private final int length
  • Constructor Details

  • Method Details

    • 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)
    • 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
    • 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