View Javadoc
1 // re/mind - Remote Reminder Software 2 // Copyright (C) 2002 Moritz Petersen 3 // 4 // This program is free software; you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation; either version 2 of the License, or 7 // (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with this program; if not, write to the Free Software 16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 // 18 // $Id: NoteMetaData.java,v 1.1 2002/09/29 19:33:23 powerpete Exp $ 19 package de.jface.remind.core; 20 21 import java.awt.Rectangle; 22 23 import java.util.Date; 24 25 import org.apache.log4j.Logger; 26 27 /*** 28 * Interface <code>NoteMetaData</code> 29 * of project RemotePostIt. 30 * 31 * @author Moritz Petersen 32 * @version $Revision: 1.1 $ 33 */ 34 public class NoteMetaData 35 { 36 private Logger log4j = Logger.getLogger(getClass()); 37 38 /*** 39 * Contains the unique number of this NoteMetaData instance. 40 */ 41 private final UniqueNumber uniqueNumber; 42 43 /*** 44 * Contains the date of the creation of this 45 * object. 46 */ 47 private final Date dateOfCreation; 48 private Rectangle bounds = new Rectangle(10, 10, 240, 240); 49 private Visibility visibility = Visibility.VISIBLE; 50 51 /*** 52 * Creates a new NoteMetaData object with a new unique 53 * number. 54 */ 55 public NoteMetaData() 56 { 57 uniqueNumber = UniqueNumber.newInstance(); 58 log4j.debug("NoteMetaData created with uniqueNumber = " + uniqueNumber); 59 dateOfCreation = new Date(); 60 } 61 62 /*** 63 * Creates a new NoteMetaData object with the given unique number. 64 * This constructor is used to reproduce already created 65 * instances of NoteMetaData. It should be used when unmarshalling 66 * this object form the persistance storage. 67 * 68 * @param uniqueNumber the unique number that is assigned 69 * to the new NoteMetaData instance. 70 */ 71 public NoteMetaData(long uniqueNumber, Date dateOfCreation) 72 throws IllegalUniqueNumberException 73 { 74 this.uniqueNumber = UniqueNumber.newInstance(uniqueNumber, true); 75 log4j.debug("NoteMetaData created with uniqueNumber = " 76 + this.uniqueNumber); 77 this.dateOfCreation = dateOfCreation; 78 } 79 80 /*** 81 * Returns the uniqe number of this NoteMetaData. 82 * 83 * @return the unique number of this NoteMetaData. 84 */ 85 public long getUniqueNumber() 86 { 87 return uniqueNumber.longValue(); 88 } 89 90 /*** 91 * Returns the date of the creation of this note. 92 */ 93 public Date getDateOfCreation() 94 { 95 return dateOfCreation; 96 } 97 98 public void setBounds(Rectangle bounds) 99 { 100 this.bounds = bounds; 101 } 102 103 public Rectangle getBounds() 104 { 105 return bounds; 106 } 107 108 public void setVisibility(Visibility visibility) 109 { 110 this.visibility = visibility; 111 } 112 113 public Visibility getVisibility() 114 { 115 return visibility; 116 } 117 118 /*** 119 * Compares this instance of NoteMetaData with the specified 120 * object. Returns true, if both have the same unique 121 * number. 122 * 123 * @param o The instance to compare with. 124 * @return true, if the unique numbers of both instances 125 * are equal. 126 */ 127 public boolean equals(Object o) 128 { 129 NoteMetaData n = (NoteMetaData) o; 130 131 return uniqueNumber.equals(n.uniqueNumber) 132 && dateOfCreation.equals(n.dateOfCreation); 133 } 134 135 /*** 136 * Returns the hash code of this object. 137 */ 138 public int hashCode() 139 { 140 return (int) (uniqueNumber.longValue() + dateOfCreation.getTime()); 141 } 142 143 public String toString() 144 { 145 return new StringBuffer(getClass().getName()).append( 146 "Ê[uniqueNumber = ").append(uniqueNumber) 147 .append(", dateOfCreation = ") 148 .append(dateOfCreation) 149 .append(", bounds = ") 150 .append(bounds) 151 .append(", visibility = ") 152 .append(visibility) 153 .append("]").toString(); 154 } 155 156 public static class Visibility 157 { 158 public static final Visibility VISIBLE = new Visibility("VISIBLE"); 159 public static final Visibility HIDDEN = new Visibility("HIDDEN"); 160 public static final Visibility MINIMIZED = new Visibility("MINIMIZED"); 161 private String status; 162 163 private Visibility(String status) 164 { 165 this.status = status; 166 } 167 168 public String toString() 169 { 170 return status; 171 } 172 173 public static Visibility getInstance(String status) 174 { 175 if (VISIBLE.toString().equals(status)) 176 { 177 return VISIBLE; 178 } 179 else if (HIDDEN.toString().equals(status)) 180 { 181 return HIDDEN; 182 } 183 else if (MINIMIZED.toString().equals(status)) 184 { 185 return MINIMIZED; 186 } 187 188 return null; 189 } 190 191 public boolean equals(Object o) 192 { 193 Visibility n = (Visibility) o; 194 195 return status.equals(n.status); 196 } 197 198 public int hashCode() 199 { 200 return status.hashCode(); 201 } 202 } 203 }

This page was automatically generated by Maven