Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.base.stats.bin
Class Interval

java.lang.Object
  extended by com.jivesoftware.base.stats.Bin
      extended by com.jivesoftware.base.stats.bin.Interval
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
ClosedInterval, HalfOpenInterval

public class Interval
extends Bin

Interval is a Bin that represents an open, closed, or half-open interval. The Interval class requires that elements have a working toLong() function.


Constructor Summary
Interval(Element begin, Element end, boolean containsBegin, boolean containsEnd)
          Creates new Interval extending from begin to end.
 
Method Summary
 java.lang.Object clone()
           
 int compareTo(java.lang.Object o)
          Compare the Interval to another Bin (will throw a ClassCastException if o is not a Bin).
 boolean contains(Bin b)
          Determine whether the Interval contains the given Bin.
 boolean contains(Element e)
          Determine whether the Interval contains the given Element.
 boolean containsBegin()
          Test to see if the Interval contains its first element (used to enable us to create open intervals, closed intervals, and half-open intervals).
 boolean containsEnd()
          Test to see if the Interval contains its last element (used to enable us to create open intervals, closed intervals, and half-open intervals).
 boolean equals(java.lang.Object o)
          Determine whether two Intervals are the same.
 Element getBegin()
          Get the first element in the Interval
 Element getEnd()
          Get the last element in the Interval
 int hashCode()
          Provide a suitable hashCode so that Intervals can be used with HashMaps
 java.lang.String toString()
          Convert the Interval to a string.
 
Methods inherited from class com.jivesoftware.base.stats.Bin
getProperty, setProperty
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Interval

public Interval(Element begin,
                Element end,
                boolean containsBegin,
                boolean containsEnd)
Creates new Interval extending from begin to end. The containsBegin and containsEnd flags determine whether the interval contains its endpoints.

Parameters:
begin - The first element in the Interval
end - The last element in the Interval
containsBegin - True if the Interval contains the first element
containsEnd - True if the interval contains the last element
Method Detail

toString

public java.lang.String toString()
Convert the Interval to a string. A square bracket indicates that the interval contains its endpoint, and a parenthesis indicates that the interval does not contain its endpoint. For example, [1,3) is the set of values x such that 1 <= x < 3.

Specified by:
toString in class Bin
See Also:
Object.toString()

contains

public boolean contains(Bin b)
Determine whether the Interval contains the given Bin.

Specified by:
contains in class Bin
Parameters:
b - Bin to be tested
Returns:
true if this Bin contains the given Bin, false otherwise.

contains

public boolean contains(Element e)
Determine whether the Interval contains the given Element.

Specified by:
contains in class Bin
Parameters:
e - Element to be tested

compareTo

public int compareTo(java.lang.Object o)
Compare the Interval to another Bin (will throw a ClassCastException if o is not a Bin). This function is used to keep Bins sorted during the population of a Histogram.

Specified by:
compareTo in interface java.lang.Comparable
Specified by:
compareTo in class Bin
Parameters:
o - Object to be compared to
Returns:
-1 if o < this, 0 if o.equals(this), 1 if o > this
See Also:
Comparable.compareTo(java.lang.Object)

getBegin

public Element getBegin()
Get the first element in the Interval

Specified by:
getBegin in class Bin

containsBegin

public boolean containsBegin()
Test to see if the Interval contains its first element (used to enable us to create open intervals, closed intervals, and half-open intervals).

Specified by:
containsBegin in class Bin
Returns:
True if the Interval contains the element returned by getBegin()

getEnd

public Element getEnd()
Get the last element in the Interval

Specified by:
getEnd in class Bin

containsEnd

public boolean containsEnd()
Test to see if the Interval contains its last element (used to enable us to create open intervals, closed intervals, and half-open intervals).

Specified by:
containsEnd in class Bin
Returns:
True if the Interval contains the element returned by getEnd()

equals

public boolean equals(java.lang.Object o)
Determine whether two Intervals are the same.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Provide a suitable hashCode so that Intervals can be used with HashMaps

Overrides:
hashCode in class java.lang.Object

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.