2 * Quoridor server and related libraries
3 * Copyright (C) 2009-2010 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License.
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.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. Look for COPYING file in the top folder.
16 * If not, see http://www.gnu.org/licenses/.
19 package cz.xelfi.quoridor.webidor;
21 import java.util.Date;
22 import javax.xml.bind.annotation.XmlAccessType;
23 import javax.xml.bind.annotation.XmlAccessorType;
24 import javax.xml.bind.annotation.XmlAttribute;
25 import javax.xml.bind.annotation.XmlValue;
29 * @author Jaroslav Tulach <jtulach@netbeans.org>
31 @XmlAccessorType(XmlAccessType.FIELD)
34 private String comment;
43 public Note(String comment, Date when, String who) {
44 this.comment = eliminateXMLChars(comment);
45 this.when = new Date(when.getTime());
49 public String getComment() {
53 public Date getWhen() {
54 return (Date) when.clone();
57 public String getWho() {
62 public String toString() {
63 return "Note[" + who + "@" + when + ": " + comment + "]";
67 public boolean equals(Object obj) {
71 if (getClass() != obj.getClass()) {
74 final Note other = (Note) obj;
75 if ((this.comment == null) ? (other.comment != null) : !this.comment.equals(other.comment)) {
78 if (this.when != other.when && (this.when == null || !this.when.equals(other.when))) {
81 if ((this.who == null) ? (other.who != null) : !this.who.equals(other.who)) {
88 public int hashCode() {
90 hash = 59 * hash + (this.comment != null ? this.comment.hashCode() : 0);
91 hash = 59 * hash + (this.when != null ? this.when.hashCode() : 0);
92 hash = 59 * hash + (this.who != null ? this.who.hashCode() : 0);
96 private static String eliminateXMLChars(String s) {
97 StringBuilder sb = new StringBuilder();
98 for (int i = 0; i < s.length(); i++) {
99 char ch = s.charAt(i);
100 if (0 <= ch && ch < 32) {
101 if (ch != '\n' || ch != '\r') {
102 System.err.println("ignore: " + ch);
108 return sb.toString();