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.w3c.dom.Element ; 18 import org.w3c.dom.NodeList ; 19 20 44 public class BusinessInfo extends UDDIElement { 45 public static final String UDDI_TAG = "businessInfo"; 46 47 protected Element base = null; 48 49 String businessKey = null; 50 ServiceInfos serviceInfos = null; 51 Vector name = new Vector (); 53 Vector description = new Vector (); 55 56 62 63 public BusinessInfo() { 64 } 65 66 73 public BusinessInfo(String businessKey, 74 String name, 75 ServiceInfos serviceInfos) { 76 this.businessKey = businessKey; 77 this.name.addElement(new Name(name)); 78 this.serviceInfos = serviceInfos; 79 } 80 81 91 92 public BusinessInfo(Element base) throws UDDIException { 93 super(base); 95 businessKey = base.getAttribute("businessKey"); 96 NodeList nl = null; 97 nl = getChildElementsByTagName(base, Name.UDDI_TAG); 98 for(int i=0; i<nl.getLength() ; i++) { 99 name.addElement(new Name((Element)nl.item(i))); 100 } 101 nl = getChildElementsByTagName(base, ServiceInfos.UDDI_TAG); 102 if (nl.getLength() > 0) { 103 serviceInfos = new ServiceInfos((Element)nl.item(0)); 104 } 105 nl = getChildElementsByTagName(base, Description.UDDI_TAG); 106 for (int i=0; i < nl.getLength(); i++) { 107 description.addElement(new Description((Element)nl.item(i))); 108 } 109 } 110 111 public void setBusinessKey(String s) { 112 businessKey = s; 113 } 114 119 public void setName(Name s) { 120 setDefaultName(s); 121 } 122 127 public void setName(String s) { 128 setDefaultNameString(s,null); 129 } 130 134 public void setDefaultName(Name name) { 135 if (this.name.size() > 0) { 136 this.name.setElementAt(name,0); 137 }else{ 138 this.name.addElement(name); 139 } 140 } 141 145 public void setDefaultNameString(String value, String lang) { 146 Name n = new Name(value, lang); 147 if(this.name.size() > 0) { 148 name.setElementAt(n,0); 149 }else{ 150 name.addElement(n); 151 } 152 } 153 156 public void setNameVector(Vector s) { 157 name = s; 158 } 159 160 public void setServiceInfos(ServiceInfos s) { 161 serviceInfos = s; 162 } 163 164 169 public void setDescriptionVector(Vector s) { 170 description = s; 171 } 172 173 178 public void setDefaultDescriptionString(String s) { 179 if (description.size() > 0) { 180 description.setElementAt(new Description(s), 0); 181 } else { 182 description.addElement(new Description(s)); 183 } 184 } 185 186 public String getBusinessKey() { 187 return businessKey; 188 } 189 190 195 public Name getName() { 196 return getDefaultName(); 197 } 198 199 204 public String getNameString() { 205 return getDefaultNameString(); 206 } 207 208 212 public Name getDefaultName() { 213 if(name.size() > 0) { 214 return (Name) name.elementAt(0); 215 }else{ 216 return null; 217 } 218 } 219 220 224 public String getDefaultNameString() { 225 if( name.size() > 0) { 226 return ((Name)name.elementAt(0)).getText(); 227 }else{ 228 return null; 229 } 230 } 231 232 236 public Vector getNameVector() { 237 return name; 238 } 239 240 public ServiceInfos getServiceInfos() { 241 return serviceInfos; 242 } 243 244 245 250 public Vector getDescriptionVector() { 251 return description; 252 } 253 254 259 public String getDefaultDescriptionString() { 260 if ((description).size() > 0) { 261 Description t = (Description)description.elementAt(0); 262 return t.getText(); 263 } else { 264 return null; 265 } 266 } 267 268 277 278 public void saveToXML(Element parent) { 279 base = parent.getOwnerDocument().createElement(UDDI_TAG); 280 if (businessKey!=null) { 282 base.setAttribute("businessKey", businessKey); 283 } 284 if (name!=null) { 285 for (int i=0; i < name.size(); i++) { 286 ((Name)(name.elementAt(i))).saveToXML(base); 287 } 288 } 289 if (description!=null) { 290 for (int i=0; i < description.size(); i++) { 291 ((Description)(description.elementAt(i))).saveToXML(base); 292 } 293 } 294 if (serviceInfos!=null) { 295 serviceInfos.saveToXML(base); 296 } 297 parent.appendChild(base); 298 } 299 } 300 | Popular Tags |