1 8 9 package org.uddi4j.response; 10 11 import java.util.Vector ; 12 13 import org.uddi4j.UDDIElement; 14 import org.uddi4j.UDDIException; 15 import org.uddi4j.datatype.Description; 16 import org.uddi4j.datatype.Name; 17 import org.uddi4j.util.BusinessKey; 18 import org.w3c.dom.Element ; 19 import org.w3c.dom.NodeList ; 20 21 50 public class RelatedBusinessInfo extends UDDIElement { 51 52 public static final String UDDI_TAG = "relatedBusinessInfo"; 53 protected Element base = null; 54 BusinessKey businessKey = null; 55 Vector nameVector = new Vector (); 57 Vector description = new Vector (); 58 Vector sharedRelationships = new Vector (); 59 60 66 public RelatedBusinessInfo() { 67 } 68 69 70 78 public RelatedBusinessInfo( BusinessKey businessKey, Vector names, Vector sharedRelationships) { 79 this.businessKey=businessKey; 80 this.nameVector=names; 81 this.sharedRelationships=sharedRelationships; 82 } 83 84 92 public RelatedBusinessInfo( String businessKey, Vector names, Vector sharedRelationships) { 93 this.businessKey=new BusinessKey(businessKey); 94 this.nameVector=names; 95 this.sharedRelationships=sharedRelationships; 96 } 97 98 106 public RelatedBusinessInfo( String businessKey, String name, Vector sharedRelationships) { 107 this.businessKey=new BusinessKey(businessKey); 108 setDefaultNameString(name,null); 109 this.sharedRelationships=sharedRelationships; 110 } 111 112 113 123 public RelatedBusinessInfo(Element base) throws UDDIException { 124 super(base); 126 NodeList nl = null; 127 nl = getChildElementsByTagName(base, BusinessKey.UDDI_TAG); 128 if (nl.getLength() > 0) { 129 businessKey = new BusinessKey((Element)nl.item(0)); 130 } 131 132 nl = getChildElementsByTagName(base, Name.UDDI_TAG); 133 for (int i = 0 ; i < nl.getLength(); i++ ) { 134 nameVector.addElement(new Name((Element)nl.item(i))); 135 } 136 137 nl = getChildElementsByTagName(base, Description.UDDI_TAG); 138 for (int i = 0 ; i < nl.getLength(); i++) { 139 description.addElement(new Description((Element)nl.item(i))); 140 } 141 142 nl = getChildElementsByTagName(base, SharedRelationships.UDDI_TAG); 143 for (int i = 0 ; i < nl.getLength(); i++) { 144 sharedRelationships.addElement(new SharedRelationships((Element)nl.item(i))); 145 } 146 147 } 148 153 public void setSharedRelationships(SharedRelationships s) { 154 setDefaultSharedRelationships(s); 155 } 156 157 161 public void setDefaultSharedRelationships(SharedRelationships s) { 162 if (this.sharedRelationships.size() > 0) { 163 this.sharedRelationships.setElementAt(s,0); 164 } else { 165 this.sharedRelationships.addElement(s); 166 } 167 } 168 169 172 public void setSharedRelationshipsVector(Vector s) { 173 sharedRelationships = s; 174 } 175 176 181 public void setName(Name s) { 182 setDefaultName(s); 183 } 184 185 190 public void setName(String s) { 191 setDefaultNameString(s, null); 192 } 193 194 198 public void setDefaultName(Name name) { 199 if (nameVector.size() > 0) { 200 nameVector.setElementAt(name,0); 201 } else { 202 nameVector.addElement(name); 203 } 204 } 205 206 210 public void setDefaultNameString(String value, String lang) { 211 Name name = new Name(value, lang); 212 if (nameVector.size() > 0) { 213 nameVector.setElementAt(name,0); 214 } else { 215 nameVector.addElement(name); 216 } 217 } 218 219 222 public void setNameVector(Vector s) { 223 nameVector = s; 224 } 225 226 231 public void setDescription(Description s) { 232 setDefaultDescription(s); 233 } 234 235 240 public void setDescriptionString(String s) { 241 setDefaultDescriptionString(s,null); 242 } 243 244 250 public void setDefaultDescription(Description s) { 251 if (description.size() > 0) { 252 description.setElementAt(s,0); 253 } else { 254 description.addElement(s); 255 } 256 } 257 258 264 public void setDefaultDescriptionString(String s, String lang) { 265 if (description.size() > 0) { 266 description.setElementAt(new Description(s,lang), 0); 267 } else { 268 description.addElement(new Description(s,lang)); 269 } 270 } 271 272 277 public void setDescriptionVector(Vector s) { 278 description = s; 279 } 280 281 282 public void setBusinessKey(String s) { 283 businessKey = new BusinessKey(s); 284 } 285 286 287 292 public SharedRelationships getSharedRelationships() { 293 return getDefaultSharedRelationships(); 294 } 295 296 301 public SharedRelationships getDefaultSharedRelationships() { 302 if(sharedRelationships.size() > 0) 303 return (SharedRelationships) sharedRelationships.elementAt(0); 304 else 305 return null; 306 } 307 308 313 public Vector getSharedRelationshipsVector() { 314 return sharedRelationships; 315 } 316 317 322 public Name getName() { 323 return getDefaultName(); 324 } 325 326 331 public String getNameString() { 332 return getDefaultNameString(); 333 } 334 335 340 public Name getDefaultName() { 341 if(nameVector.size() > 0) 342 return (Name) nameVector.elementAt(0); 343 else 344 return null; 345 } 346 347 352 public String getDefaultNameString() { 353 if ((nameVector).size() > 0) { 354 return ((Name)nameVector.elementAt(0)).getText(); 355 } else { 356 return null; 357 } 358 } 359 360 365 public Vector getNameVector() { 366 return nameVector ; 367 } 368 369 374 public Description getDescription() { 375 return getDefaultDescription(); 376 } 377 382 public String getDescriptionString() { 383 return getDefaultDescriptionString(); 384 } 385 390 public Description getDefaultDescription() { 391 if(description.size() > 0) 392 return ((Description) description.elementAt(0)); 393 else 394 return null; 395 } 396 401 public String getDefaultDescriptionString() { 402 if(description.size() > 0) 403 return ((Description) description.elementAt(0)).getText(); 404 else 405 return null; 406 } 407 408 413 public Vector getDescriptionVector() { 414 return description; 415 } 416 417 public String getBusinessKey() { 418 return this.businessKey.getText(); 419 } 420 421 430 431 public void saveToXML(Element parent) { 432 base = parent.getOwnerDocument().createElement(UDDI_TAG); 433 if (businessKey!=null) { 435 businessKey.saveToXML(base); 436 } 437 438 if (nameVector!=null && nameVector.size()>0) { 439 for(int i=0; i<nameVector.size(); i++) { 440 ((Name)nameVector.elementAt(i)).saveToXML(base); 441 } 442 } 443 444 if (description!=null && description.size()>0) { 445 for(int i=0; i<description.size(); i++) { 446 ((Description)description.elementAt(i)).saveToXML(base); 447 } 448 } 449 450 if (sharedRelationships!=null && sharedRelationships.size()>0) { 451 for(int i=0; i<sharedRelationships.size(); i++) { 452 ((SharedRelationships)sharedRelationships.elementAt(i)).saveToXML(base); 453 } 454 } 455 parent.appendChild(base); 456 } 457 } 458 | Popular Tags |