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.uddi4j.datatype.Description; 17 import org.uddi4j.datatype.Name; 18 import org.uddi4j.datatype.service.BusinessServices; 19 import org.uddi4j.util.CategoryBag; 20 import org.uddi4j.util.DiscoveryURLs; 21 import org.uddi4j.util.IdentifierBag; 22 import org.w3c.dom.Element ; 23 import org.w3c.dom.NodeList ; 24 25 48 public class BusinessEntity extends UDDIElement { 49 public static final String UDDI_TAG = "businessEntity"; 50 51 protected Element base = null; 52 53 String businessKey = null; 54 String operator = null; 55 String authorizedName = null; 56 DiscoveryURLs discoveryURLs = null; 57 Contacts contacts = null; 58 BusinessServices businessServices = null; 59 IdentifierBag identifierBag = null; 60 CategoryBag categoryBag = null; 61 Vector description = new Vector (); 63 Vector nameVector = new Vector (); 64 65 71 public BusinessEntity() { 72 } 73 74 90 public BusinessEntity(String businessKey, 91 String name) { 92 this.businessKey = businessKey; 93 nameVector.addElement(new Name(name)); 94 } 95 96 103 public BusinessEntity(String businessKey, 104 String name, String lang) { 105 this.businessKey = businessKey; 106 nameVector.addElement(new Name(name,lang)); 107 } 108 109 119 public BusinessEntity(Element base) throws UDDIException { 120 super(base); 122 businessKey = base.getAttribute("businessKey"); 123 operator = getAttr(base,"operator"); 124 authorizedName = getAttr(base,"authorizedName"); 125 NodeList nl = null; 126 nl = getChildElementsByTagName(base, DiscoveryURLs.UDDI_TAG); 127 if (nl.getLength() > 0) { 128 discoveryURLs = new DiscoveryURLs((Element)nl.item(0)); 129 } 130 nl = getChildElementsByTagName(base, Name.UDDI_TAG); 131 for (int i=0; i < nl.getLength(); i++) { 132 nameVector.addElement(new Name((Element)nl.item(i))); 133 } 134 nl = getChildElementsByTagName(base, Contacts.UDDI_TAG); 135 if (nl.getLength() > 0) { 136 contacts = new Contacts((Element)nl.item(0)); 137 } 138 nl = getChildElementsByTagName(base, BusinessServices.UDDI_TAG); 139 if (nl.getLength() > 0) { 140 businessServices = new BusinessServices((Element)nl.item(0)); 141 } 142 nl = getChildElementsByTagName(base, IdentifierBag.UDDI_TAG); 143 if (nl.getLength() > 0) { 144 identifierBag = new IdentifierBag((Element)nl.item(0)); 145 } 146 nl = getChildElementsByTagName(base, CategoryBag.UDDI_TAG); 147 if (nl.getLength() > 0) { 148 categoryBag = new CategoryBag((Element)nl.item(0)); 149 } 150 nl = getChildElementsByTagName(base, Description.UDDI_TAG); 151 for (int i=0; i < nl.getLength(); i++) { 152 description.addElement(new Description((Element)nl.item(i))); 153 } 154 } 155 156 private String getAttr(Element base, String attrname) 157 { 158 if(base.getAttributeNode(attrname)!=null && base.getAttributeNode(attrname).getSpecified() ) 159 { 160 return base.getAttribute(attrname); 161 } 162 return null; 163 } 164 165 public void setBusinessKey(String s) { 166 businessKey = s; 167 } 168 169 public void setOperator(String s) { 170 operator = s; 171 } 172 173 public void setAuthorizedName(String s) { 174 authorizedName = s; 175 } 176 177 public void setDiscoveryURLs(DiscoveryURLs s) { 178 discoveryURLs = s; 179 } 180 181 186 public void setName(Name s) { 187 setDefaultName(s); 188 } 189 190 195 public void setName(String s) { 196 setDefaultNameString(s, null); 197 } 198 199 203 public void setDefaultName(Name name) { 204 if (nameVector.size() > 0) { 205 nameVector.setElementAt(name,0); 206 } else { 207 nameVector.addElement(name); 208 } 209 } 210 211 215 public void setDefaultNameString(String value, String lang) { 216 Name name = new Name(value, lang); 217 if (nameVector.size() > 0) { 218 nameVector.setElementAt(name,0); 219 } else { 220 nameVector.addElement(name); 221 } 222 } 223 224 227 public void setNameVector(Vector s) { 228 nameVector = s; 229 } 230 231 public void setContacts(Contacts s) { 232 contacts = s; 233 } 234 235 public void setBusinessServices(BusinessServices s) { 236 businessServices = s; 237 } 238 239 public void setIdentifierBag(IdentifierBag s) { 240 identifierBag = s; 241 } 242 243 public void setCategoryBag(CategoryBag s) { 244 categoryBag = s; 245 } 246 247 252 public void setDescriptionVector(Vector s) { 253 description = s; 254 } 255 256 261 public void setDefaultDescriptionString(String s) { 262 if (description.size() > 0) { 263 description.setElementAt(new Description(s), 0); 264 } else { 265 description.addElement(new Description(s)); 266 } 267 } 268 269 270 public String getBusinessKey() { 271 return businessKey; 272 } 273 274 275 public String getOperator() { 276 return operator; 277 } 278 279 280 public String getAuthorizedName() { 281 return authorizedName; 282 } 283 284 285 public DiscoveryURLs getDiscoveryURLs() { 286 return discoveryURLs; 287 } 288 289 294 public Name getName() { 295 return getDefaultName(); 296 } 297 298 303 public String getNameString() { 304 return getDefaultNameString(); 305 } 306 307 308 public Name getDefaultName() { 309 return (Name) nameVector.elementAt(0); 310 } 311 312 317 public String getDefaultNameString() { 318 if ((nameVector).size() > 0) { 319 return ((Name)nameVector.elementAt(0)).getText(); 320 } else { 321 return null; 322 } 323 } 324 325 330 public Vector getNameVector() { 331 return nameVector ; 332 } 333 334 public Contacts getContacts() { 335 return contacts; 336 } 337 338 339 public BusinessServices getBusinessServices() { 340 return businessServices; 341 } 342 343 344 public IdentifierBag getIdentifierBag() { 345 return identifierBag; 346 } 347 348 349 public CategoryBag getCategoryBag() { 350 return categoryBag; 351 } 352 353 354 359 public Vector getDescriptionVector() { 360 return description; 361 } 362 363 364 369 public String getDefaultDescriptionString() { 370 if ((description).size() > 0) { 371 Description t = (Description)description.elementAt(0); 372 return t.getText(); 373 } else { 374 return null; 375 } 376 } 377 378 387 public void saveToXML(Element parent) { 388 base = parent.getOwnerDocument().createElement(UDDI_TAG); 389 if (businessKey!=null) { 391 base.setAttribute("businessKey", businessKey); 392 } 393 if (operator!=null) { 394 base.setAttribute("operator", operator); 395 } 396 if (authorizedName!=null) { 397 base.setAttribute("authorizedName", authorizedName); 398 } 399 if (discoveryURLs!=null) { 400 discoveryURLs.saveToXML(base); 401 } 402 if (nameVector!=null) { 403 for (int i=0; i < nameVector.size(); i++) { 404 ((Name)(nameVector.elementAt(i))).saveToXML(base); 405 } 406 } 407 if (description!=null) { 408 for (int i=0; i < description.size(); i++) { 409 ((Description)(description.elementAt(i))).saveToXML(base); 410 } 411 } 412 if (contacts!=null) { 413 contacts.saveToXML(base); 414 } 415 if (businessServices!=null) { 416 businessServices.saveToXML(base); 417 } 418 if (identifierBag!=null) { 419 identifierBag.saveToXML(base); 420 } 421 if (categoryBag!=null) { 422 categoryBag.saveToXML(base); 423 } 424 parent.appendChild(base); 425 } 426 } 427 428 | Popular Tags |