Package com.jidesoft.range
Class TimeRange
- java.lang.Object
-
- com.jidesoft.range.AbstractRange<java.util.Date>
-
- com.jidesoft.range.TimeRange
-
public class TimeRange extends AbstractRange<java.util.Date>
Specifies upper and lower bounds for a range of values along a time line.- Author:
- Simon White (swhite@catalysoft.com)
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Date_maxprotected java.util.Date_min-
Fields inherited from interface com.jidesoft.range.Range
PROPERTY_MAX, PROPERTY_MIN
-
-
Constructor Summary
Constructors Constructor Description TimeRange()Sets a default time range of the whole of todayTimeRange(long from, long to)TimeRange(TimeRange timeRange)Constructs a copy of the supplied time rangeTimeRange(java.util.Calendar from, java.util.Calendar to)TimeRange(java.util.Date from, java.util.Date to)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadjust(java.util.Date lower, java.util.Date upper)Adjusts the range.booleancontains(java.util.Date x)Determines whether the supplied point lies within this range.Range<java.util.Date>copy()Range<java.util.Date>createIntermediate(Range<java.util.Date> target, double position)booleanequals(java.lang.Object other)java.util.TimeZonegetTimeZone()inthashCode()java.util.Datelower()doublemaximum()This may be the numeric representation of upper() or it may be rounded up.doubleminimum()This may be the numeric representation of lower() or it may be rounded down.voidsetMax(long to)voidsetMax(java.util.Date to)voidsetMin(long from)voidsetMin(java.util.Date from)voidsetTimeZone(java.util.TimeZone timeZone)doublesize()Compute the size of the rangejava.lang.StringtoString()static TimeRangeunion(TimeRange r1, TimeRange r2)Creates a new TimeRange as the union of two existing TimeRanges.java.util.Dateupper()-
Methods inherited from class com.jidesoft.range.AbstractRange
addPropertyChangeListener, compareTo, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener
-
-
-
-
Constructor Detail
-
TimeRange
public TimeRange()
Sets a default time range of the whole of today
-
TimeRange
public TimeRange(java.util.Calendar from, java.util.Calendar to)
-
TimeRange
public TimeRange(java.util.Date from, java.util.Date to)
-
TimeRange
public TimeRange(long from, long to)
-
TimeRange
public TimeRange(TimeRange timeRange)
Constructs a copy of the supplied time range- Parameters:
timeRange- the timeRange to copy
-
-
Method Detail
-
copy
public Range<java.util.Date> copy()
- Overrides:
copyin classAbstractRange<java.util.Date>
-
setMin
public void setMin(java.util.Date from)
-
setMin
public void setMin(long from)
-
adjust
public void adjust(java.util.Date lower, java.util.Date upper)Description copied from interface:RangeAdjusts the range.- Parameters:
lower- the new smallest value of the rangeupper- the new largest value of the range
-
setMax
public void setMax(java.util.Date to)
-
setMax
public void setMax(long to)
-
minimum
public double minimum()
Description copied from interface:RangeThis may be the numeric representation of lower() or it may be rounded down.- Returns:
- the numeric value of the smallest value to include in the range.
-
maximum
public double maximum()
Description copied from interface:RangeThis may be the numeric representation of upper() or it may be rounded up.- Returns:
- The numeric value of the largest value to include in the range.
-
size
public double size()
Description copied from interface:RangeCompute the size of the range
-
lower
public java.util.Date lower()
- Returns:
- the smallest value of the range
-
upper
public java.util.Date upper()
- Returns:
- the largest value of the range
-
contains
public boolean contains(java.util.Date x)
Description copied from interface:RangeDetermines whether the supplied point lies within this range. For continuous ranges this is interpreted as a pair of inequalities on the supplied value (i.e., min <= x <= max), but for discrete ranges thecontains()method is more like a set membership test.- Returns:
- a boolean to indicate whether the supplied point lies within the range
-
getTimeZone
public java.util.TimeZone getTimeZone()
-
setTimeZone
public void setTimeZone(java.util.TimeZone timeZone)
-
createIntermediate
public Range<java.util.Date> createIntermediate(Range<java.util.Date> target, double position)
- Specified by:
createIntermediatein classAbstractRange<java.util.Date>
-
union
public static TimeRange union(TimeRange r1, TimeRange r2)
Creates a new TimeRange as the union of two existing TimeRanges. The date format of the first time range is retained in the returned result.- Parameters:
r1- the first TimeRanger2- the second TimeRange- Returns:
- the union of the supplied TimeRanges
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-