anonymizer
Class Interval

java.lang.Object
  extended by anonymizer.Interval

public class Interval
extends java.lang.Object

Data struture for generalized numeric attributes (intervals). Each interval has its high and low value. Inc/exclusiveness of the lower and upper bounds are determined by the incType property. For easy storage, and/or hashing purposes a string representation is included. The string representation consists of low and high values, separated by ":". The boundary conditions are represented mathematically, e.g., [3,4).


Field Summary
 double high
          upper bound of the interval
 int incType
          inclusion type (e.g., [low, high) vs.
 double low
          lower bound of the interval
private  java.lang.String str
          string representation
static int TYPE_ExcLowExcHigh
          lower bound exclusive, upper bound exclusive (e.g., (3,4))
static int TYPE_ExcLowIncHigh
          lower bound exclusive, upper bound inclusive (e.g., (3,4])
static int TYPE_IncLowExcHigh
          lower bound inclusive, upper bound exclusive (e.g., [3,4))
static int TYPE_IncLowIncHigh
          lower bound inclusive, upper bound inclusive (e.g., [3,4])
 
Constructor Summary
Interval(java.lang.String stringRep)
          Class constructor specifying the string representation
 
Method Summary
 boolean compareTo(double d)
          Compares numeric values to intervals
 boolean compareTo(java.lang.String val)
          Compares numeric values to intervals
 boolean contains(Interval that)
          Checks whether one interval contains within itself another interval
 boolean equals(java.lang.Object o)
          String values are parsed to double and checked for inclusion in the interval (returns true if within the interval).
 java.lang.String getPredicate(java.lang.String comparator)
          Builds a predicate that tests for inclusion into this interval.
private  boolean incLowerBound()
           
private  boolean incUpperBound()
           
 boolean isSingleton()
          Singleton intervals are categories assigned integer values (e.g., "[35]" or "[35)").
 Interval[] splitInclusive(double value)
          Splits this interval into two new intervals such that all values <= to the parameter value reside in the first interval and > the parameter value reside in the second interval (e.g., given (3:5] to be split at 4, the result would be (3:4] and (4:5]).
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

low

public double low
lower bound of the interval


high

public double high
upper bound of the interval


str

private java.lang.String str
string representation


incType

public int incType
inclusion type (e.g., [low, high) vs. [low, high])


TYPE_IncLowIncHigh

public static final int TYPE_IncLowIncHigh
lower bound inclusive, upper bound inclusive (e.g., [3,4])

See Also:
Constant Field Values

TYPE_IncLowExcHigh

public static final int TYPE_IncLowExcHigh
lower bound inclusive, upper bound exclusive (e.g., [3,4))

See Also:
Constant Field Values

TYPE_ExcLowIncHigh

public static final int TYPE_ExcLowIncHigh
lower bound exclusive, upper bound inclusive (e.g., (3,4])

See Also:
Constant Field Values

TYPE_ExcLowExcHigh

public static final int TYPE_ExcLowExcHigh
lower bound exclusive, upper bound exclusive (e.g., (3,4))

See Also:
Constant Field Values
Constructor Detail

Interval

public Interval(java.lang.String stringRep)
         throws java.lang.Exception
Class constructor specifying the string representation

Parameters:
stringRep - lower and upper bounds separated by ":" OR a double value
Throws:
java.lang.Exception
Method Detail

compareTo

public boolean compareTo(java.lang.String val)
Compares numeric values to intervals

Parameters:
val - numeric value that can be parsed into a double
Returns:
true if the specified value is within the interval

compareTo

public boolean compareTo(double d)
Compares numeric values to intervals

Parameters:
d - numeric value
Returns:
true if the specified value is within the interval

incLowerBound

private boolean incLowerBound()
Returns:
true if the lower bound is inclusive

incUpperBound

private boolean incUpperBound()
Returns:
true if the upper bound is inclusive

contains

public boolean contains(Interval that)
Checks whether one interval contains within itself another interval

Parameters:
that - an interval object
Returns:
true if this interval contains that interval

isSingleton

public boolean isSingleton()
Singleton intervals are categories assigned integer values (e.g., "[35]" or "[35)").

Returns:
true if singleton, false otherwise

splitInclusive

public Interval[] splitInclusive(double value)
                          throws java.lang.Exception
Splits this interval into two new intervals such that all values <= to the parameter value reside in the first interval and > the parameter value reside in the second interval (e.g., given (3:5] to be split at 4, the result would be (3:4] and (4:5]).

Parameters:
value - boundary of the split
Returns:
two interval resulting from the split
Throws:
java.lang.Exception

getPredicate

public java.lang.String getPredicate(java.lang.String comparator)
Builds a predicate that tests for inclusion into this interval. This function is useful to implement the compareTo function in SQL queries (e.g., given interval [30:40] and attribute name age as comparator, returns "30 <= age, age >= 40")

Parameters:
comparator - Name of the object being compared with the interval
Returns:
String representation of the predicate

equals

public boolean equals(java.lang.Object o)
String values are parsed to double and checked for inclusion in the interval (returns true if within the interval). For Interval objects string representations are compared (returns true if similar).

Overrides:
equals in class java.lang.Object

toString

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