Package org.globus.ftp
Class ByteRange
- java.lang.Object
-
- org.globus.ftp.ByteRange
-
public class ByteRange extends java.lang.Object
Represents a range of integers. The name reflects the fact that it is used with FTP extended mode restart markers, where it represents a range of transfered bytes.
-
-
Field Summary
Fields Modifier and Type Field Description static int
ADJACENT
long
from
lower range limitstatic int
THIS_ABOVE
static int
THIS_BELOW
static int
THIS_SUBSET
static int
THIS_SUPERSET
long
to
upper range limit
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object other)
int
hashCode()
int
merge(ByteRange other)
If this range can be consolidated with the other one, modify this range so that it represents the result of merging this and the other range.java.lang.String
toString()
-
-
-
Field Detail
-
from
public long from
lower range limit
-
to
public long to
upper range limit
-
THIS_BELOW
public static final int THIS_BELOW
- See Also:
- Constant Field Values
-
ADJACENT
public static final int ADJACENT
- See Also:
- Constant Field Values
-
THIS_SUPERSET
public static final int THIS_SUPERSET
- See Also:
- Constant Field Values
-
THIS_SUBSET
public static final int THIS_SUBSET
- See Also:
- Constant Field Values
-
THIS_ABOVE
public static final int THIS_ABOVE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ByteRange
public ByteRange(long from, long to)
- Parameters:
from
- lower range limitto
- upper range limit- Throws:
java.lang.IllegalArgumentException
- if to < from
-
ByteRange
public ByteRange(ByteRange src)
copying constructor
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
- Returns:
- true if both object logically represent the same range (even if they are two separate ByteRange instances)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
merge
public int merge(ByteRange other)
If this range can be consolidated with the other one, modify this range so that it represents the result of merging this and the other range. The parameter object remains intact. Return value indicates what operation has been performed.- If the two ranges were separate, then this range will remain unchanged. The return value will be THIS_BELOW if this range is below the other range, or THIS_ABOVE in the other case.
- If this range was a superset of the other, then this range remains unchanged and THIS_SUPERSET will be returned. A special case of this situation is when both ranges were equal.
- If other range was a superset of this, OTHER_SUPERSET will be returned.
- Otherwise ADJACENT is returned, meaning that merge was possible but no range is a superset of the other.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-