org.ofbiz.service.calendar
Class TemporalExpression

java.lang.Object
  extended by org.ofbiz.service.calendar.TemporalExpression
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<TemporalExpression>
Direct Known Subclasses:
RecurrenceInfo.RecurrenceWrapper, TemporalExpressions.DateRange, TemporalExpressions.DayInMonth, TemporalExpressions.DayOfMonthRange, TemporalExpressions.DayOfWeekRange, TemporalExpressions.Difference, TemporalExpressions.Frequency, TemporalExpressions.Intersection, TemporalExpressions.MonthRange, TemporalExpressions.Null, TemporalExpressions.TimeOfDayRange, TemporalExpressions.Union

public abstract class TemporalExpression
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable<TemporalExpression>

Temporal expression abstract class.

See Also:
Serialized Form

Field Summary
protected  java.lang.String id
          A unique ID for this expression.
protected  int sequence
          Field used to sort expressions.
protected  int subSequence
          Field used to sort expressions.
 
Constructor Summary
protected TemporalExpression()
           
 
Method Summary
abstract  void accept(TemporalExpressionVisitor visitor)
          Handles a TemporalExpressionVisitor visit.
 int compareTo(TemporalExpression obj)
           
protected  boolean containsExpression(TemporalExpression expression)
           
abstract  java.util.Calendar first(java.util.Calendar cal)
          Returns a date representing the first occurrence of this expression on or after a specified date.
 java.lang.String getId()
          Returns this expression's ID.
 java.util.Set<java.util.Date> getRange(DateRange range, java.util.Calendar cal)
          Returns a range of dates matching this expression.
abstract  boolean includesDate(java.util.Calendar cal)
          Returns true if this expression includes the specified date.
abstract  java.util.Calendar next(java.util.Calendar cal)
          Returns a date representing the next occurrence of this expression after a specified date.
 void setId(java.lang.String id)
          Sets this expression's ID.
protected  java.util.Calendar setStartOfDay(java.util.Calendar cal)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sequence

protected int sequence
Field used to sort expressions. Expression evaluation depends on correct ordering. Expressions are evaluated from lowest value to highest value.


subSequence

protected int subSequence
Field used to sort expressions. Expression evaluation depends on correct ordering. Expressions are evaluated from lowest value to highest value.


id

protected java.lang.String id
A unique ID for this expression. This field is intended to be used by persistence classes.

Constructor Detail

TemporalExpression

protected TemporalExpression()
Method Detail

includesDate

public abstract boolean includesDate(java.util.Calendar cal)
Returns true if this expression includes the specified date.

Parameters:
cal - A date to evaluate
Returns:
true if this expression includes the date represented by cal

first

public abstract java.util.Calendar first(java.util.Calendar cal)
Returns a date representing the first occurrence of this expression on or after a specified date. Returns null if there is no matching date.

Parameters:
cal - A date to evaluate
Returns:
A Calendar instance representing the first matching date, or null if no matching date is found

next

public abstract java.util.Calendar next(java.util.Calendar cal)
Returns a date representing the next occurrence of this expression after a specified date. Returns null if there is no matching date.

Parameters:
cal - A date to evaluate
Returns:
A Calendar instance representing the first matching date, or null if no matching date is found

accept

public abstract void accept(TemporalExpressionVisitor visitor)
Handles a TemporalExpressionVisitor visit.

Parameters:
visitor -

compareTo

public int compareTo(TemporalExpression obj)
Specified by:
compareTo in interface java.lang.Comparable<TemporalExpression>

getRange

public java.util.Set<java.util.Date> getRange(DateRange range,
                                              java.util.Calendar cal)
Returns a range of dates matching this expression. Returns an empty Set if no dates are found.

Parameters:
range - The range of dates to evaluate
cal - The starting date
Returns:
A Set of matching Date objects

getId

public java.lang.String getId()
Returns this expression's ID.

Returns:
Expression ID String

setId

public void setId(java.lang.String id)
Sets this expression's ID.

Parameters:
id - Expression ID String

containsExpression

protected boolean containsExpression(TemporalExpression expression)

setStartOfDay

protected java.util.Calendar setStartOfDay(java.util.Calendar cal)