001: package vqwiki;
002:
003: import java.util.Calendar;
004: import java.util.Date;
005:
006: /*
007: Very Quick Wiki - WikiWikiWeb clone
008: Copyright (C) 2001-2002 Gareth Cronin
009:
010: This program is free software; you can redistribute it and/or modify
011: it under the terms of the latest version of the GNU Lesser General
012: Public License as published by the Free Software Foundation;
013:
014: This program is distributed in the hope that it will be useful,
015: but WITHOUT ANY WARRANTY; without even the implied warranty of
016: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
017: GNU Lesser General Public License for more details.
018:
019: You should have received a copy of the GNU Lesser General Public License
020: along with this program (gpl.txt); if not, write to the Free Software
021: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
022:
023: */
024:
025: public class Change implements java.io.Serializable, Comparable {
026:
027: protected String topic;
028: protected String user;
029: protected Date time;
030: protected String virtualWiki;
031:
032: /**
033: *
034: */
035: public Change() {
036: }
037:
038: /**
039: *
040: */
041: public String getTopic() {
042: return topic;
043: }
044:
045: /**
046: *
047: */
048: public Change(String virtualWiki, String inTopic, String inUser,
049: Date changeDate) {
050: this .topic = inTopic;
051: this .user = inUser;
052: this .time = changeDate;
053: this .virtualWiki = virtualWiki;
054: }
055:
056: /**
057: *
058: */
059: public void setTopic(String topic) {
060: this .topic = topic;
061: }
062:
063: /**
064: *
065: */
066: public String getUser() {
067: return user;
068: }
069:
070: /**
071: *
072: */
073: public String getUsername() {
074: try {
075: return WikiBase.getInstance().getUsergroupInstance()
076: .getFullnameById(user);
077: } catch (Exception e) {
078: return user;
079: }
080: }
081:
082: /**
083: *
084: */
085: public void setUser(String user) {
086: this .user = user;
087: }
088:
089: /**
090: *
091: */
092: public Date getTime() {
093: return time;
094: }
095:
096: /**
097: *
098: */
099: public void setTime(Date time) {
100: this .time = time;
101: }
102:
103: /**
104: *
105: */
106: public String getVirtualWiki() {
107: return virtualWiki;
108: }
109:
110: /**
111: *
112: */
113: public void setVirtualWiki(String virtualWiki) {
114: this .virtualWiki = virtualWiki;
115: }
116:
117: /**
118: *
119: */
120: public int compareTo(Object o) {
121: Change incomingChange = (Change) o;
122: if (time.before(incomingChange.time)) {
123: return 1;
124: }
125: if (time.after(incomingChange.time)) {
126: return -1;
127: }
128: return 0;
129: }
130:
131: /**
132: *
133: */
134: public boolean equals(Object o) {
135: if (o == null)
136: return false;
137: if (!(o instanceof Change))
138: return false;
139: Change c = (Change) o;
140: if (!this .topic.equals(c.getTopic())
141: || !this .user.equals(c.getUser())) {
142: return false;
143: }
144: Calendar cal1 = Calendar.getInstance();
145: Calendar cal2 = Calendar.getInstance();
146: cal1.setTime(this .time);
147: cal2.setTime(c.getTime());
148: if (cal1.get(Calendar.DATE) != cal2.get(Calendar.DATE)
149: || cal1.get(Calendar.MONTH) != cal2.get(Calendar.MONTH)
150: || cal1.get(Calendar.YEAR) != cal2.get(Calendar.YEAR)) {
151: return false;
152: }
153: return true;
154: }
155: }
|