Package io.milton.zsync
Class DataRange
java.lang.Object
io.milton.zsync.DataRange
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
FieldsModifier and TypeFieldDescriptionstatic final intOnce more thanthresholdbytes are written to data, the backing store is switched from a byte array to a temporary file -
Constructor Summary
ConstructorsConstructorDescriptionDataRange(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 rangeDataRange(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
-
Field Details
-
threshold
public static final int thresholdOnce more thanthresholdbytes are written to data, the backing store is switched from a byte array to a temporary file- See Also:
-
-
Constructor Details
-
DataRange
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 streaminstream- A stream from which the data portion will be pulled- Throws:
IOException
-
DataRange
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
-
getRange
-
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:
-