|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectch.sahits.game.openpatrician.model.Date
public class Date
Representation of the date within the game. This class is thread safe. The Date is implemented as a singleton. However there is no getInstance method to retrieve the once created instance, so it must be referenced elsewhere.
| Field Summary | |
|---|---|
private Calendar |
cal
Current date |
private static Date |
instance
This instance |
private CopyOnWriteArrayList<IClockUpdateListener> |
listeners
|
private static Object |
lock
Lock for guaranteeing thread safty |
private ResourceBundle |
messages
|
private int |
startYear
Start year |
private int |
update
Tick update in minutes |
| Constructor Summary | |
|---|---|
(package private) |
Date(Calendar cal)
Constructor for testing purposes only |
private |
Date(int year)
Initialize the date with start year. |
| Method Summary | |
|---|---|
void |
add(IClockUpdateListener listener)
Add a new listener that should be updated |
Calendar |
getCurrentDate()
Retrieve a copy of the current date |
String |
getEndOfWeek()
Retrieve the date of the end of the week in the form {Day of month}. |
(package private) Calendar |
getEndOfWeekInternal()
Retrieve the date of the of the Sunday of last week |
static Date |
getInstance(int year)
Retrieve the singleton instance of the date. |
String |
getStartOfWeek()
Retrieve the date of the start of the week in the form {Day of month}. |
(package private) Calendar |
getStartOfWeekInternal()
Retrieve the date of the start of the last week |
int |
getStartYear()
Retrieve the start year |
int |
getUpdateInterval()
Retrieve the update interval |
int |
getWeekdayIndex()
Retrieve an index for the current weekday. |
void |
notifyTick()
Notify all registered listeners of a clock tick |
void |
notifyTickUpdate()
Notify all registered listeners of the change in update tick size in minutes |
void |
remove(IClockUpdateListener listener)
Remove a listener from the queue |
void |
setTickUpdate(int minutes)
Set the tick update in number of minutes |
void |
tick()
Update the time by one tick. |
String |
toDisplayString()
Create a string representation for the user interface of the form {Day of month}. |
String |
todisplayString(int day,
int month,
int year)
|
private String |
toShortDate(Calendar c)
Convert the date into the form {Day in month}. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private int update
private final Calendar cal
private final int startYear
private static Date instance
private static Object lock
private CopyOnWriteArrayList<IClockUpdateListener> listeners
private ResourceBundle messages
| Constructor Detail |
|---|
private Date(int year)
Date(Calendar cal)
cal - | Method Detail |
|---|
public static Date getInstance(int year)
year -
public void tick()
public void setTickUpdate(int minutes)
minutes - tick updatepublic int getStartYear()
public String getStartOfWeek()
Calendar getStartOfWeekInternal()
private String toShortDate(Calendar c)
c -
public String getEndOfWeek()
Calendar getEndOfWeekInternal()
public String toDisplayString()
public String todisplayString(int day,
int month,
int year)
public void add(IClockUpdateListener listener)
IClockUpdateListenable
add in interface IClockUpdateListenablepublic void remove(IClockUpdateListener listener)
IClockUpdateListenable
remove in interface IClockUpdateListenablepublic void notifyTick()
IClockUpdateListenable
notifyTick in interface IClockUpdateListenablepublic void notifyTickUpdate()
IClockUpdateListenable
notifyTickUpdate in interface IClockUpdateListenablepublic Calendar getCurrentDate()
public final int getUpdateInterval()
public final int getWeekdayIndex()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||