01: /*--------------------------------------------------------------------------*
02: | Copyright (C) 2006 Christopher Kohlhaas |
03: | |
04: | This program is free software; you can redistribute it and/or modify |
05: | it under the terms of the GNU General Public License as published by the |
06: | Free Software Foundation. A copy of the license has been included with |
07: | these distribution in the COPYING file, if not go to www.fsf.org |
08: | |
09: | As a special exception, you are granted the permissions to link this |
10: | program with every library, which license fulfills the Open Source |
11: | Definition as published by the Open Source Initiative (OSI). |
12: *--------------------------------------------------------------------------*/
13: package org.rapla.entities.domain;
14:
15: import java.util.*;
16:
17: import org.rapla.entities.Entity;
18: import org.rapla.entities.Named;
19: import org.rapla.entities.RaplaObject;
20: import org.rapla.entities.RaplaType;
21:
22: /**
23: Most universities and schools are planning for fixed periods/terms
24: rather than arbitrary dates. Rapla provides support for this periods.
25: */
26: public interface Period extends Entity, RaplaObject, Comparable, Named {
27: final RaplaType TYPE = new RaplaType(Period.class, "period");
28:
29: Date getStart();
30:
31: Date getEnd();
32:
33: int getWeeks();
34:
35: String getName();
36:
37: void setStart(Date start);
38:
39: void setEnd(Date end);
40:
41: void setName(String name);
42:
43: boolean contains(Date date);
44:
45: /** returns the week of the specified date relative to the period.
46: @throws NoSuchElementException if the period doesn't contain the date
47: */
48: int weekOf(Date date);
49:
50: String toString();
51:
52: /** compares the period to a date.
53: Compares endDates with date.
54: If dates are equal 1 will be returned:
55: The date is before the endDate and therefore in the period.
56: */
57: int compareTo(Date date);
58:
59: /** compares the period to another period.
60: First compares startDates and if they are equal
61: compares endDates. If endDates are equal the hashValues, names
62: or some other unique value should be compared to ensure:
63: equals() is true <=> compareTo() returns 0;
64: */
65: int compareTo(Period period);
66:
67: /** compares the period to another period or a date object.
68: @see #compareTo(Date)
69: @see #compareTo(Period)
70: */
71: int compareTo(Object object);
72:
73: public static Period[] PERIOD_ARRAY = new Period[0];
74: }
|