001: /*
002: * Copyright (c) 2007, Sun Microsystems, Inc.
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions are met:
007: *
008: * * Redistributions of source code must retain the above copyright notice,
009: * this list of conditions and the following disclaimer.
010: * * Redistributions in binary form must reproduce the above copyright
011: * notice, this list of conditions and the following disclaimer in
012: * the documentation and/or other materials provided with the distribution.
013: * * Neither the name of Sun Microsystems, Inc. nor the names of its
014: * contributors may be used to endorse or promote products derived
015: * from this software without specific prior written permission.
016: *
017: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
018: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
019: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
020: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
021: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
022: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
023: * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
024: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
025: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
026: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
027: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028: */
029:
030: package clienteditor;
031:
032: import java.beans.PropertyChangeListener;
033: import java.beans.PropertyChangeSupport;
034:
035: /**
036: * Information about one clinet.
037: *
038: * @author Jiri Vagner, Jan Stola
039: */
040: public class Client {
041: /** First name of the client. */
042: private String firstName;
043: /** Surname of the client. */
044: private String surname;
045: /** Nickname of the client. */
046: private String nickname;
047: /** Age of the client. */
048: private int age;
049: /** Sex of the client (0 - female, 1 - male). */
050: private int sex;
051: /** Marital status of the client (0 - single, 1 - married, 2 - separated, 3 - divorced) */
052: private int maritalStatus;
053: /** E-mail of the client. */
054: private String email;
055: /** Home web page of the client. */
056: private String web;
057: /** Instant messenger of the client. */
058: private String im;
059:
060: // <editor-fold defaultstate="collapsed" desc="PropertyChange Stuff">
061: private final PropertyChangeSupport changeSupport = new PropertyChangeSupport(
062: this );
063:
064: public void addPropertyChangeListener(
065: PropertyChangeListener listener) {
066: changeSupport.addPropertyChangeListener(listener);
067: }
068:
069: public void removePropertyChangeListener(
070: PropertyChangeListener listener) {
071: changeSupport.removePropertyChangeListener(listener);
072: }
073:
074: // </editor-fold>
075:
076: // <editor-fold defaultstate="collapsed" desc="Get Methods">
077: public String getFirstName() {
078: return firstName;
079: }
080:
081: public String getSurname() {
082: return surname;
083: }
084:
085: public String getNickname() {
086: return nickname;
087: }
088:
089: public int getAge() {
090: return age;
091: }
092:
093: public String getEmail() {
094: return email;
095: }
096:
097: public String getWeb() {
098: return web;
099: }
100:
101: public String getIm() {
102: return im;
103: }
104:
105: public int getSex() {
106: return sex;
107: }
108:
109: public int getMaritalStatus() {
110: return maritalStatus;
111: }
112:
113: // </editor-fold>
114:
115: // <editor-fold defaultstate="collapsed" desc="Set Methods">
116: public void setFirstName(String firstName) {
117: String oldFirstName = this .firstName;
118: this .firstName = firstName;
119: changeSupport.firePropertyChange("firstName", oldFirstName,
120: firstName);
121: }
122:
123: public void setSurname(String surname) {
124: String oldSurname = this .surname;
125: this .surname = surname;
126: changeSupport
127: .firePropertyChange("surname", oldSurname, surname);
128: }
129:
130: public void setNickname(String nickname) {
131: String oldNickname = this .nickname;
132: this .nickname = nickname;
133: changeSupport.firePropertyChange("nickname", oldNickname,
134: nickname);
135: }
136:
137: public void setAge(int age) {
138: int oldAge = this .age;
139: this .age = age;
140: changeSupport.firePropertyChange("age", oldAge, age);
141: }
142:
143: public void setEmail(String email) {
144: String oldEmail = this .email;
145: this .email = email;
146: changeSupport.firePropertyChange("email", oldEmail, email);
147: }
148:
149: public void setWeb(String web) {
150: String oldWeb = this .web;
151: this .web = web;
152: changeSupport.firePropertyChange("web", oldWeb, web);
153: }
154:
155: public void setIm(String im) {
156: String oldIm = this .im;
157: this .im = im;
158: changeSupport.firePropertyChange("im", oldIm, im);
159: }
160:
161: public void setSex(int sex) {
162: int oldSex = this .sex;
163: this .sex = sex;
164: changeSupport.firePropertyChange("sex", oldSex, sex);
165: }
166:
167: public void setMaritalStatus(int maritalStatus) {
168: int oldMaritalStatus = this .maritalStatus;
169: this .maritalStatus = maritalStatus;
170: changeSupport.firePropertyChange("maritalStatus",
171: oldMaritalStatus, maritalStatus);
172: }
173:
174: // </editor-fold>
175:
176: public static Client createTestClient() {
177: Client client = new Client();
178: client.setFirstName("George");
179: client.setSurname("Foo");
180: client.setNickname("Juraj");
181: client.setAge(30);
182:
183: client.setEmail("g.foo@foo.org");
184: client.setWeb("https://beansbinding.dev.java.net");
185: client.setIm("ICQ: 53 25 89 76");
186:
187: client.setSex(1);
188: client.setMaritalStatus(2);
189:
190: return client;
191: }
192: }
|