summaryrefslogtreecommitdiff
path: root/sources/shared
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shared')
-rw-r--r--sources/shared/CalendarCategory.java408
-rw-r--r--sources/shared/CalendarEvent.java648
-rw-r--r--sources/shared/Config.java412
-rw-r--r--sources/shared/DoCallback.java6
-rw-r--r--sources/shared/Main.java216
-rw-r--r--sources/shared/MyDate.java88
-rw-r--r--sources/shared/MyVector.java24
-rw-r--r--sources/shared/remotecall/ClientRequest.java704
-rw-r--r--sources/shared/remotecall/RemoteCall.java34
-rw-r--r--sources/shared/remotecall/ServerResponse.java76
10 files changed, 1328 insertions, 1288 deletions
diff --git a/sources/shared/CalendarCategory.java b/sources/shared/CalendarCategory.java
index 94c215c..1e686d7 100644
--- a/sources/shared/CalendarCategory.java
+++ b/sources/shared/CalendarCategory.java
@@ -1,3 +1,7 @@
+/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow
+ * http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+ */
+
/**
*
*/
@@ -18,206 +22,206 @@ import shared.remotecall.*;
*
*/
public class CalendarCategory {
- private Vector vecEvents;
- private String sCategoryName;
- private boolean bHasChanged = false;
- private File categoryFile;
-
- /**
- * Creates a new calendar category object and sets the categorie's name to the filename of the category.
- * @param categoryFile The file object which contains the unparsed events for this specific category. It will be unset after parsing.
- */
- public CalendarCategory(File categoryFile) {
- this.categoryFile = categoryFile;
- this.sCategoryName = categoryFile.getName();
-
- // sCategoryName is now "calendar.Name", remove now the leading 'calendar.'
- sCategoryName = sCategoryName.substring(sCategoryName.indexOf('.') + 1);
- }
-
- /**
- * Creates a new calendar category object and sets the categorie's File to the name of the category.
- * @param sCategoryName Specifies the categorie's name.
- */
- public CalendarCategory(String sCategoryName) {
- this.sCategoryName = sCategoryName;
- }
-
- /**
- * This method sets the categorie's initial events.
- * @param vecEvents Specifies the categorie's events.
- */
- public void setEvents(Vector vecEvents) {
- this.vecEvents = vecEvents;
- }
-
- /**
- * This method adds an event to the category.
- * @param event Specifies the calendar event to add to this category.
- */
- public void addEvent(CalendarEvent event) {
- if (vecEvents == null)
- vecEvents = new Vector();
-
- vecEvents.add(event);
- }
-
- /**
- * This method returns the calendar events file object.
- * @return Returns the categorie's file object.
- */
- public File getFile() {
- return categoryFile;
- }
-
- /**
- * This method Sets the categories file handle to null. This is done if all the data has been read from
- * the file database.
- */
- public void unsetFile() {
- categoryFile = null;
- }
-
- /**
- * This method returns the categorie's name.
- * @return Returns the categorie's name.
- */
- public String getName() {
- return sCategoryName;
- }
-
- /**
- * This method sets the categorie's name.
- */
- public void setName(String sCategoryName) {
- if (this.sCategoryName.equals(sCategoryName))
- return;
-
- deleteDatabaseFile();
- this.sCategoryName = sCategoryName;
- categoryFile = new File(Config.getStringValue("server_database_dir")+"/calendar."+sCategoryName);
- setHasChanged(true);
- }
-
- /**
- * This method deletes the database file of this event.
- */
- public void deleteDatabaseFile() {
- if (categoryFile == null)
- categoryFile = new File(Config.getStringValue("server_database_dir")+"/calendar."+getName());
-
- Main.infoMessage("Removing " + categoryFile.getPath());
- categoryFile.delete();
- }
-
- /**
- * This method returns the categorie's events.
- * @return Returns a Vector of all CalendarEvent objects.
- */
- public Vector getEvents() {
- return vecEvents;
- }
-
- /**
- * This method looks for all calendar events of this category which matches a given client's request.
- * @param clientRequest Specifies the client request sent by the calendar client.
- * @return Returns a Vector of all matching CalendarEvent objects.
- */
- public Vector getMatchingEvents(ClientRequest clientRequest) {
- Vector vecMatching = new Vector();
- int iNumEventsToRequest = clientRequest.getNumEventsToRequest();
-
- Enumeration enumEvents = vecEvents.elements();
- while (enumEvents.hasMoreElements()) {
- CalendarEvent event = (CalendarEvent) enumEvents.nextElement();
- if (clientRequest.match(event))
- vecMatching.add(event);
-
- if (iNumEventsToRequest > -1 && iNumEventsToRequest == vecMatching.size())
- break;
- }
-
- return vecMatching;
- }
-
- /**
- * This method checks the current category's name against a regular expression pattern.
- * @param pattern Specifies the pattern to be used.
- * @return Returns true if the event matches, else false will be returned.
- */
- public boolean matchesName(Pattern pattern) {
- if (pattern == null)
- return false;
-
- return pattern.matcher(getName()).find();
- }
-
- /**
- * This method removes a given event from its event vector.
- * @param event Specifies the calendar event object to be removed from this category
- */
- public void removeEvent(CalendarEvent event) {
- getEvents().removeElement(event);
- }
-
- /**
- * This method lets you check if the calendar category has been modified/changed by a
- * calendar client request. This is needed by the CalendarDatabase.flush method, to write all
- * the changes back to the database files.
- * @return Returns true if the category has changed, else it will return false.
- */
- public boolean hasChanged() {
- return bHasChanged;
- }
-
- /**
- * This method merges two categories.
- * @param calendarCategory Specifies the category to merge with.
- */
- public void merge(CalendarCategory calendarCategory) {
- Enumeration enumEvents = calendarCategory.getEvents().elements();
- while (enumEvents.hasMoreElements())
- vecEvents.add(enumEvents.nextElement());
-
- System.out.println(vecEvents);
- }
-
- /**
- * This method specifies if the calendar category has been modified/changed or not.
- * @param bHasChanged Specifies if the category has been modified/changed or not.
- */
- public void setHasChanged(boolean bHasChanged) {
- this.bHasChanged = bHasChanged;
- }
-
- /**
- * This method flushes the calendar category to the database at the filesystem.
- */
- public void flush() {
- Main.infoMessage("Flushing category " + getName() + " to database!");
-
- if (vecEvents.size() == 0) {
- deleteDatabaseFile();
- return;
- }
-
- try {
- FileWriter fileWriter = new FileWriter(
- Config.getStringValue("server_database_dir") + "/calendar." + getName());
- BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
-
- Enumeration enumEvent = vecEvents.elements();
- while (enumEvent.hasMoreElements()) {
- CalendarEvent event = (CalendarEvent) enumEvent.nextElement();
- event.flush(bufferedWriter);
- }
-
- bufferedWriter.close();
-
- } catch (IOException e) {
- Main.infoMessage("Error: Database flush error: " + e.getMessage());
- }
-
- setHasChanged(false);
- }
+ private Vector vecEvents;
+ private String sCategoryName;
+ private boolean bHasChanged = false;
+ private File categoryFile;
+
+ /**
+ * Creates a new calendar category object and sets the categorie's name to the filename of the category.
+ * @param categoryFile The file object which contains the unparsed events for this specific category. It will be unset after parsing.
+ */
+ public CalendarCategory(File categoryFile) {
+ this.categoryFile = categoryFile;
+ this.sCategoryName = categoryFile.getName();
+
+ // sCategoryName is now "calendar.Name", remove now the leading 'calendar.'
+ sCategoryName = sCategoryName.substring(sCategoryName.indexOf('.') + 1);
+ }
+
+ /**
+ * Creates a new calendar category object and sets the categorie's File to the name of the category.
+ * @param sCategoryName Specifies the categorie's name.
+ */
+ public CalendarCategory(String sCategoryName) {
+ this.sCategoryName = sCategoryName;
+ }
+
+ /**
+ * This method sets the categorie's initial events.
+ * @param vecEvents Specifies the categorie's events.
+ */
+ public void setEvents(Vector vecEvents) {
+ this.vecEvents = vecEvents;
+ }
+
+ /**
+ * This method adds an event to the category.
+ * @param event Specifies the calendar event to add to this category.
+ */
+ public void addEvent(CalendarEvent event) {
+ if (vecEvents == null)
+ vecEvents = new Vector();
+
+ vecEvents.add(event);
+ }
+
+ /**
+ * This method returns the calendar events file object.
+ * @return Returns the categorie's file object.
+ */
+ public File getFile() {
+ return categoryFile;
+ }
+
+ /**
+ * This method Sets the categories file handle to null. This is done if all the data has been read from
+ * the file database.
+ */
+ public void unsetFile() {
+ categoryFile = null;
+ }
+
+ /**
+ * This method returns the categorie's name.
+ * @return Returns the categorie's name.
+ */
+ public String getName() {
+ return sCategoryName;
+ }
+
+ /**
+ * This method sets the categorie's name.
+ */
+ public void setName(String sCategoryName) {
+ if (this.sCategoryName.equals(sCategoryName))
+ return;
+
+ deleteDatabaseFile();
+ this.sCategoryName = sCategoryName;
+ categoryFile = new File(Config.getStringValue("server_database_dir")+"/calendar."+sCategoryName);
+ setHasChanged(true);
+ }
+
+ /**
+ * This method deletes the database file of this event.
+ */
+ public void deleteDatabaseFile() {
+ if (categoryFile == null)
+ categoryFile = new File(Config.getStringValue("server_database_dir")+"/calendar."+getName());
+
+ Main.infoMessage("Removing " + categoryFile.getPath());
+ categoryFile.delete();
+ }
+
+ /**
+ * This method returns the categorie's events.
+ * @return Returns a Vector of all CalendarEvent objects.
+ */
+ public Vector getEvents() {
+ return vecEvents;
+ }
+
+ /**
+ * This method looks for all calendar events of this category which matches a given client's request.
+ * @param clientRequest Specifies the client request sent by the calendar client.
+ * @return Returns a Vector of all matching CalendarEvent objects.
+ */
+ public Vector getMatchingEvents(ClientRequest clientRequest) {
+ Vector vecMatching = new Vector();
+ int iNumEventsToRequest = clientRequest.getNumEventsToRequest();
+
+ Enumeration enumEvents = vecEvents.elements();
+ while (enumEvents.hasMoreElements()) {
+ CalendarEvent event = (CalendarEvent) enumEvents.nextElement();
+ if (clientRequest.match(event))
+ vecMatching.add(event);
+
+ if (iNumEventsToRequest > -1 && iNumEventsToRequest == vecMatching.size())
+ break;
+ }
+
+ return vecMatching;
+ }
+
+ /**
+ * This method checks the current category's name against a regular expression pattern.
+ * @param pattern Specifies the pattern to be used.
+ * @return Returns true if the event matches, else false will be returned.
+ */
+ public boolean matchesName(Pattern pattern) {
+ if (pattern == null)
+ return false;
+
+ return pattern.matcher(getName()).find();
+ }
+
+ /**
+ * This method removes a given event from its event vector.
+ * @param event Specifies the calendar event object to be removed from this category
+ */
+ public void removeEvent(CalendarEvent event) {
+ getEvents().removeElement(event);
+ }
+
+ /**
+ * This method lets you check if the calendar category has been modified/changed by a
+ * calendar client request. This is needed by the CalendarDatabase.flush method, to write all
+ * the changes back to the database files.
+ * @return Returns true if the category has changed, else it will return false.
+ */
+ public boolean hasChanged() {
+ return bHasChanged;
+ }
+
+ /**
+ * This method merges two categories.
+ * @param calendarCategory Specifies the category to merge with.
+ */
+ public void merge(CalendarCategory calendarCategory) {
+ Enumeration enumEvents = calendarCategory.getEvents().elements();
+ while (enumEvents.hasMoreElements())
+ vecEvents.add(enumEvents.nextElement());
+
+ System.out.println(vecEvents);
+ }
+
+ /**
+ * This method specifies if the calendar category has been modified/changed or not.
+ * @param bHasChanged Specifies if the category has been modified/changed or not.
+ */
+ public void setHasChanged(boolean bHasChanged) {
+ this.bHasChanged = bHasChanged;
+ }
+
+ /**
+ * This method flushes the calendar category to the database at the filesystem.
+ */
+ public void flush() {
+ Main.infoMessage("Flushing category " + getName() + " to database!");
+
+ if (vecEvents.size() == 0) {
+ deleteDatabaseFile();
+ return;
+ }
+
+ try {
+ FileWriter fileWriter = new FileWriter(
+ Config.getStringValue("server_database_dir") + "/calendar." + getName());
+ BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
+
+ Enumeration enumEvent = vecEvents.elements();
+ while (enumEvent.hasMoreElements()) {
+ CalendarEvent event = (CalendarEvent) enumEvent.nextElement();
+ event.flush(bufferedWriter);
+ }
+
+ bufferedWriter.close();
+
+ } catch (IOException e) {
+ Main.infoMessage("Error: Database flush error: " + e.getMessage());
+ }
+
+ setHasChanged(false);
+ }
}
diff --git a/sources/shared/CalendarEvent.java b/sources/shared/CalendarEvent.java
index 9a54237..8558d91 100644
--- a/sources/shared/CalendarEvent.java
+++ b/sources/shared/CalendarEvent.java
@@ -1,3 +1,7 @@
+/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow
+ * http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+ */
+
/**
*
*/
@@ -14,326 +18,326 @@ import java.io.*;
*
*/
public class CalendarEvent implements Serializable {
- private static final long serialVersionUID = 1L;
- private MyDate date;
- private CalendarCategory category;
- private String sCategoryName;
- private String sDescription;
- private String sPlace;
- private boolean bYearly;
- private int iEventID;
-
- static private int iEventIDCount = 0;
-
- /**
- * Simple constructor, creates an event object and increments iEventIDCount by one.
- * @param category Specifies the event's category.
- */
- public CalendarEvent(CalendarCategory category) {
- setCategory(category);
- setEventID(iEventIDCount++);
- setYearly(false);
- }
-
- /**
- * Simple constructor, creates an event object and increments iEventIDCount by one.
- * @param sCategoryName Specifies the event's category name.
- */
- public CalendarEvent(String sCategoryName) {
- setCategoryName(sCategoryName.trim());
- setEventID(iEventIDCount++);
- setYearly(false);
- }
-
- /**
- * This method sets the event's date.
- * @param date Specifies the event's date.
- */
- public void setDate(Date date) {
- if (date instanceof MyDate)
- this.date = (MyDate) date;
- else
- this.date = new MyDate(date);
- }
-
- /**
- * This method sets the event's category.
- * @param category Specifies the event's category.
- */
- public void setCategory(CalendarCategory category) {
- this.category = category;
- setCategoryName(category.getName());
- }
-
- /**
- * This event returns the event's calendar category.
- * @return Returns the event's calenda category.
- */
- public CalendarCategory getCategory() {
- return category;
- }
-
- /**
- * This methos sets thhe event's category name.
- * @param sCategoryName Specifies the event's category name.
- */
- public void setCategoryName(String sCategoryName) {
- this.sCategoryName = sCategoryName.trim();
- }
-
- /**
- * This method sets the event's descriptions tring.
- * @param sDescription Specifies the event's description string.
- */
- public void setDescription(String sDescription) {
- this.sDescription = sDescription.trim();
- }
-
- /**
- * This method sets the event's place string.
- * @param sPlace Specifies the event's place string.
- */
- public void setPlace(String sPlace) {
- this.sPlace = sPlace.trim();
- }
-
- /**
- * This method sets the event's ID number.
- * @param iEventID specifies the event's ID number.
- */
- public void setEventID(int iEventID) {
- this.iEventID = iEventID;
- }
-
- /**
- * This method specifies if this event occurs yearly or not.
- * @param bYearly Specifies if this event occury yearly or not.
- */
- public void setYearly(boolean bYearly) {
- this.bYearly = bYearly;
- }
-
- /**
- * This method returns the event's category name.
- * @return Returns the event's category name.
- */
- public String getCategoryName() {
- return sCategoryName;
- }
-
- /**
- * This method returns the event's description string.
- * @return Returns the event's description string.
- */
- public String getDescription() {
- return sDescription;
- }
-
- /**
- * This method returns the event's place string.
- * @return Returns the event's place string.
- */
- public String getPlace() {
- return sPlace;
- }
-
- /**
- * This method returns the event's ID.
- * @return Returns the event's ID.
- */
- public int getID() {
- return iEventID;
- }
-
- /**
- * This method returns the event's date object.
- * @return Returns the event's date object.
- */
- public MyDate getDate() {
- return date;
- }
-
- /**
- * This method returns the event's ID number.
- * @return Returns the event's ID number.
- */
- public int getEventID() {
- return iEventID;
- }
-
- /**
- * This method checks if this event occurs yearly or not.
- * @return Returns true if the event occurs yearly, else it returns false.
- */
- public boolean isYearly() {
- return bYearly;
- }
-
- /**
- * Checks if the current event matches all available data of the event agains
- * a given regular expression pattern.
- * @param pattern Specifies the pattern to match against.
- * @return Returns true if one element of the event matches.
- */
- public boolean matches(Pattern pattern) {
- if (pattern == null)
- return false;
-
- else if (matchesDescription(pattern))
- return true;
-
- else if (matchesPlace(pattern))
- return true;
-
- else if (matchesCategoryName(pattern))
- return true;
-
- return matchesDateString(pattern);
- }
-
- /**
- * Checks if the current event's name matches agains a regular expression pattern.
- * @param pattern Specifies the pattern to be matched against.
- * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
- */
- public boolean matchesCategoryName(Pattern pattern) {
- if (pattern == null)
- return true;
-
- return pattern.matcher(getCategoryName()).find();
- }
-
- /**
- * Checks if the current event's description string matches agains a regular expression pattern.
- * @param pattern Specifies the pattern to match against.
- * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
- */
- public boolean matchesDescription(Pattern pattern) {
- if (pattern == null)
- return true;
-
- return pattern.matcher(getDescription()).find();
- }
-
- /**
- * Checks if the current event's place string matches agains a regular expression pattern.
- * @param pattern Specifies the pattern to match against.
- * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
- */
- public boolean matchesPlace(Pattern pattern) {
- if (pattern == null)
- return true;
-
- return pattern.matcher(getPlace()).find();
- }
-
- /**
- * Checks if the current event's category name matches agains a regular expression pattern
- * @param pattern Specifies the pattern to match against.
- * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
- */
- public boolean matchesCategory(Pattern pattern) {
- if (pattern == null)
- return true;
-
- return pattern.matcher(getCategoryName()).find();
- }
-
- /**
- * Checks if the current event's date string matches agains a regular expression pattern
- * @param pattern Specifies the pattern to match against.
- * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
- */
- public boolean matchesDateString(Pattern pattern) {
- if (pattern == null)
- return true;
-
- return pattern.matcher(getDate().toString()).find();
- }
-
- /**
- * Needed for ojbect serialization (sending part)-
- * @param objectOutputStream Specifies the output stream to use.
- * @throws IOException
- */
- private void writeObject(ObjectOutputStream objectOutputStream)
- throws IOException {
- objectOutputStream.writeInt(iEventID);
- objectOutputStream.writeBoolean(isYearly());
- objectOutputStream.writeObject(getDate());
- objectOutputStream.writeObject(getCategoryName());
- objectOutputStream.writeObject(getDescription());
- objectOutputStream.writeObject(getPlace());
- }
-
- /**
- * Needed for object serialization (receiving part).
- * @param objectInputStream Specifies the input stream to use.
- * @throws IOException
- * @throws ClassNotFoundException
- */
- private void readObject(ObjectInputStream objectInputStream)
- throws IOException, ClassNotFoundException {
- setEventID(objectInputStream.readInt());
- setYearly(objectInputStream.readBoolean());
- setDate((Date) objectInputStream.readObject());
- setCategoryName((String) objectInputStream.readObject());
- setDescription((String) objectInputStream.readObject());
- setPlace((String) objectInputStream.readObject());
-
- if (getEventID() < 0 )
- setEventID(iEventIDCount++);
- }
-
- /**
- * Removes the calendar event from its current category and sets the
- * category reference to null.
- */
- public void removeFromCurrentCategory() {
- CalendarCategory category = getCategory();
- category.removeEvent(this);
- }
-
- /**
- * This method flushes the calendar event to the database at the filesystem.
- * @param bufferedWriter Specifies the buffered writer to write to.
- */
- protected void flush(BufferedWriter bufferedWriter) throws IOException {
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(getDate());
- int iYear = calendar.get(Calendar.YEAR);
- // if (iYear < 11) iYear += 2000;
- int iMonth = calendar.get(Calendar.MONTH) + 1;
- int iDays = calendar.get(Calendar.DAY_OF_MONTH);
- int iHours= calendar.get(Calendar.HOUR);
- int iMinutes = calendar.get(Calendar.MINUTE);
-
- String sPlace = getPlace();
- if (!sPlace.equals(""))
- sPlace = ";;" + sPlace;
-
- String sYearly = isYearly() ? "yearly" : MyDate.addZerosToFront(iYear, 4);
- String sEventLine =
- MyDate.addZerosToFront(iMonth, 2) + "/"
- + MyDate.addZerosToFront(iDays, 2) + "\t"
- + sYearly + "-"
- + MyDate.addZerosToFront(iHours, 2) + ":"
- + MyDate.addZerosToFront(iMinutes, 2) + " "
- + getDescription()
- + sPlace + "\n";
-
- bufferedWriter.write(sEventLine);
- }
-
- /**
- * This method is needed for a text representation of the object.
- * @return Returns object represented as a String.
- */
- public String toString() {
- return "#" + getEventID() + " " + getDate() + "\n"
- + "Yearly : " + isYearly() + "\n"
- + "Category : " + getCategoryName() + "\n"
- + "Description: " + getDescription() + "\n"
- + "Place : " + getPlace() + "\n";
- }
+ private static final long serialVersionUID = 1L;
+ private MyDate date;
+ private CalendarCategory category;
+ private String sCategoryName;
+ private String sDescription;
+ private String sPlace;
+ private boolean bYearly;
+ private int iEventID;
+
+ static private int iEventIDCount = 0;
+
+ /**
+ * Simple constructor, creates an event object and increments iEventIDCount by one.
+ * @param category Specifies the event's category.
+ */
+ public CalendarEvent(CalendarCategory category) {
+ setCategory(category);
+ setEventID(iEventIDCount++);
+ setYearly(false);
+ }
+
+ /**
+ * Simple constructor, creates an event object and increments iEventIDCount by one.
+ * @param sCategoryName Specifies the event's category name.
+ */
+ public CalendarEvent(String sCategoryName) {
+ setCategoryName(sCategoryName.trim());
+ setEventID(iEventIDCount++);
+ setYearly(false);
+ }
+
+ /**
+ * This method sets the event's date.
+ * @param date Specifies the event's date.
+ */
+ public void setDate(Date date) {
+ if (date instanceof MyDate)
+ this.date = (MyDate) date;
+ else
+ this.date = new MyDate(date);
+ }
+
+ /**
+ * This method sets the event's category.
+ * @param category Specifies the event's category.
+ */
+ public void setCategory(CalendarCategory category) {
+ this.category = category;
+ setCategoryName(category.getName());
+ }
+
+ /**
+ * This event returns the event's calendar category.
+ * @return Returns the event's calenda category.
+ */
+ public CalendarCategory getCategory() {
+ return category;
+ }
+
+ /**
+ * This methos sets thhe event's category name.
+ * @param sCategoryName Specifies the event's category name.
+ */
+ public void setCategoryName(String sCategoryName) {
+ this.sCategoryName = sCategoryName.trim();
+ }
+
+ /**
+ * This method sets the event's descriptions tring.
+ * @param sDescription Specifies the event's description string.
+ */
+ public void setDescription(String sDescription) {
+ this.sDescription = sDescription.trim();
+ }
+
+ /**
+ * This method sets the event's place string.
+ * @param sPlace Specifies the event's place string.
+ */
+ public void setPlace(String sPlace) {
+ this.sPlace = sPlace.trim();
+ }
+
+ /**
+ * This method sets the event's ID number.
+ * @param iEventID specifies the event's ID number.
+ */
+ public void setEventID(int iEventID) {
+ this.iEventID = iEventID;
+ }
+
+ /**
+ * This method specifies if this event occurs yearly or not.
+ * @param bYearly Specifies if this event occury yearly or not.
+ */
+ public void setYearly(boolean bYearly) {
+ this.bYearly = bYearly;
+ }
+
+ /**
+ * This method returns the event's category name.
+ * @return Returns the event's category name.
+ */
+ public String getCategoryName() {
+ return sCategoryName;
+ }
+
+ /**
+ * This method returns the event's description string.
+ * @return Returns the event's description string.
+ */
+ public String getDescription() {
+ return sDescription;
+ }
+
+ /**
+ * This method returns the event's place string.
+ * @return Returns the event's place string.
+ */
+ public String getPlace() {
+ return sPlace;
+ }
+
+ /**
+ * This method returns the event's ID.
+ * @return Returns the event's ID.
+ */
+ public int getID() {
+ return iEventID;
+ }
+
+ /**
+ * This method returns the event's date object.
+ * @return Returns the event's date object.
+ */
+ public MyDate getDate() {
+ return date;
+ }
+
+ /**
+ * This method returns the event's ID number.
+ * @return Returns the event's ID number.
+ */
+ public int getEventID() {
+ return iEventID;
+ }
+
+ /**
+ * This method checks if this event occurs yearly or not.
+ * @return Returns true if the event occurs yearly, else it returns false.
+ */
+ public boolean isYearly() {
+ return bYearly;
+ }
+
+ /**
+ * Checks if the current event matches all available data of the event agains
+ * a given regular expression pattern.
+ * @param pattern Specifies the pattern to match against.
+ * @return Returns true if one element of the event matches.
+ */
+ public boolean matches(Pattern pattern) {
+ if (pattern == null)
+ return false;
+
+ else if (matchesDescription(pattern))
+ return true;
+
+ else if (matchesPlace(pattern))
+ return true;
+
+ else if (matchesCategoryName(pattern))
+ return true;
+
+ return matchesDateString(pattern);
+ }
+
+ /**
+ * Checks if the current event's name matches agains a regular expression pattern.
+ * @param pattern Specifies the pattern to be matched against.
+ * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
+ */
+ public boolean matchesCategoryName(Pattern pattern) {
+ if (pattern == null)
+ return true;
+
+ return pattern.matcher(getCategoryName()).find();
+ }
+
+ /**
+ * Checks if the current event's description string matches agains a regular expression pattern.
+ * @param pattern Specifies the pattern to match against.
+ * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
+ */
+ public boolean matchesDescription(Pattern pattern) {
+ if (pattern == null)
+ return true;
+
+ return pattern.matcher(getDescription()).find();
+ }
+
+ /**
+ * Checks if the current event's place string matches agains a regular expression pattern.
+ * @param pattern Specifies the pattern to match against.
+ * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
+ */
+ public boolean matchesPlace(Pattern pattern) {
+ if (pattern == null)
+ return true;
+
+ return pattern.matcher(getPlace()).find();
+ }
+
+ /**
+ * Checks if the current event's category name matches agains a regular expression pattern
+ * @param pattern Specifies the pattern to match against.
+ * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
+ */
+ public boolean matchesCategory(Pattern pattern) {
+ if (pattern == null)
+ return true;
+
+ return pattern.matcher(getCategoryName()).find();
+ }
+
+ /**
+ * Checks if the current event's date string matches agains a regular expression pattern
+ * @param pattern Specifies the pattern to match against.
+ * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
+ */
+ public boolean matchesDateString(Pattern pattern) {
+ if (pattern == null)
+ return true;
+
+ return pattern.matcher(getDate().toString()).find();
+ }
+
+ /**
+ * Needed for ojbect serialization (sending part)-
+ * @param objectOutputStream Specifies the output stream to use.
+ * @throws IOException
+ */
+ private void writeObject(ObjectOutputStream objectOutputStream)
+ throws IOException {
+ objectOutputStream.writeInt(iEventID);
+ objectOutputStream.writeBoolean(isYearly());
+ objectOutputStream.writeObject(getDate());
+ objectOutputStream.writeObject(getCategoryName());
+ objectOutputStream.writeObject(getDescription());
+ objectOutputStream.writeObject(getPlace());
+ }
+
+ /**
+ * Needed for object serialization (receiving part).
+ * @param objectInputStream Specifies the input stream to use.
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ private void readObject(ObjectInputStream objectInputStream)
+ throws IOException, ClassNotFoundException {
+ setEventID(objectInputStream.readInt());
+ setYearly(objectInputStream.readBoolean());
+ setDate((Date) objectInputStream.readObject());
+ setCategoryName((String) objectInputStream.readObject());
+ setDescription((String) objectInputStream.readObject());
+ setPlace((String) objectInputStream.readObject());
+
+ if (getEventID() < 0 )
+ setEventID(iEventIDCount++);
+ }
+
+ /**
+ * Removes the calendar event from its current category and sets the
+ * category reference to null.
+ */
+ public void removeFromCurrentCategory() {
+ CalendarCategory category = getCategory();
+ category.removeEvent(this);
+ }
+
+ /**
+ * This method flushes the calendar event to the database at the filesystem.
+ * @param bufferedWriter Specifies the buffered writer to write to.
+ */
+ protected void flush(BufferedWriter bufferedWriter) throws IOException {
+ Calendar cale