Reference.java

Go to the documentation of this file.
00001 package cedar.hepdata.model;
00002 
00003 import java.util.Date;
00004 import java.util.Set;
00005 
00006 import javax.persistence.*;
00007 
00014 @Embeddable
00015 public class Reference extends Storeable implements Comparable<Reference> {
00016 
00018     @Column(name="Date", nullable=true)
00019     @Temporal(TemporalType.TIMESTAMP)
00020     private Date _date = new Date();
00021 
00023     @Column(name="Type", nullable=false)
00024     private RefType _type = RefType.UNKNOWN;
00025 
00027     @Column(name="Description", nullable=false)
00028     private String _description = "";
00029 
00031     @Column(name="Comment", nullable=false)//, length=10000)
00032     private String _comment = "";
00033 
00034 
00036 
00037 
00039     public Reference() { super(); }
00040 
00042     public Reference(String description) {
00043         this();
00044         setDescription(description);
00045     }
00046 
00048     public Reference(RefType type, String description) {
00049         this(description);
00050         setType(type);
00051     }
00052 
00054     public Reference(RefType type, String description, Date date) {
00055         this(type, description);
00056         setDate(date);
00057     }
00058 
00059 
00061 
00062 
00064     public Date getDate() {
00065         return _date;
00066     }
00068     public Reference setDate(Date date) {
00069         _date = date;
00070         return this;
00071     }
00072 
00073 
00075     public RefType getType() {
00076         return _type;
00077     }
00079     public Reference setType(RefType type) {
00080         _type = type;
00081         return this;
00082     }
00083 
00084 
00086     public String getDescription() {
00087         return _description;
00088     }
00090     public Reference setDescription(String description) {
00091         _description = description;
00092         return this;
00093     }
00094 
00095 
00097     public String getComment() {
00098         return _comment;
00099     }
00101     public Reference setComment(String comment) {
00102         _comment = comment;
00103         return this;
00104     }
00105 
00106 
00108 
00109 
00110     public int compareTo(Reference other) {
00111         log().debug("Comparing references...");
00112         return getDate().compareTo(other.getDate());
00113     }
00114 
00115 
00117 
00118 
00120     public String toString() {
00121         StringBuffer s = new StringBuffer();
00122         s.append("Reference: " + getType().toString() + " " );
00123         return s.toString();
00124     }
00125 
00126     public boolean equals(Object other) {
00127         if (this == other) return true;
00128         if (!(other instanceof Reference)) return false;
00129         return (hashCode() == other.hashCode());
00130     }
00131 
00132     public int hashCode() {
00133          int result = 17;
00134          result ^= getDate().hashCode();
00135          result ^= getType().hashCode();
00136          result ^= getDescription().hashCode();
00137          result ^= getComment().hashCode();
00138          return result;
00139      }
00140 
00141 }

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