LimeWire collection component api

org.limewire.collection
Class Range

java.lang.Object
  extended by org.limewire.collection.Range
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
LongInterval

public abstract class Range
extends java.lang.Object
implements java.io.Serializable

An ordered tuple of long values, (low, high).

See Also:
Serialized Form

Field Summary
static long MAX_VALUE
          Maximum value a Range can hold.
 
Constructor Summary
Range()
           
 
Method Summary
static Range createRange(long singleton)
           
static Range createRange(long start, long end)
           
 boolean equals(java.lang.Object o)
           
abstract  long getHigh()
           
 long getLength()
          Returns the length of this range.
abstract  long getLow()
           
 int hashCode()
           
abstract  boolean isLong()
           
 boolean isSubrange(Range other)
           
abstract  byte[] toBytes()
           
abstract  void toBytes(byte[] dest, int offset)
          Places a byte[] representation of this range in the specified array at the specified offset.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_VALUE

public static final long MAX_VALUE
Maximum value a Range can hold.

See Also:
Constant Field Values
Constructor Detail

Range

public Range()
Method Detail

isSubrange

public final boolean isSubrange(Range other)
Returns:
true if this Interval is a "subrange" of the other interval

toBytes

public abstract byte[] toBytes()
Returns:
a byte [] representation of this range. The representation will be 8 bytes if isLong() is false, 10 bytes otherwise.

toBytes

public abstract void toBytes(byte[] dest,
                             int offset)
Places a byte[] representation of this range in the specified array at the specified offset.


getLow

public abstract long getLow()

getHigh

public abstract long getHigh()

createRange

public static Range createRange(long start,
                                long end)
Returns:
a Range with the provided values that will use the least amount of memory.

createRange

public static Range createRange(long singleton)
Returns:
a range (singleton,singleton)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

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

isLong

public abstract boolean isLong()
Returns:
true if this range has values > Integer.MAX_VALUE.

getLength

public long getLength()
Returns the length of this range.


LimeWire collection component api

Copyright © 2009 Lime Wire LLC. All Rights Reserved.