Package com.mckoi.database
Class SelectableRangeSet
- java.lang.Object
-
- com.mckoi.database.SelectableRangeSet
-
public final class SelectableRangeSet extends java.lang.Object
Represents a complex normalized range of a list. This is essentially a set of SelectableRange objects that make up a complex view of a range. For example, say we had a query '(a > 10 and a < 20 and a <> 15) or a >= 50', we could represent this range by the following range set;RANGE: AFTER_LAST_VALUE 10, BEFORE_FIRST_VALUE 15 RANGE: AFTER_LAST_VALUE 15, BEFORE_FIRST_VALUE 20 RANGE: FIRST_VALUE 50, LAST_VALUE LAST_IN_SET
The range is constructed by calls to 'intersect', and 'union'.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.ArrayList
range_set
The list of ranges.
-
Constructor Summary
Constructors Constructor Description SelectableRangeSet()
Constructs the SelectableRangeSet to a full range (a range that encompases all values).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static SelectableRange
changeRangeSizeToEncompass(SelectableRange range1, SelectableRange range2)
Alters the first range so it encompasses the second range.void
intersect(Operator op, TObject val)
Intersects this range with the given Operator and value constraint.private static SelectableRange
intersectRange(SelectableRange range, Operator op, TObject val, boolean null_check)
Intersects the given SelectableRange object with the given Operator and value constraint.static void
main(java.lang.String[] args)
A test application.private static boolean
rangeIntersectedBy(SelectableRange range1, SelectableRange range2)
Returns true if the two SelectableRange ranges intersect.SelectableRange[]
toSelectableRangeArray()
Returns the range as an array of SelectableRange or an empty array if there is no range.java.lang.String
toString()
Outputs this range as a string, for diagnostic and testing purposes.void
union(Operator op, TObject val)
Unions this range with the given Operator and value constraint.void
union(SelectableRangeSet union_to)
Unions the current range set with the given range set.
-
-
-
Method Detail
-
intersectRange
private static SelectableRange intersectRange(SelectableRange range, Operator op, TObject val, boolean null_check)
Intersects the given SelectableRange object with the given Operator and value constraint.NOTE: This does not work with the '<>' operator which must be handled another way.
-
rangeIntersectedBy
private static boolean rangeIntersectedBy(SelectableRange range1, SelectableRange range2)
Returns true if the two SelectableRange ranges intersect.
-
changeRangeSizeToEncompass
private static SelectableRange changeRangeSizeToEncompass(SelectableRange range1, SelectableRange range2)
Alters the first range so it encompasses the second range. This assumes that range1 intersects range2.
-
intersect
public void intersect(Operator op, TObject val)
Intersects this range with the given Operator and value constraint. For example, if a range is 'a' -> [END] and the given operator is '<=' and the value is 'z' the result range is 'a' -> 'z'.
-
union
public void union(Operator op, TObject val)
Unions this range with the given Operator and value constraint.
-
union
public void union(SelectableRangeSet union_to)
Unions the current range set with the given range set.
-
toSelectableRangeArray
public SelectableRange[] toSelectableRangeArray()
Returns the range as an array of SelectableRange or an empty array if there is no range.
-
toString
public java.lang.String toString()
Outputs this range as a string, for diagnostic and testing purposes.- Overrides:
toString
in classjava.lang.Object
-
main
public static void main(java.lang.String[] args)
A test application.
-
-