001: /*
002: * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018: package test.org.mandarax.xkb;
019:
020: import java.util.Date;
021: import java.util.GregorianCalendar;
022:
023: /**
024: * Sample bean class for test cases
025: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
026: * @version 3.4 <7 March 05>
027: * @since 1.6
028: */
029: public class Person {
030:
031: private int id = 0;
032: private String name = "";
033: private Date dob = (new GregorianCalendar(1966, 0, 12)).getTime();
034:
035: /**
036: * Constructor.
037: */
038: public Person() {
039: super ();
040: }
041:
042: /**
043: * Constructor. Pass id, name, the year/month and day of birth.
044: */
045: public Person(int anId, String aName, int yearOfBirth,
046: int monthOfBirth, int dayOfBirth) {
047: this ();
048:
049: id = anId;
050: name = aName;
051: dob = (new GregorianCalendar(yearOfBirth, monthOfBirth,
052: dayOfBirth)).getTime();
053: }
054:
055: /**
056: * Setter for id.
057: */
058: public void setId(int value) {
059: id = value;
060: }
061:
062: /**
063: * Setter for name.
064: */
065: public void setName(String value) {
066: name = value;
067: }
068:
069: /**
070: * Setter for dob.
071: */
072: public void setDob(Date value) {
073: dob = value;
074: }
075:
076: /**
077: * Getter for id.
078: */
079: public int getId() {
080: return id;
081: }
082:
083: /**
084: * Getter for name.
085: */
086: public String getName() {
087: return name;
088: }
089:
090: /**
091: * Getter for dob.
092: */
093: public Date getDob() {
094: return dob;
095: }
096:
097: /**
098: * Compare objects.
099: * @param obj another object
100: * @return a boolean
101: */
102: public boolean equals(Object obj) {
103: if ((obj == null) || (getClass() != obj.getClass())) {
104: return false;
105: }
106:
107: Person p = (Person) obj;
108:
109: return (getId() == p.getId()) && getName().equals(p.getName())
110: && getDob().equals(p.getDob());
111: }
112:
113: /**
114: * Get the hash code of the object.
115: * @return the hash code
116: */
117: public int hashCode() {
118: return id;
119: }
120: }
|