Methods Summary |
---|
public synchronized void | addEntry(ReportEntry entry)Sets the "id" property of the provided ReportEntry and saves a
copy of the ReportEntry (so that changes to the provided instance
doesn't change the content of the report).
entry.setId(currentEntryId++);
entries.put(new Integer(entry.getId()), new ReportEntry(entry));
|
private java.util.Map | copyEntries()Returns a Map with copies of all entries.
Map copy = new HashMap();
Iterator i = entries.entrySet().iterator();
while (i.hasNext()) {
Map.Entry e = (Map.Entry) i.next();
copy.put(e.getKey(), new ReportEntry((ReportEntry) e.getValue()));
}
return copy;
|
private int | getCurrentEntryId()Returns the current ID value.
return currentEntryId;
|
public synchronized java.util.Date | getEndDate()Returns the report end date.
Date date = null;
if (!entries.isEmpty()) {
List l = getEntriesSortedByDate();
date = ((ReportEntry) l.get(entries.size() - 1)).getDate();
}
return date;
|
public synchronized java.util.List | getEntries()Returns a List with copies of all entries.
return new ArrayList(copyEntries().values());
|
private java.util.List | getEntriesSortedByDate()Returns all entries sorted by date.
List l = getEntries();
Collections.sort(l, new Comparator() {
public int compare(Object o1, Object o2) {
Date d1 = ((ReportEntry) o1).getDate();
Date d2 = ((ReportEntry) o2).getDate();
return d1.compareTo(d2);
}
});
return l;
|
public synchronized ReportEntry | getEntry(int id)Returns a copy of the entry with the specified ID.
return new ReportEntry((ReportEntry) entries.get(new Integer(id)));
|
public synchronized int | getId()Returns the report ID.
return id;
|
public synchronized java.lang.String | getOwner()Returns the report owner.
return owner;
|
public synchronized java.util.Date | getStartDate()Returns the report start date.
Date date = null;
if (!entries.isEmpty()) {
List l = getEntriesSortedByDate();
date = ((ReportEntry) l.get(0)).getDate();
}
return date;
|
public synchronized int | getStatus()Returns the report status.
return status;
|
public synchronized java.lang.String | getTitle()Returns the report title.
return title;
|
public synchronized double | getTotal()Returns the total of all entry amounts.
double total = 0;
Iterator i = entries.values().iterator();
while (i.hasNext()) {
ReportEntry e = (ReportEntry) i.next();
total += e.getAmount();
}
return total;
|
public synchronized void | removeEntry(int id)Removes the entry with the specified ID.
entries.remove(new Integer(id));
|
private void | setCurrentEntryId(int currentEntryId)Sets the current ID value.
this.currentEntryId = currentEntryId;
|
private void | setEntries(java.util.Map entries)Sets the entries.
this.entries = entries;
|
public synchronized void | setId(int id)Sets the report ID.
this.id = id;
|
public synchronized void | setOwner(java.lang.String owner)Sets the report owner.
this.owner = owner;
|
public synchronized void | setStatus(int status)Sets the report status.
this.status = status;
|
public synchronized void | setTitle(java.lang.String title)Sets the report title.
this.title = title;
|
public java.lang.String | toString()Returns a String with all report properties.
return "id: " + id + " title: " + getTitle() +
" owner: " + getOwner() +
" startDate: " + getStartDate() + " endDate: " + getEndDate() +
" status: " + getStatus();
|