1 9 10 package org.uddi4j.datatype.business; 11 12 import java.util.Vector ; 13 14 import org.uddi4j.UDDIElement; 15 import org.uddi4j.UDDIException; 16 import org.w3c.dom.Element ; 17 import org.w3c.dom.NodeList ; 18 19 41 42 public class Address extends UDDIElement 43 { 44 public static final String UDDI_TAG = "address"; 45 46 protected Element base = null; 47 48 String useType = null; 49 String sortCode = null; 50 String tModelKey = null; 51 Vector addressLine = new Vector (); 53 54 60 public Address() 61 { 62 } 63 64 74 75 public Address(Element base) throws UDDIException 76 { 77 super(base); 79 useType = getAttr(base,"useType"); 80 sortCode = getAttr(base,"sortCode"); 81 tModelKey = getAttr(base,"tModelKey"); 82 NodeList nl = null; 83 nl = getChildElementsByTagName(base, AddressLine.UDDI_TAG); 84 for (int i = 0; i < nl.getLength(); i++) 85 { 86 addressLine.addElement(new AddressLine((Element) nl.item(i))); 87 } 88 } 89 90 private String getAttr(Element base, String attrname) 91 { 92 if(base.getAttributeNode(attrname)!=null && base.getAttributeNode(attrname).getSpecified() ) 93 { 94 return base.getAttribute(attrname); 95 } 96 return null; 97 } 98 99 public void setUseType(String s) 100 { 101 useType = s; 102 } 103 104 public void setSortCode(String s) 105 { 106 sortCode = s; 107 } 108 109 114 public void setAddressLineVector(Vector s) 115 { 116 addressLine = s; 117 } 118 119 124 public void setAddressLineStrings(Vector s) 125 { 126 addressLine = new Vector (); 127 for (int i = 0; i < s.size(); i++) 128 { 129 addressLine.addElement(new AddressLine((String ) s.elementAt(i))); 130 } 131 } 132 133 public void setTModelKey(String key) 134 { 135 tModelKey = key; 136 } 137 138 public String getUseType() 139 { 140 return useType; 141 } 142 143 public String getSortCode() 144 { 145 return sortCode; 146 } 147 148 153 public Vector getAddressLineVector() 154 { 155 return addressLine; 156 } 157 158 163 public Vector getAddressLineStrings() 164 { 165 Vector strings = new Vector (); 166 for (int i = 0; i < addressLine.size(); i++) 167 { 168 strings.addElement(((AddressLine) addressLine.elementAt(i)).getText()); 169 } 170 return strings; 171 } 172 173 public String getTModelKey() 174 { 175 return tModelKey; 176 } 177 178 187 public void saveToXML(Element parent) 188 { 189 base = parent.getOwnerDocument().createElement(UDDI_TAG); 190 if (useType != null) 192 { 193 base.setAttribute("useType", useType); 194 } 195 if (sortCode != null) 196 { 197 base.setAttribute("sortCode", sortCode); 198 } 199 if (tModelKey != null) 200 { 201 base.setAttribute("tModelKey", tModelKey); 202 } 203 if (addressLine != null) 204 { 205 for (int i = 0; i < addressLine.size(); i++) 206 { 207 ((AddressLine) (addressLine.elementAt(i))).saveToXML(base); 208 } 209 } 210 parent.appendChild(base); 211 } 212 } 213 | Popular Tags |