1 /********************************************************************************
2 * InternetCafe is a software solution that helps the management of Cybercafes
3 * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005.
4 * Copyright (C) 2006 Guido Angelo Ingenito
5
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 *******************************************************************************/
20
21 package base.user.jcard;
22
23 public class Name extends Property {
24
25 private static final String FIELD_NAME_DELIMITER=";";
26
27 private String familyName = "";
28 private String givenName = "";
29 private String additionalName = "";
30 private String prefix = "";
31 private String suffix = "";
32
33
34
35 /***
36 * @param additionalName The additionalName to set.
37 */
38 public void setAdditionalName(String additionalName) {
39 this.additionalName = additionalName;
40 }
41
42 /***
43 * @param familyName The familyName to set.
44 */
45 public void setFamilyName(String familyName) {
46 this.familyName = familyName;
47 }
48
49 /***
50 * @param givenName The givenName to set.
51 */
52 public void setGivenName(String givenName) {
53 this.givenName = givenName;
54 }
55
56 /***
57 * @param prefix The prefix to set.
58 */
59 public void setPrefix(String prefix) {
60 this.prefix = prefix;
61 }
62
63 /***
64 * @param suffix The suffix to set.
65 */
66 public void setSuffix(String suffix) {
67 this.suffix = suffix;
68 }
69
70
71
72 public void setPropertyName() {
73 super.PROPERTY_NAME = "N:";
74 }
75
76 public void doValidate() throws JCardException {
77
78 if(givenName == null || givenName == "") {
79 throw new JCardException("Validation error: At least given name must be populated");
80 }
81 }
82
83
84 public String toString() {
85 StringBuffer name = new StringBuffer(30);
86 name.append(familyName);
87 name.append(FIELD_NAME_DELIMITER);
88 name.append(givenName);
89 name.append(FIELD_NAME_DELIMITER);
90 name.append(additionalName);
91 name.append(FIELD_NAME_DELIMITER);
92 name.append(prefix);
93 name.append(FIELD_NAME_DELIMITER);
94 name.append(suffix);
95 return name.toString();
96 }
97 }