|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.blinkenbyte.io.BlockRange
public class BlockRange
This class represents a mutable block range, specified by a starting block number, and the length of the run. It provides methods to combine and remove blocks individually and as a list, and to read and write lists from a Reader/Writer.
Constructor Summary | |
---|---|
BlockRange(long _blockNumber,
long _blockLength)
Constructs a new BlockRange. |
Method Summary | |
---|---|
void |
absorb(BlockRange bp)
Extends the range of this BlockRange to include the specified block. |
static void |
coalesce(java.util.List<BlockRange> list)
Coalesces a list of BlockRange objects. |
int |
compareTo(BlockRange bp)
Compares the starting block of this BlockRange to the specified BlockRange. |
int |
compareToBlockNumber(long n)
Compares a block number to this range. |
boolean |
contains(BlockRange bp)
Returns true if the specified BlockRange is fully contained within this BlockRange. |
long |
getBlockLength()
Returns the number of blocks represented by this object. |
long |
getBlockNumber()
Returns the starting block number represented by this object. |
long |
getEndBlockNumber()
Returns the ending block number encompassed by this range. |
java.lang.String |
getLine()
Returns a string representation of this BlockRange as it would be read or written from a Reader/Writer. |
boolean |
isBlockInRange(long n)
Returns whether a given block number is in the range covered by this object. |
boolean |
isContiguousWith(BlockRange bp)
Returns true if the union of this BlockRange with the specified BlockRange is a single continuous block. |
boolean |
isOverlapping(BlockRange bp)
Returns true if the intersection of this BlockRange with the specified BlockRange is not empty. |
static java.util.ArrayList<BlockRange> |
readList(java.io.Reader r)
Reads a list of block ranges in a format that can be read by readList. |
static void |
readList(java.io.Reader r,
java.util.List<BlockRange> list)
Reads a list of block ranges in a format that can be read by readList, and appends them to the specified list. |
BlockRange[] |
remove(BlockRange bp)
Removes a range of blocks from this BlockRange, and returns the resulting BlockRange(s). |
java.lang.String |
toString()
Returns a string representation of this BlockRange |
BlockRange |
union(BlockRange bp)
Returns a new block that represents a union of this BlockRange and the specified BlockRange. |
static void |
writeList(java.util.List<BlockRange> list,
java.io.Writer w)
Writes out a list of blocks in a format that can be read by readList. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BlockRange(long _blockNumber, long _blockLength)
_blockNumber
- The starting block number._blockLength
- The number of blocks.Method Detail |
---|
public long getBlockNumber()
public long getBlockLength()
public long getEndBlockNumber()
public boolean isBlockInRange(long n)
public int compareToBlockNumber(long n)
public boolean contains(BlockRange bp)
public boolean isContiguousWith(BlockRange bp)
public boolean isOverlapping(BlockRange bp)
public void absorb(BlockRange bp)
public BlockRange union(BlockRange bp)
public BlockRange[] remove(BlockRange bp)
public int compareTo(BlockRange bp)
compareTo
in interface java.lang.Comparable<BlockRange>
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getLine()
public static void coalesce(java.util.List<BlockRange> list)
public static void writeList(java.util.List<BlockRange> list, java.io.Writer w) throws java.io.IOException
java.io.IOException
public static java.util.ArrayList<BlockRange> readList(java.io.Reader r) throws java.lang.Exception
java.lang.Exception
public static void readList(java.io.Reader r, java.util.List<BlockRange> list) throws java.lang.Exception
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |