View Javadoc

1   /*
2    * The SmartWeb Framework
3    * Copyright (C) 2004-2006
4    *
5    * This library is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU Lesser General Public
7    * License as published by the Free Software Foundation; either
8    * version 2.1 of the License, or (at your option) any later version.
9    *
10   * This library is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   * Lesser General Public License for more details.
14   *
15   * You should have received a copy of the GNU Lesser General Public
16   * License along with this library; if not, write to the Free Software
17   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18   *
19   * For further informations on the SmartWeb Framework please visit
20   *
21   *                        http://smartweb.sourceforge.net
22   */
23   
24  package net.smartlab.web.history;
25  
26  import java.io.Serializable;
27  import java.sql.Timestamp;
28  
29  /**
30   * TODO documentation
31   * 
32   * @author rlogiacco
33   */
34  public interface HistorizedBusinessObject {
35  
36  	/**
37  	 * Returns the id.
38  	 * 
39  	 * @return the id.
40  	 * @hibernate.id
41  	 * @uml.property name="id"
42  	 */
43  	public HistoryId getHistoryId();
44  	
45  	/**
46  	 * Sets the id.
47  	 * 
48  	 * @param historyId the id to set.
49  	 * @uml.property name="id"
50  	 */
51  	public void setHistoryId(HistoryId historyId);
52  	
53  	/**
54  	 * TODO documentation
55  	 * 
56  	 * @return
57  	 * @hibernate.property column="modified"
58  	 */
59  	public Timestamp getLastModified();
60  
61  	/**
62  	 * TODO documentation
63  	 * 
64  	 * @param timestamp
65  	 */
66  	public void setLastModified(Timestamp timestamp);
67  	
68  	public static class HistoryId implements Serializable {
69  
70  		private static final long serialVersionUID = -1087450948763335029L;
71  
72  		/**
73  		 * The reference part of this identifier.
74  		 * 
75  		 * @uml.property name="ref"
76  		 */
77  		private Serializable ref;
78  
79  		private Timestamp lastModified;
80  
81  
82  		/**
83  		 * A reference back to the primary key of the unlocalized referent
84  		 * object.
85  		 * 
86  		 * @return returns the <code>reference</code> part.
87  		 * @hibernate.property column="`ref`"
88  		 * @uml.property name="ref"
89  		 */
90  		public Serializable getRef() {
91  			return ref;
92  		}
93  
94  		/**
95  		 * TODO documentation
96  		 * 
97  		 * @param ref the <code>ref</code> part to set.
98  		 * @uml.property name="ref"
99  		 */
100 		public void setRef(Serializable ref) {
101 			this.ref = ref;
102 		}
103 
104 		/**
105 		 * TODO documentation
106 		 * 
107 		 * @return returns the <code>lastModified</code> part.
108 		 * @hibernate.property column="`modified`"
109 		 * @uml.property name="lastModified"
110 		 */
111 		public Timestamp getLastModified() {
112 			return lastModified;
113 		}
114 
115 		/**
116 		 * TODO documentation
117 		 * 
118 		 * @param lastModified the <code>lastModified</code> part to set.
119 		 * @uml.property name="lastModified"
120 		 */
121 		public void setLastModified(Timestamp lastModified) {
122 			this.lastModified = lastModified;
123 		}
124 
125 		/**
126 		 * @see java.lang.Object#equals(java.lang.Object)
127 		 */
128 		public boolean equals(Object obj) {
129 			if (obj instanceof HistoryId) {
130 				return ((HistoryId)obj).ref.equals(ref) && ((HistoryId)obj).lastModified.equals(lastModified);
131 			} else {
132 				return false;
133 			}
134 		}
135 
136 		/**
137 		 * @see java.lang.Object#hashCode()
138 		 */
139 		public int hashCode() {
140 			return ref.hashCode() + (lastModified.hashCode() >> 29);
141 		}
142 
143 		/**
144 		 * @see java.lang.Object#toString()
145 		 */
146 		public String toString() {
147 			return "ref = " + ref.toString() + " modified = " + lastModified;
148 		}
149 	}
150 }