org.globus.ftp
Class ByteRangeList

java.lang.Object
  extended by org.globus.ftp.ByteRangeList
All Implemented Interfaces:
RestartData

public class ByteRangeList
extends java.lang.Object
implements RestartData

Represents list of ranges of integers (ByteRange objects). The name reflects the fact that in FTP extended mode restart markers, such structure represent a list of ranges of transfered bytes. The list has following characteristic:

You cannot just add new ranges to the list, because that would violate the contract above. New ranges can be merge()d to the list.

See Also:
GridFTPRestartMarker

Field Summary
protected  java.util.Vector vector
          vector of ByteRanges.
 
Constructor Summary
ByteRangeList()
           
 
Method Summary
 boolean equals(java.lang.Object other)
           
 int hashCode()
           
 void merge(ByteRange range)
          Merge a copy of the given ByteRange into this list.
 void merge(ByteRangeList other)
          Merge into this list all the ranges contained in the given ByteRangeList using merge(ByteRange).
 void merge(java.util.Vector other)
          Merge into this list all the ranges contained in the given vector using merge(ByteRange).
 java.lang.String toFtpCmdArgument()
          convert this object to a String, in the format of argument of REST GridFTP command, for instance: "0-29,32-89" The resulting String will preserve the features of ByteRangeList: (1) order and (2) separation
 java.util.Vector toVector()
          convert this object to a vector of ByteRanges.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vector

protected java.util.Vector vector
vector of ByteRanges. It is guaranteed that any two ranges are not adjacent to each other, nor have a common subset. They are unordered, however.

Constructor Detail

ByteRangeList

public ByteRangeList()
Method Detail

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object
Returns:
true if this list logically represents the same range list, although the object instances may be different.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

merge

public void merge(ByteRange range)
Merge a copy of the given ByteRange into this list. The resulting range list will represent all the integers represented so far, plus the integers represented by the new range. The resulting list will be stored in this object, while the parameter object will remain intact. For instance:


merge

public void merge(java.util.Vector other)
Merge into this list all the ranges contained in the given vector using merge(ByteRange).

Parameters:
other - the Vector of ByteRange objects

merge

public void merge(ByteRangeList other)
Merge into this list all the ranges contained in the given ByteRangeList using merge(ByteRange). The parameter object remains intact.

Parameters:
other - the ByteRangeList to be merged into this

toVector

public java.util.Vector toVector()
convert this object to a vector of ByteRanges. The resulting vector will preserve the features of ByteRangeList: (1) order and (2) separation. Subsequent calls of this method will return the same Vector object.


toFtpCmdArgument

public java.lang.String toFtpCmdArgument()
convert this object to a String, in the format of argument of REST GridFTP command, for instance: "0-29,32-89" The resulting String will preserve the features of ByteRangeList: (1) order and (2) separation

Specified by:
toFtpCmdArgument in interface RestartData
Returns:
the restart data in the format of REST command argument. For instance (in GridFTP) "4-50,62-75"


Copyright © 2013. All Rights Reserved.