org.apache.sandesha2.util
Class RangeString

java.lang.Object
  extended by org.apache.sandesha2.util.RangeString
All Implemented Interfaces:
java.io.Serializable

public class RangeString
extends java.lang.Object
implements java.io.Serializable

Helper class. Enables conversion to from a list of Range objects to a String representation of that list. Also performs task such as aggregation of ranges

See Also:
Serialized Form

Constructor Summary
RangeString()
          Creates an empty range string
RangeString(java.lang.String s)
          Expects a String of the form [x1,y1][x2,y2]...[xn,yn]
 
Method Summary
 RangeString addRange(Range r)
          Adds the Range into the existing RangeString Any existing Ranges that are encompassed in this new Range are removed.
 java.util.List getContainedElementsAsNumbersList()
          Returns a List of the form [x1,x2,x3....xn] listing each discrete number contained in all of the ranges in order NOTE: inefficient, should be avoided
 Range getRangeForMessageNumber(long messageNumber)
           
 Range[] getRanges()
           
 boolean isMessageNumberInRanges(long messageNumber)
           
 boolean isRangeCompleted(Range interestedRange)
          Returns true if the numbers are contained in a single range
 java.lang.String toString()
          Returns a String representation of the ranges contained in this object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RangeString

public RangeString()
Creates an empty range string


RangeString

public RangeString(java.lang.String s)
Expects a String of the form [x1,y1][x2,y2]...[xn,yn]

Parameters:
s -
Method Detail

isMessageNumberInRanges

public boolean isMessageNumberInRanges(long messageNumber)

getRangeForMessageNumber

public Range getRangeForMessageNumber(long messageNumber)

isRangeCompleted

public boolean isRangeCompleted(Range interestedRange)
Returns true if the numbers are contained in a single range

Parameters:
interestedRange -
Returns:

toString

public java.lang.String toString()
Returns a String representation of the ranges contained in this object

Overrides:
toString in class java.lang.Object
Returns:
a String of the form [x1,y1][x2,y2]...[xn,yn]

getRanges

public Range[] getRanges()
Returns:
ordered array of each range object in the string

getContainedElementsAsNumbersList

public java.util.List getContainedElementsAsNumbersList()
Returns a List of the form [x1,x2,x3....xn] listing each discrete number contained in all of the ranges in order NOTE: inefficient, should be avoided


addRange

public RangeString addRange(Range r)
Adds the Range into the existing RangeString Any existing Ranges that are encompassed in this new Range are removed. Any existing Ranges that are on either side of this Range (i.e. if this Range plugs a gap) are joined. The method returns a RangeString consisting of all the Ranges that were added that were not present previously i.e. all the new Ranges

Parameters:
r -
Returns:


Copyright © 2007 Apache Web Services Project. All Rights Reserved.