Class FileData

  • All Implemented Interfaces:
    Data

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

      Fields 
      Modifier and Type Field Description
      private DataFile file  
      private int length  
      private long pointer  
    • Constructor Summary

      Constructors 
      Constructor Description
      FileData​(DataFile file, long pointer, int length)  
      FileData​(DataFile file, java.nio.ByteBuffer buf)  
    • 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

      • pointer

        private final long pointer
      • length

        private final int length
    • Constructor Detail

      • FileData

        FileData​(DataFile file,
                 java.nio.ByteBuffer buf)
      • FileData

        FileData​(DataFile file,
                 long pointer,
                 int length)
    • Method Detail

      • 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,
                               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 - start of the linked list of data objects
        buf - contains partial content for a part
        Returns:
        Data