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 package base.user;
21
22 import java.io.UnsupportedEncodingException;
23 import java.security.MessageDigest;
24 import java.security.NoSuchAlgorithmException;
25 import java.util.Date;
26 import java.util.HashSet;
27 import java.util.Iterator;
28 import java.util.Observable;
29
30 import org.apache.log4j.Logger;
31 import org.w3c.dom.Document;
32 import org.w3c.dom.Element;
33 import org.w3c.dom.Node;
34
35 import base.ICXmlTags;
36 import base.IXMLLoadable;
37 import base.IXMLSaveable;
38
39 public class User extends Observable implements IXMLSaveable, IXMLLoadable {
40
41 private static final transient Logger logger = Logger.getLogger(User.class
42 .getName());
43
44 private int id;
45
46 private String name = "";
47
48 private String surname = "";
49
50 private base.user.Document document = new base.user.Document();;
51
52 private String imagePath = null;
53
54 private String credential = UserCredential.USER_CREDENTIAL[0];
55
56 private String nickname = "";
57
58 private String password = "";
59
60 private Date birthday = new Date();
61
62 public Date creationDate = new Date();
63
64 private String gender = UserGender.USER_GENDER[0];
65
66 private HashSet<NAddress> nAddress = new HashSet<NAddress>();
67
68 private HashSet<EAddress> eAddress = new HashSet<EAddress>();
69
70 private HashSet<PhoneNumber> phoneNumber = new HashSet<PhoneNumber>();
71
72 private int currentNAddressId = 0;
73
74 private int currentEAddressId = 0;
75
76 private int currentPhoneNumberId = 0;
77
78 /***
79 * @param id
80 * The user's id.
81 * @param name
82 * The user's name.
83 * @param surname
84 * The user's surname.
85 * @param gender
86 * The user's gender.
87 * @param birthday
88 * The user's birthday.
89 * @param nickname
90 * The user's nickname.
91 * @param password
92 * The user's password.
93 * @param credential
94 * The user's id.
95 * @param document
96 * The user's document.
97 */
98 protected User(final int id, String name, String surname, String gender,
99 Date birthday, String nickname, String password, String credential,
100 base.user.Document document) {
101 this.id = id;
102 this.name = name;
103 this.surname = surname;
104 this.gender = gender;
105 this.birthday = birthday;
106 this.nickname = nickname;
107 this.password = password;
108 this.credential = credential;
109 this.document = document;
110 this.currentNAddressId = retrieveMaxNAddressId();
111 this.currentEAddressId = retrieveMaxEAddressId();
112 this.currentPhoneNumberId = retrieveMaxPhoneNumberId();
113 }
114
115 protected User(int id) {
116 this.id = id;
117
118 }
119
120 /***
121 * @return Returns the imagePath.
122 */
123 public String getImagePath() {
124 return imagePath;
125 }
126
127 /***
128 * @param imagePath
129 * The imagePath to set.
130 */
131 public void setImagePath(String imagePath) {
132 this.imagePath = imagePath;
133 }
134
135 /***
136 * @return Returns the password.
137 */
138 public String getPassword() {
139 return password;
140 }
141
142 /***
143 * @param password
144 * The password to set.
145 */
146 public void setPassword(String password) {
147 if (!this.getPassword().equals(password)) {
148
149 this.password = buildUserPassword(password);
150 } else
151 this.password = password;
152 }
153
154 /***
155 * @param birthday
156 * The birthday to set.
157 */
158 public void setBirthday(Date birthday) {
159 this.birthday = birthday;
160 }
161
162 /***
163 * @param credential
164 * The credential to set.
165 */
166 public void setCredential(String credential) {
167 this.credential = credential;
168 }
169
170 /***
171 * @param document
172 * The document to set.
173 */
174 public void setDocument(base.user.Document document) {
175 this.document = document;
176 }
177
178 /***
179 * @param name
180 * The name to set.
181 */
182 public void setName(String name) {
183 this.name = name;
184 }
185
186 /***
187 * @param nickname
188 * The nickname to set.
189 */
190 public void setNickname(String nickname) {
191 this.nickname = nickname;
192 }
193
194 /***
195 * @param surname
196 * The surname to set.
197 */
198 public void setSurname(String surname) {
199 this.surname = surname;
200 }
201
202 /***
203 * @return Returns the document.
204 */
205 public base.user.Document getDocument() {
206 return document;
207 }
208
209 /***
210 * @return Returns the name.
211 */
212 public String getName() {
213 return name;
214 }
215
216 /***
217 * @return Returns the nickname.
218 */
219 public String getNickname() {
220 return nickname;
221 }
222
223 /***
224 * @return Returns the surname.
225 */
226 public String getSurname() {
227 return surname;
228 }
229
230 /***
231 * @return Returns the credential.
232 */
233 public String getCredential() {
234 return credential;
235 }
236
237
238
239
240
241
242 @Override
243 public String toString() {
244 StringBuffer sb = new StringBuffer();
245 sb.append("USER");
246 sb.append("\n");
247 sb.append("id: " + id);
248 sb.append("\n");
249 sb.append("name: " + name);
250 sb.append("\n");
251 sb.append("surname: " + surname);
252 sb.append("\n");
253 sb.append("gender: " + gender);
254 sb.append("\n");
255 sb.append("birthday: " + birthday);
256 sb.append("\n");
257 sb.append("document: \n" + document);
258 sb.append("\n");
259 sb.append("nAddress: \n");
260
261 Iterator iterator = nAddress.iterator();
262 while (iterator.hasNext())
263 sb.append(iterator.next() + "\n");
264 sb.append("eAddress: \n");
265
266 iterator = eAddress.iterator();
267 while (iterator.hasNext())
268 sb.append(iterator.next() + "\n");
269 sb.append("phoneNumber: \n");
270
271 iterator = phoneNumber.iterator();
272 while (iterator.hasNext())
273 sb.append(iterator.next() + "\n");
274
275 sb.append("image: " + imagePath);
276 sb.append("\n");
277 sb.append("credential: " + credential);
278 sb.append("\n");
279 sb.append("nickname: " + nickname);
280 sb.append("\n");
281 sb.append("password: " + password);
282 return sb.toString();
283 }
284
285 /***
286 * @return Returns the birthday.
287 */
288 public Date getBirthday() {
289 return birthday;
290 }
291
292 /***
293 * @return Returns the id.
294 */
295 public int getId() {
296 return id;
297 }
298
299 /***
300 * @return Returns the gender.
301 */
302 public String getGender() {
303 return gender;
304 }
305
306 /***
307 * @param gender
308 * The gender to set.
309 */
310 public void setGender(String gender) {
311 this.gender = gender;
312 }
313
314 /***
315 * @return Returns the creationDate.
316 */
317 public Date getCreationDate() {
318 return creationDate;
319 }
320
321 /***
322 * @param password
323 * The User's password.
324 * @return Returns an MD5 digest of the user's password.
325 */
326 public static String buildUserPassword(String password) {
327 String result = "";
328 MessageDigest md;
329 try {
330 md = MessageDigest.getInstance("MD5");
331 md.update(password.getBytes("UTF8"));
332 byte[] hash = md.digest();
333 for (int i = 0; i < hash.length; i++) {
334 int hexValue = hash[i] & 0xFF;
335 if (hexValue < 16) {
336 result = result + "0";
337 }
338 result = result + Integer.toString(hexValue, 16);
339 }
340 logger.debug("Users'password MD5 Digest: " + result);
341 } catch (NoSuchAlgorithmException ex) {
342
343 logger.error(ex.getMessage());
344 ex.printStackTrace();
345 } catch (UnsupportedEncodingException ex) {
346 logger.error(ex.getMessage());
347 ex.printStackTrace();
348 }
349 return result;
350 }
351
352 /***
353 * @return Returns the eAddress.
354 */
355 public EAddress[] getEAddress() {
356 if (eAddress == null) {
357 eAddress = new HashSet<EAddress>();
358 }
359 return eAddress.toArray(new EAddress[0]);
360 }
361
362 /***
363 * @return Returns the nAddress.
364 */
365 public NAddress[] getNAddress() {
366 if (nAddress == null) {
367 nAddress = new HashSet<NAddress>();
368 }
369 return nAddress.toArray(new NAddress[0]);
370 }
371
372 /***
373 * @return Returns the phoneNumber.
374 */
375 public PhoneNumber[] getPhoneNumber() {
376 if (phoneNumber == null) {
377 phoneNumber = new HashSet<PhoneNumber>();
378 }
379 return phoneNumber.toArray(new PhoneNumber[0]);
380 }
381
382 public void addEAddress(EAddress eAddress) {
383 eAddress.setId(getNextEAddressId());
384 this.eAddress.add(eAddress);
385 }
386
387 public void addNAddress(NAddress nAddress) {
388 nAddress.setId(getNextNAddressId());
389 this.nAddress.add(nAddress);
390 }
391
392 public void addPhoneNumber(PhoneNumber phoneNumber) {
393 phoneNumber.setId(getNextPhoneNumberId());
394 this.phoneNumber.add(phoneNumber);
395 }
396
397 private int getNextNAddressId() {
398 return ++currentNAddressId;
399 }
400
401 private int getNextEAddressId() {
402 return ++currentEAddressId;
403 }
404
405 private int getNextPhoneNumberId() {
406 return ++currentPhoneNumberId;
407 }
408
409 private int retrieveMaxNAddressId() {
410 int max = -1;
411 NAddress[] address = getNAddress();
412 for (int i = 0; i < address.length; i++)
413 if (address[i].getId() > max)
414 max = address[i].getId();
415 return max;
416 }
417
418 private int retrieveMaxEAddressId() {
419 int max = -1;
420 EAddress[] address = getEAddress();
421 for (int i = 0; i < address.length; i++)
422 if (address[i].getId() > max)
423 max = address[i].getId();
424 return max;
425 }
426
427 private int retrieveMaxPhoneNumberId() {
428 int max = -1;
429 PhoneNumber[] phoneNumber = getPhoneNumber();
430 for (int i = 0; i < phoneNumber.length; i++)
431 if (phoneNumber[i].getId() > max)
432 max = phoneNumber[i].getId();
433 return max;
434 }
435
436 public NAddress newNAddress(String city, String nation, String street,
437 String region, String postalCode, String description) {
438 return new NAddress(0, city, nation, street, region, postalCode,
439 description);
440 }
441
442 public EAddress newEAddress(String eAddress) {
443 return new EAddress(0, eAddress);
444 }
445
446 public PhoneNumber newPhoneNumber(String areaCode, String exchange,
447 String number, String description) {
448 return new PhoneNumber(0, areaCode, exchange, number, description);
449 }
450
451 /***
452 * @param addressId
453 * The id associated to the NAddress
454 * @return The NAddress whose id is addressId, null if such nAddressId is
455 * not contained in the user's nAddress set.
456 *
457 */
458 public NAddress getNAddressById(int addressId) {
459 NAddress[] address = getNAddress();
460 for (int i = 0; i < address.length; i++)
461 if (address[i].getId() == addressId)
462 return address[i];
463 return null;
464 }
465
466 /***
467 * @param addressId
468 * The id associated to an EAddress.
469 * @return The EAddress whose id is addressId, null if such eAddressId is
470 * not contained in the user's eAddress set.
471 */
472 public EAddress getEAddressById(int addressId) {
473 EAddress[] address = getEAddress();
474 for (int i = 0; i < address.length; i++)
475 if (address[i].getId() == addressId)
476 return address[i];
477 return null;
478 }
479
480 /***
481 * @param phoneNumberId
482 * The id associated to a PhoneNumber.
483 * @return The PhoneNumber whose id is phoneNumberId, null if such
484 * phoneNumberId is not contained in the user's phoneNumber set.
485 */
486 public PhoneNumber getPhoneNumberById(int phoneNumberId) {
487 PhoneNumber[] phoneNumber = getPhoneNumber();
488 for (int i = 0; i < phoneNumber.length; i++)
489 if (phoneNumber[i].getId() == phoneNumberId)
490 return phoneNumber[i];
491 return null;
492 }
493
494 /***
495 * @param nAddress
496 * Deletes the nAddress form the user's nAddress set.
497 */
498 public void deleteNAddress(NAddress nAddress) {
499 this.nAddress.remove(nAddress);
500 }
501
502 /***
503 * @param eAddress
504 * Deletes the eAddress from the user's eAddress set.
505 */
506 public void deleteEAddress(EAddress eAddress) {
507 this.eAddress.remove(eAddress);
508
509 }
510
511 /***
512 * @param phoneNumber
513 * Deletes the phoneNumber from the user's phoneNumber set.
514 */
515 public void deletePhoneNumber(PhoneNumber phoneNumber) {
516 this.phoneNumber.remove(phoneNumber);
517
518 }
519
520 public Node toXml(Document document) {
521 Element userElement = document.createElement(ICXmlTags.IC_USER_TAG);
522 userElement.setAttribute(ICXmlTags.IC_USER_ID_ATTRIBUTE, "" + this.id);
523 userElement.setAttribute(
524 ICXmlTags.IC_USER_CURRENT_NADDRESS_ID_ATTRIBUTE, ""
525 + this.currentNAddressId);
526 userElement.setAttribute(
527 ICXmlTags.IC_USER_CURRENT_EADDRESS_ID_ATTRIBUTE, ""
528 + this.currentEAddressId);
529 userElement.setAttribute(
530 ICXmlTags.IC_USER_CURRENT_PHONE_NUMBER_ID_ATTRIBUTE, ""
531 + this.currentPhoneNumberId);
532
533 Element nameElement = document
534 .createElement(ICXmlTags.IC_USER_NAME_TAG);
535 nameElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.name);
536 userElement.appendChild(nameElement);
537
538 Element surnameElement = document
539 .createElement(ICXmlTags.IC_USER_SURNAME_TAG);
540 surnameElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.surname);
541 userElement.appendChild(surnameElement);
542
543 Element genderElement = document
544 .createElement(ICXmlTags.IC_USER_GENDER_TAG);
545 genderElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE, this.gender);
546 userElement.appendChild(genderElement);
547
548 Element credentialElement = document
549 .createElement(ICXmlTags.IC_USER_CREDENTIAL_TAG);
550 credentialElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE,
551 this.credential);
552 userElement.appendChild(credentialElement);
553
554 Element nicknameElement = document
555 .createElement(ICXmlTags.IC_USER_NICKNAME_TAG);
556 nicknameElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE,
557 this.nickname);
558 userElement.appendChild(nicknameElement);
559
560 Element passwordElement = document
561 .createElement(ICXmlTags.IC_USER_PASSWORD_TAG);
562 passwordElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE,
563 this.password);
564 userElement.appendChild(passwordElement);
565
566 Element imagePathElement = document
567 .createElement(ICXmlTags.IC_USER_IMAGE_PATH_TAG);
568 imagePathElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE,
569 this.imagePath);
570 userElement.appendChild(imagePathElement);
571
572 Element birthdayElement = document
573 .createElement(ICXmlTags.IC_USER_BIRTHDAY_TAG);
574 birthdayElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE,
575 this.birthday.toString());
576 birthdayElement.setAttribute(ICXmlTags.IC_LONG_VALUE_ATTRIBUTE, ""
577 + this.birthday.getTime());
578 userElement.appendChild(birthdayElement);
579
580 Element creationDateElement = document
581 .createElement(ICXmlTags.IC_USER_CREATION_DATE_TAG);
582 creationDateElement.setAttribute(ICXmlTags.IC_VALUE_ATTRIBUTE,
583 this.creationDate.toString());
584 creationDateElement.setAttribute(ICXmlTags.IC_LONG_VALUE_ATTRIBUTE, ""
585 + this.creationDate.getTime());
586
587 userElement.appendChild(creationDateElement);
588
589 userElement.appendChild(this.document.toXml(document));
590
591 Element nAddressElement = document
592 .createElement(ICXmlTags.IC_USER_NADDRESS_LIST_TAG);
593 Iterator iterator = this.nAddress.iterator();
594 while (iterator.hasNext())
595 nAddressElement.appendChild(((IXMLSaveable) iterator.next())
596 .toXml(document));
597 userElement.appendChild(nAddressElement);
598
599 Element eAddressElement = document
600 .createElement(ICXmlTags.IC_USER_EADDRESS_LIST_TAG);
601 iterator = this.eAddress.iterator();
602 while (iterator.hasNext())
603 eAddressElement.appendChild(((IXMLSaveable) iterator.next())
604 .toXml(document));
605 userElement.appendChild(eAddressElement);
606
607 Element phoneNumberElement = document
608 .createElement(ICXmlTags.IC_USER_PHONE_NUMBER_LIST_TAG);
609 iterator = this.phoneNumber.iterator();
610 while (iterator.hasNext())
611 phoneNumberElement.appendChild(((IXMLSaveable) iterator.next())
612 .toXml(document));
613 userElement.appendChild(phoneNumberElement);
614
615 return userElement;
616 }
617
618 public Object fromXml(Document document) {
619
620 Node userNode = document.getElementsByTagName(ICXmlTags.IC_USER_TAG)
621 .item(0);
622
623 int id = Integer.parseInt(userNode.getAttributes().getNamedItem(
624 ICXmlTags.IC_USER_ID_ATTRIBUTE).getNodeValue());
625 int currentNAddressId = Integer.parseInt(userNode.getAttributes()
626 .getNamedItem(ICXmlTags.IC_USER_CURRENT_NADDRESS_ID_ATTRIBUTE)
627 .getNodeValue());
628 int currentEAddressId = Integer.parseInt(userNode.getAttributes()
629 .getNamedItem(ICXmlTags.IC_USER_CURRENT_EADDRESS_ID_ATTRIBUTE)
630 .getNodeValue());
631 int currentPhoneNumberId = Integer.parseInt(userNode.getAttributes()
632 .getNamedItem(
633 ICXmlTags.IC_USER_CURRENT_PHONE_NUMBER_ID_ATTRIBUTE)
634 .getNodeValue());
635
636 String name = "";
637 String surname = "";
638 String gender = "";
639 String credential = "";
640 Date birthday = null;
641 Date creationDate = null;
642 String nickname = "";
643 String password = "";
644 base.user.Document userDocument = null;
645 String imagePath = "";
646 NAddress[] nAddress = null;
647 EAddress[] eAddress = null;
648 PhoneNumber[] phoneNumber = null;
649
650 for (int i = 0; i < userNode.getChildNodes().getLength(); i++) {
651 if (userNode.getChildNodes().item(i).getNodeName()
652 .equalsIgnoreCase(ICXmlTags.IC_USER_NAME_TAG))
653 name = userNode.getChildNodes().item(i).getAttributes()
654 .getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE)
655 .getNodeValue();
656 if (userNode.getChildNodes().item(i).getNodeName()
657 .equalsIgnoreCase(ICXmlTags.IC_USER_SURNAME_TAG))
658 surname = userNode.getChildNodes().item(i).getAttributes()
659 .getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE)
660 .getNodeValue();
661 if (userNode.getChildNodes().item(i).getNodeName()
662 .equalsIgnoreCase(ICXmlTags.IC_USER_GENDER_TAG))
663 gender = userNode.getChildNodes().item(i).getAttributes()
664 .getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE)
665 .getNodeValue();
666 if (userNode.getChildNodes().item(i).getNodeName()
667 .equalsIgnoreCase(ICXmlTags.IC_USER_CREDENTIAL_TAG))
668 credential = userNode.getChildNodes().item(i).getAttributes()
669 .getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE)
670 .getNodeValue();
671 if (userNode.getChildNodes().item(i).getNodeName()
672 .equalsIgnoreCase(ICXmlTags.IC_USER_NICKNAME_TAG))
673 nickname = userNode.getChildNodes().item(i).getAttributes()
674 .getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE)
675 .getNodeValue();
676 if (userNode.getChildNodes().item(i).getNodeName()
677 .equalsIgnoreCase(ICXmlTags.IC_USER_PASSWORD_TAG))
678 password = userNode.getChildNodes().item(i).getAttributes()
679 .getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE)
680 .getNodeValue();
681 if (userNode.getChildNodes().item(i).getNodeName()
682 .equalsIgnoreCase(ICXmlTags.IC_USER_IMAGE_PATH_TAG))
683 imagePath = userNode.getChildNodes().item(i).getAttributes()
684 .getNamedItem(ICXmlTags.IC_VALUE_ATTRIBUTE)
685 .getNodeValue();
686 if (userNode.getChildNodes().item(i).getNodeName()
687 .equalsIgnoreCase(ICXmlTags.IC_USER_BIRTHDAY_TAG))
688 birthday = new Date(Long.parseLong(userNode.getChildNodes()
689 .item(i).getAttributes().getNamedItem(
690 ICXmlTags.IC_LONG_VALUE_ATTRIBUTE)
691 .getNodeValue()));
692 if (userNode.getChildNodes().item(i).getNodeName()
693 .equalsIgnoreCase(ICXmlTags.IC_USER_CREATION_DATE_TAG))
694 creationDate = new Date(Long.parseLong(userNode.getChildNodes()
695 .item(i).getAttributes().getNamedItem(
696 ICXmlTags.IC_LONG_VALUE_ATTRIBUTE)
697 .getNodeValue()));
698 if (userNode.getChildNodes().item(i).getNodeName()
699 .equalsIgnoreCase(ICXmlTags.IC_USER_NADDRESS_LIST_TAG)) {
700 nAddress = new NAddress[userNode.getChildNodes().item(i)
701 .getChildNodes().getLength()];
702 for (int k = 0; k < userNode.getChildNodes().item(i)
703 .getChildNodes().getLength(); k++) {
704 nAddress[k] = new NAddress().fromXml(userNode
705 .getChildNodes().item(i).getChildNodes().item(i));
706 }
707 }
708 if (userNode.getChildNodes().item(i).getNodeName()
709 .equalsIgnoreCase(ICXmlTags.IC_USER_EADDRESS_LIST_TAG)) {
710 eAddress = new EAddress[userNode.getChildNodes().item(i)
711 .getChildNodes().getLength()];
712 for (int k = 0; k < userNode.getChildNodes().item(i)
713 .getChildNodes().getLength(); k++) {
714 eAddress[k] = new EAddress().fromXml(userNode
715 .getChildNodes().item(i).getChildNodes().item(i));
716 }
717 }
718 if (userNode.getChildNodes().item(i).getNodeName()
719 .equalsIgnoreCase(ICXmlTags.IC_USER_PHONE_NUMBER_LIST_TAG)) {
720 phoneNumber = new PhoneNumber[userNode.getChildNodes().item(i)
721 .getChildNodes().getLength()];
722 for (int k = 0; k < userNode.getChildNodes().item(i)
723 .getChildNodes().getLength(); k++) {
724 phoneNumber[k] = new PhoneNumber().fromXml(userNode
725 .getChildNodes().item(i).getChildNodes().item(i));
726 }
727 }
728 if (userNode.getChildNodes().item(i).getNodeName()
729 .equalsIgnoreCase(ICXmlTags.IC_DOCUMENT_TAG)) {
730 userDocument = new base.user.Document().fromXml(userNode
731 .getChildNodes().item(i));
732 }
733 }
734
735 User result = new User(id);
736 result.currentEAddressId = currentEAddressId;
737 result.currentNAddressId = currentNAddressId;
738 result.currentPhoneNumberId = currentPhoneNumberId;
739 result.creationDate = creationDate;
740 result.name = name;
741 result.surname = surname;
742 result.gender = gender;
743 result.birthday = birthday;
744 result.nickname = nickname;
745 result.password = password;
746 result.credential = credential;
747 result.document = userDocument;
748 result.imagePath = imagePath;
749
750 return result;
751 }
752
753 /***
754 * @param id
755 * The id to set.
756 */
757 protected void setId(int id) {
758 this.id = id;
759 }
760 }