Package io.milton.zsync
Class RelocateRange
java.lang.Object
io.milton.zsync.RelocateRange
An object consisting of a
Range and a long offset.
A RelocateRange is an instruction sent as part of a ZSync PUT upload,
which informs the server of the new offset of a single range of blocks from the original file. The String
format for this object as it appears in the upload is currently "A-B/C", where A-B
indicates the block range starting at A and ending at B-1, and C represents the location
of this sequence of blocks in the updated (client-side) file.- Author:
- Nick
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRelocateRange(Range range, long offset) Constructs a RelocateRange from a Range and offset. -
Method Summary
Modifier and TypeMethodDescriptionReturns the range of blocks to be relocated.longReturns the byte position to which the Range should be relocated.Returns a String representing this object, e.g. "10-20/1234", ready to be inserted into a ZSync PUT upload request.static RelocateRangeConstructs and returns a RelocateRange object from the input String.toString()Returns a String description of this object, not meant to be inserted into a ZSync PUT.
-
Field Details
-
DIV
The String separating the Range from the offset in the String representation of this object.- See Also:
-
-
Constructor Details
-
RelocateRange
Constructs a RelocateRange from a Range and offset. The object is immutable; the fields cannot be changed after construction.- Parameters:
range- A range of block indices in the remote fileoffset- The new byte position of range
-
-
Method Details
-
toString
Returns a String description of this object, not meant to be inserted into a ZSync PUT. For the proper PUT formatting, usegetRelocation() -
getRelocation
Returns a String representing this object, e.g. "10-20/1234", ready to be inserted into a ZSync PUT upload request.- Returns:
- A String representing this object
-
parse
Constructs and returns a RelocateRange object from the input String. The String should be in the format A-B/C. Note: Leading and trailing whitespaces in the argument are ignored, but there should be no spaces between the non-ws chars.- Parameters:
relocString- The String to be parsed- Returns:
- The RelocateRange object corresponding to relocString
- Throws:
ParseException- If the format of the input String is incorrect or the numbers cannot be properly parsed
-
getBlockRange
Returns the range of blocks to be relocated.The numbers in the Range are indices of the blocks in the server's copy of the file. The Range consists of the pair (firstBlock, lastBlock + 1).
- Returns:
- A Range object containing the block range
-
getOffset
public long getOffset()Returns the byte position to which the Range should be relocated.- Returns:
- The new offset of the Range
-