Class DataRange

java.lang.Object
io.milton.zsync.DataRange

public class DataRange extends Object
An object consisting of a Range and a stream of bytes. If the number of bytes is beyond a certain threshold, the data is stored in a temporary file; otherwise, it is just stored in an array.
Author:
Nick
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Once more than threshold bytes are written to data, the backing store is switched from a byte array to a temporary file
  • Constructor Summary

    Constructors
    Constructor
    Description
    DataRange(Range range, InputStream instream)
    Sets the range equal to the specified Range and pulls a number of bytes from the InputStream equal to the size of the range
    DataRange(Range range, RandomAccessFile randAccess)
    Sets the range to the specified Range and seeks to the beginning of the range in the RandomAccessFile before copying bytes
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the stream of bytes.
    long
    Returns the length of the Range (and the number of bytes in the byte stream)
     
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • threshold

      public static final int threshold
      Once more than threshold bytes are written to data, the backing store is switched from a byte array to a temporary file
      See Also:
  • Constructor Details

    • DataRange

      public DataRange(Range range, InputStream instream) throws IOException
      Sets the range equal to the specified Range and pulls a number of bytes from the InputStream equal to the size of the range
      Parameters:
      range - A Range object specifying the target location of the byte stream
      instream - A stream from which the data portion will be pulled
      Throws:
      IOException
    • DataRange

      public DataRange(Range range, RandomAccessFile randAccess) throws IOException
      Sets the range to the specified Range and seeks to the beginning of the range in the RandomAccessFile before copying bytes
      Parameters:
      range -
      randAccess -
      Throws:
      IOException
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getRange

      public Range getRange()
    • getInputStream

      public InputStream getInputStream()
      Returns the stream of bytes. If a temporary file is used to store data, it will be deleted when the returned stream is closed.
      Returns:
      The byte stream corresponding to range
    • getLength

      public long getLength()
      Returns the length of the Range (and the number of bytes in the byte stream)
      Returns: