View Javadoc

1   /*
2    * Copyright (c) 2001 - 2004 ivata limited.
3    * All rights reserved.
4    * -----------------------------------------------------------------------------
5    * ivata masks may be redistributed under the GNU General Public
6    * License as published by the Free Software Foundation;
7    * version 2 of the License.
8    *
9    * These programs are free software; you can redistribute them and/or
10   * modify them under the terms of the GNU General Public License
11   * as published by the Free Software Foundation; version 2 of the License.
12   *
13   * These programs are distributed in the hope that they will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16   *
17   * See the GNU General Public License in the file LICENSE.txt for more
18   * details.
19   *
20   * If you would like a copy of the GNU General Public License write to
21   *
22   * Free Software Foundation, Inc.
23   * 59 Temple Place - Suite 330
24   * Boston, MA 02111-1307, USA.
25   *
26   *
27   * To arrange commercial support and licensing, contact ivata at
28   *                  http://www.ivata.com/contact.jsp
29   * -----------------------------------------------------------------------------
30   * $Log: CustomerDO.java,v $
31   * Revision 1.4  2005/04/09 18:04:13  colinmacleod
32   * Changed copyright text to GPL v2 explicitly.
33   *
34   * Revision 1.3  2005/01/07 09:13:04  colinmacleod
35   * Added newline to end of file.
36   *
37   * Revision 1.2  2005/01/07 08:08:17  colinmacleod
38   * Moved up a version number.
39   * Changed copyright notices to 2005.
40   * Updated the documentation:
41   *   - started working on multiproject:site docu.
42   *   - changed the logo.
43   * Added checkstyle and fixed LOADS of style issues.
44   * Added separate thirdparty subproject.
45   * Added struts (in web), util and webgui (in webtheme) from ivata op.
46   *
47   * Revision 1.1  2004/11/10 17:18:19  colinmacleod
48   * New value object classes - first version in CVS.
49   * -----------------------------------------------------------------------------
50   */
51  package com.ivata.mask.web.demo.customer;
52  import com.ivata.mask.util.StringHandling;
53  import com.ivata.mask.web.demo.valueobject.DemoValueObject;
54  /***
55   * <p>
56   * Represents a single customer of this imaginary system.
57   * </p>
58   *
59   * @since ivata masks 0.4 (2004-05-20)
60   * @author Colin MacLeod
61   * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
62   * @version $Revision: 1.4 $
63   */
64  public final class CustomerDO extends DemoValueObject {
65      /***
66       * <p>
67       * Person's email address (ok - it's a simple system).
68       * </p>
69       */
70      private String emailAddress;
71      /***
72       * <p>
73       * Person's first name(s).
74       * </p>
75       */
76      private String firstName;
77      /***
78       * <p>
79       * Person's last name(s).
80       * </p>
81       */
82      private String lastName;
83      /***
84       * Full customer postal address, including carriage
85       * returns, region/state, country, etc.
86       */
87      private String postalAddress;
88      /***
89       * <p>
90       * Construct a new customer instance with no id.
91       * </p>
92       */
93      public CustomerDO() {
94          super();
95      }
96      /***
97       * <p>
98       * Construct a new customer instance with the given unique identifier.
99       * </p>
100      *
101      * @param idParam unique identifier of this customer.
102      */
103     public CustomerDO(final int idParam) {
104         super(idParam);
105     }
106     /***
107      * Get a text to display describing the customer. If the customer has a
108      * first and last name, then this will return something like &quot;Freddie
109      * Kruger&quot;, otherwise just the first or last name is returned -
110      * whichever is present.
111      *
112      * @return customer's name.
113      * @see com.ivata.mask.valueobject.ValueObject#getStringValue()
114      */
115     public String getDisplayValue() {
116         StringBuffer stringValue = new StringBuffer();
117         if (!StringHandling.isNullOrEmpty(firstName)) {
118             stringValue.append(firstName.trim());
119         }
120         if (!StringHandling.isNullOrEmpty(lastName)) {
121             if (stringValue.length() > 0) {
122                 stringValue.append(" ");
123             }
124             stringValue.append(lastName.trim());
125         }
126         return stringValue.toString();
127     }
128     /***
129      * Person's email address (ok - it's a simple system).
130      *
131      * @return string email address such as
132      * <code>ted@nowhere.com</code>.
133      */
134     public String getEmailAddress() {
135         return emailAddress;
136     }
137     /***
138      * <p>
139      * Person's first name(s).
140      * </p>
141      *
142      * @return first name such as &quot;Bob&quot;, or &quot;Sally&quot;.
143      */
144     public String getFirstName() {
145         return firstName;
146     }
147     /***
148      * Person's last name(s).
149      *
150      * @return last name of the customer, such as &quot;Smith&quot; or
151      * &quot;Tarrantino&quot;.
152      */
153     public String getLastName() {
154         return lastName;
155     }
156     /***
157      * Full customer postal address, including carriage
158      * returns, region/state, country, etc.
159      *
160      * @return Customer's full snail-mail address.
161      */
162     public String getPostalAddress() {
163         return postalAddress;
164     }
165     /***
166      * Person's email address (ok - it's a simple system).
167      *
168      * @param emailAddressParam string email address such as
169      * <code>ted@nowhere.com</code>.
170      */
171     public void setEmailAddress(final String emailAddressParam) {
172         emailAddress = emailAddressParam;
173     }
174     /***
175      * <p>
176      * Person's first name(s).
177      * </p>
178      *
179      * @param firstNameParam first name such as &quot;Bob&quot;, or
180      * &quot;Sally&quot;.
181      */
182     public void setFirstName(final String firstNameParam) {
183         firstName = firstNameParam;
184     }
185     /***
186      * Person's last name(s).
187      *
188      * @param lastNameParam last name of the customer, such as &quot;Smith&quot;
189      * or &quot;Tarrantino&quot;.
190      */
191     public void setLastName(final String lastNameParam) {
192         lastName = lastNameParam;
193     }
194     /***
195      * Full customer postal address, including carriage
196      * returns, region/state, country, etc.
197      *
198      * @param postalAddressParam Customer's full snail-mail address.
199      */
200     public void setPostalAddress(final String postalAddressParam) {
201         postalAddress = postalAddressParam;
202     }
203 }
204