Modification.java

Go to the documentation of this file.
00001 package cedar.hepdata.model;
00002 
00003 import cedar.hepdata.util.*;
00004 import java.util.Date;
00005 
00006 import javax.persistence.*;
00007 
00008 
00009 @Embeddable
00010 public class Modification extends Storeable implements Comparable<Modification> {
00012     @Column(name="Timestamp", nullable=true)
00013     @Temporal(TemporalType.TIMESTAMP)
00014     @Transient
00015     private Date _timestamp;
00016 
00018     @Column(name="Modifier", nullable=true)
00019     private String _modifier;
00020 
00022     @Column(name="ModComment", nullable=true, length=10000)
00023     private String _comment;
00024 
00025 
00027 
00028 
00030     public Modification() {}
00031 
00032 
00034 
00035 
00037     public Date getTimestamp() {
00038         return _timestamp;
00039     }
00041     public Modification setTimestamp(Date timestamp) {
00042         _timestamp = timestamp;
00043         return this;
00044     }
00045 
00046 
00048     public String getModifier() {
00049         return _modifier;
00050     }
00052     public Modification setModifier(String modifier) {
00053         _modifier = modifier;
00054         return this;
00055     }
00056 
00057 
00059     public String getComment() {
00060         return _comment;
00061     }
00063     public Modification setComment(String comment) {
00064         _comment = comment;
00065         return this;
00066     }
00068     public Modification unsetComment() {
00069         _comment = null;
00070         return this;
00071     }
00072 
00073 
00075 
00076 
00077     public int compareTo(Modification other) {
00078         log().debug("Comparing modifications...");
00079         if (getTimestamp() == null) {
00080             log().warn("Null timestamp");
00081             return 1; // Sort null at the end
00082         } else if (getTimestamp().after(other.getTimestamp())) {
00083             log().debug("Greater than");
00084             return 1;
00085         } else if (getTimestamp().before(other.getTimestamp())) {
00086             log().debug("Less than");
00087             return -1;
00088         } else {
00089             log().debug("Equal to");
00090             return 0;
00091         }
00092     }
00093 
00094 
00096 
00097 
00098     public String toString() {
00099         StringBuffer s = new StringBuffer();
00100         s.append(getTimestamp().toString() + ", ");
00101         s.append(getModifier() + "\n");
00102         s.append(getComment());
00103         return s.toString();
00104     }
00105 
00106 
00107     public boolean equals(Object other) {
00108         if (this == other) return true;
00109         if (! (other instanceof Modification)) return false;
00110         return hashCode() == other.hashCode();
00111     }
00112 
00113 
00114     public int hashCode() {
00115         int code = 53;
00116         if (getTimestamp() != null) code ^= getTimestamp().hashCode();
00117         if (getModifier() != null)  code ^= getModifier().hashCode();
00118         if (getComment() != null)   code ^= getComment().hashCode();
00119         return code;
00120     }
00121 
00122 }

Generated on Tue Apr 21 15:54:38 2009 for HepData object model by  doxygen 1.5.5