View Javadoc
1 /* 2 * ==================================================================== 3 * 4 * This code is subject to the freebxml License, Version 1.1 5 * 6 * Copyright (c) 2003 freebxml.org. All rights reserved. 7 * 8 * ==================================================================== 9 */package com/sun/xml/registry/client/browser/registration/package-summary.html">color="#329900"> */package com.sun.xml.registry.client.browser.registration; 10 11 import javax.xml.registry.JAXRException; 12 import javax.xml.registry.infomodel.PersonName; 13 import javax.xml.registry.infomodel.User; 14 15 import com.sun.xml.registry.client.browser.swing.Model; 16 17 /*** 18 * @author Fabian Ritzmann 19 */ 20 public class PersonNameModel implements Model { 21 22 private final User user; 23 24 25 PersonNameModel(User name) throws JAXRException { 26 this.user = name; 27 } 28 29 30 /*** 31 * Method setFirstName. 32 * @param text 33 */ 34 public void setFirstName(String text) throws JAXRException { 35 text = text.trim(); 36 PersonName name = user.getPersonName(); 37 if (name != null) { 38 name.setFirstName(text); 39 } 40 else { 41 name = user.getLifeCycleManager().createPersonName(text, "", ""); 42 this.user.setPersonName(name); 43 } 44 } 45 46 47 /*** 48 * Method setMiddleName. 49 * @param text 50 */ 51 public void setMiddleName(String text) throws JAXRException { 52 text = text.trim(); 53 PersonName name = user.getPersonName(); 54 if (name != null) { 55 name.setMiddleName(text); 56 } 57 else { 58 name = user.getLifeCycleManager().createPersonName("", text, ""); 59 this.user.setPersonName(name); 60 } 61 } 62 63 64 /*** 65 * Method setLastName. 66 * @param text 67 */ 68 public void setLastName(String text) throws JAXRException { 69 text = text.trim(); 70 PersonName name = user.getPersonName(); 71 if (name != null) { 72 name.setLastName(text); 73 } 74 else { 75 name = user.getLifeCycleManager().createPersonName("", "", text); 76 this.user.setPersonName(name); 77 } 78 } 79 80 81 public void validate() throws JAXRException { 82 83 String firstName = user.getPersonName().getFirstName(); 84 String middleName = user.getPersonName().getMiddleName(); 85 String lastName = user.getPersonName().getLastName(); 86 87 if (((firstName == null) || (firstName.length() == 0)) 88 && ((middleName == null) || (middleName.length() == 0)) 89 && ((lastName == null) || (lastName.length() == 0))) { 90 throw new JAXRException("Missing required PersonName on User"); 91 } 92 93 } 94 95 }

This page was automatically generated by Maven