de.jaret.util.date
Class IntervalImpl

java.lang.Object
  extended by de.jaret.util.misc.PropertyObservableBase
      extended by de.jaret.util.date.IntervalImpl
All Implemented Interfaces:
Interval, PropertyObservable, PropertyChangeListener, EventListener
Direct Known Subclasses:
Event

public class IntervalImpl
extends PropertyObservableBase
implements Interval, PropertyChangeListener

Simple Implementation of an interval. Listens on property changes on the begin and end date. However it is better practice to use the JaretDate like an immutable type most of the time.

Version:
$Id: IntervalImpl.java 845 2009-02-22 18:28:44Z kliem $
Author:
Peter Kliem

Field Summary
protected  JaretDate _begin
          begin date.
protected  JaretDate _end
          end date.
 
Fields inherited from class de.jaret.util.misc.PropertyObservableBase
_propertyChangeSupport
 
Fields inherited from interface de.jaret.util.date.Interval
PROP_BEGIN, PROP_END
 
Constructor Summary
IntervalImpl()
          Default constructor leaving the interval uninitialized.
IntervalImpl(JaretDate from, JaretDate to)
          Construct a date with begin and end.
 
Method Summary
 boolean contains(Interval interval)
          Checks whether an interval is completely contained in the interval.
 boolean contains(JaretDate date)
          Checks whether a given date is contained in the interval.
static boolean containsNonIncluding(Interval interval, JaretDate date)
          Check whether a given date is contained in the interval not including the exact boundaries.
static boolean containsStatic(Interval interval, JaretDate date)
          Static helper, check whether a dat eis included in an interval.
 JaretDate getBegin()
          Retrieve the begin timestamp of the interval.
 JaretDate getEnd()
          Retrieve the end timestamp of the interval.
 int getSeconds()
          Retrieve the length of the interval in seconds.
static boolean intersect(Interval i1, Interval i2)
          Helper method determing if two intervals intersect.
static boolean intersectNonIncluding(Interval i1, Interval i2)
          Static helper method, check intersection not including the interval edges.
 boolean intersects(Interval interval)
          Check whether this intersects the given interval.
 void propertyChange(PropertyChangeEvent evt)
           check begin and end instances.
 void setBegin(JaretDate begin)
          Set the begin timestamp of the interval.
 void setEnd(JaretDate end)
          Set the end timestamp of the interval.
 String toString()
          
 
Methods inherited from class de.jaret.util.misc.PropertyObservableBase
addPropertyChangeListener, firePropertyChange, isRealModification, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.jaret.util.misc.PropertyObservable
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

_begin

protected JaretDate _begin
begin date.


_end

protected JaretDate _end
end date.

Constructor Detail

IntervalImpl

public IntervalImpl(JaretDate from,
                    JaretDate to)
Construct a date with begin and end.

Parameters:
from - begin date (will be copied)
to - end date (will be copied)

IntervalImpl

public IntervalImpl()
Default constructor leaving the interval uninitialized.

Method Detail

getBegin

public JaretDate getBegin()
Retrieve the begin timestamp of the interval.

Specified by:
getBegin in interface Interval
Returns:
the begin timestamp of the interval.

getEnd

public JaretDate getEnd()
Retrieve the end timestamp of the interval.

Specified by:
getEnd in interface Interval
Returns:
the end timestamp of the interval.

setBegin

public void setBegin(JaretDate begin)
Set the begin timestamp of the interval.

Specified by:
setBegin in interface Interval
Parameters:
begin - the begin timestamp to be set.

setEnd

public void setEnd(JaretDate end)
Set the end timestamp of the interval.

Specified by:
setEnd in interface Interval
Parameters:
end - the end timestamp to be set.

contains

public boolean contains(JaretDate date)
Checks whether a given date is contained in the interval.

Specified by:
contains in interface Interval
Parameters:
date - date to be checked
Returns:
true if the date is included in the interval

contains

public boolean contains(Interval interval)
Checks whether an interval is completely contained in the interval.

Specified by:
contains in interface Interval
Parameters:
interval - interval to check
Returns:
true if the interval is completely contained in the interval

containsStatic

public static boolean containsStatic(Interval interval,
                                     JaretDate date)
Static helper, check whether a dat eis included in an interval.

Parameters:
interval - interval
date - date to check for inclusion
Returns:
true if date is contained in interval

getSeconds

public int getSeconds()
Retrieve the length of the interval in seconds.

Specified by:
getSeconds in interface Interval
Returns:
length of the interval in seconds

toString

public String toString()

Overrides:
toString in class Object

intersects

public boolean intersects(Interval interval)
Check whether this intersects the given interval.

Specified by:
intersects in interface Interval
Parameters:
interval - interval to be checked for intersection.
Returns:
true if an intersection exists, false otherwise

intersect

public static boolean intersect(Interval i1,
                                Interval i2)
Helper method determing if two intervals intersect.

Parameters:
i1 - interval1
i2 - interval2
Returns:
true if i1 and i2 intersect

intersectNonIncluding

public static boolean intersectNonIncluding(Interval i1,
                                            Interval i2)
Static helper method, check intersection not including the interval edges.

Parameters:
i1 - interval 1
i2 - interval 2
Returns:
true if the intervals intersect

containsNonIncluding

public static boolean containsNonIncluding(Interval interval,
                                           JaretDate date)
Check whether a given date is contained in the interval not including the exact boundaries.

Parameters:
interval - interval
date - date to be checked
Returns:
true if the date is inside the interval

propertyChange

public void propertyChange(PropertyChangeEvent evt)
check begin and end instances.

Specified by:
propertyChange in interface PropertyChangeListener


Copyright © 2013. All Rights Reserved.