1 9 10 package org.uddi4j.datatype.tmodel; 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.OverviewDoc; 19 import org.uddi4j.util.CategoryBag; 20 import org.uddi4j.util.IdentifierBag; 21 import org.w3c.dom.Element ; 22 import org.w3c.dom.NodeList ; 23 24 52 public class TModel extends UDDIElement { 53 public static final String UDDI_TAG = "tModel"; 54 55 56 58 62 public static final String TYPES_TMODEL_KEY = "UUID:C1ACF26D-9672-4404-9D70-39B756E62AB4"; 63 64 70 public static final String NAICS_TMODEL_KEY = "UUID:C0B9FE13-179F-413D-8A5B-5004DB8E5BB2"; 71 72 79 public static final String UNSPSC_TMODEL_KEY = "UUID:DB77450D-9FA8-45D4-A7BC-04411D14E384"; 80 81 86 public static final String UNSPSC_73_TMODEL_KEY = "UUID:CD153257-086A-4237-B336-6BDCBDCC6634"; 87 88 92 public static final String ISO_CH_TMODEL_KEY = "UUID:4E49A8D6-D5A2-4FC2-93A0-0411D8D19E88"; 93 94 98 public static final String GENERAL_KEYWORDS_TMODEL_KEY = "UUID:A035A07C-F362-44dd-8F95-E2B134BF43B4"; 99 100 106 public static final String OWNING_BUSINESS_TMODEL_KEY = "UUID:4064C064-6D14-4F35-8953-9652106476A9"; 107 108 113 public static final String RELATIONSHIPS_TMODEL_KEY = "UUID:807A2C6A-EE22-470D-ADC7-E0424A337C03"; 114 115 119 public static final String OPERATORS_TMODEL_KEY = "UUID:327A56F0-3299-4461-BC23-5CD513E95C55"; 120 121 125 public static final String D_U_N_S_TMODEL_KEY = "UUID:8609C81E-EE1F-4D5A-B202-3EB13AD01823"; 126 127 132 public static final String THOMAS_REGISTER_TMODEL_KEY = "UUID:B1B1BAF5-2329-43E6-AE13-BA8E97195039"; 133 134 140 public static final String IS_REPLACED_BY_TMODEL_KEY = "UUID:E59AE320-77A5-11D5-B898-0004AC49CC1E"; 141 142 148 public static final String SMTP_TMODEL_KEY = "UUID:93335D49-3EFB-48A0-ACEA-EA102B60DDC6"; 149 150 156 public static final String FAX_TMODEL_KEY = "UUID:1A2B00BE-6E2C-42F5-875B-56F32686E0E7"; 157 158 163 public static final String FTP_TMODEL_KEY = "UUID:5FCF5CD0-629A-4C50-8B16-F94E9CF2A674"; 164 165 170 public static final String TELEPHONE_TMODEL_KEY = "UUID:38E12427-5536-4260-A6F9-B5B530E63A07"; 171 172 177 public static final String HTTP_TMODEL_KEY = "UUID:68DE9E80-AD09-469D-8A37-088422BFBC36"; 178 179 184 public static final String HOMEPAGE_TMODEL_KEY = "UUID:4CEC1CEF-1F68-4B23-8CB7-8BAA763AEB89"; 185 186 protected Element base = null; 187 188 String tModelKey = null; 189 String operator = null; 190 String authorizedName = null; 191 Name name = null; 192 OverviewDoc overviewDoc = null; 193 IdentifierBag identifierBag = null; 194 CategoryBag categoryBag = null; 195 Vector description = new Vector (); 197 198 204 public TModel() { 205 } 206 207 213 public TModel(String tModelKey, 214 String name) { 215 this.tModelKey = tModelKey; 216 this.name = new Name(name); 217 } 218 219 229 public TModel(Element base) throws UDDIException { 230 super(base); 232 tModelKey = base.getAttribute("tModelKey"); 233 operator = getAttr(base,"operator"); 234 authorizedName = getAttr(base,"authorizedName"); 235 NodeList nl = null; 236 nl = getChildElementsByTagName(base, Name.UDDI_TAG); 237 if (nl.getLength() > 0) { 238 name = new Name((Element)nl.item(0)); 239 if( null != name ) 241 name.setLang(null); 242 } 243 nl = getChildElementsByTagName(base, OverviewDoc.UDDI_TAG); 244 if (nl.getLength() > 0) { 245 overviewDoc = new OverviewDoc((Element)nl.item(0)); 246 } 247 nl = getChildElementsByTagName(base, IdentifierBag.UDDI_TAG); 248 if (nl.getLength() > 0) { 249 identifierBag = new IdentifierBag((Element)nl.item(0)); 250 } 251 nl = getChildElementsByTagName(base, CategoryBag.UDDI_TAG); 252 if (nl.getLength() > 0) { 253 categoryBag = new CategoryBag((Element)nl.item(0)); 254 } 255 nl = getChildElementsByTagName(base, Description.UDDI_TAG); 256 for (int i=0; i < nl.getLength(); i++) { 257 description.addElement(new Description((Element)nl.item(i))); 258 } 259 } 260 261 private String getAttr(Element base, String attrname) 262 { 263 if(base.getAttributeNode(attrname)!=null && base.getAttributeNode(attrname).getSpecified() ) 264 { 265 return base.getAttribute(attrname); 266 } 267 return null; 268 } 269 270 public void setTModelKey(String s) { 271 tModelKey = s; 272 } 273 274 public void setOperator(String s) { 275 operator = s; 276 } 277 278 public void setAuthorizedName(String s) { 279 authorizedName = s; 280 } 281 282 public void setName(Name s) { 283 name = s; 284 } 285 public void setName(String s) { 286 name = new Name(); 287 name.setText(s); 288 } 289 290 public void setOverviewDoc(OverviewDoc s) { 291 overviewDoc = s; 292 } 293 294 public void setIdentifierBag(IdentifierBag s) { 295 identifierBag = s; 296 } 297 298 public void setCategoryBag(CategoryBag s) { 299 categoryBag = s; 300 } 301 302 307 public void setDescriptionVector(Vector s) { 308 description = s; 309 } 310 311 316 public void setDefaultDescriptionString(String s) { 317 if (description.size() > 0) { 318 description.setElementAt(new Description(s), 0); 319 } else { 320 description.addElement(new Description(s)); 321 } 322 } 323 324 public String getTModelKey() { 325 return tModelKey; 326 } 327 328 public String getOperator() { 329 return operator; 330 } 331 332 public String getAuthorizedName() { 333 return authorizedName; 334 } 335 336 public Name getName() { 337 return name; 338 } 339 340 public String getNameString() { 341 return name.getText(); 342 } 343 344 public OverviewDoc getOverviewDoc() { 345 return overviewDoc; 346 } 347 348 349 public IdentifierBag getIdentifierBag() { 350 return identifierBag; 351 } 352 353 354 public CategoryBag getCategoryBag() { 355 return categoryBag; 356 } 357 358 359 364 public Vector getDescriptionVector() { 365 return description; 366 } 367 368 373 public String getDefaultDescriptionString() { 374 if ((description).size() > 0) { 375 Description t = (Description)description.elementAt(0); 376 return t.getText(); 377 } else { 378 return null; 379 } 380 } 381 382 391 public void saveToXML(Element parent) { 392 base = parent.getOwnerDocument().createElement(UDDI_TAG); 393 if (tModelKey!=null) { 395 base.setAttribute("tModelKey", tModelKey); 396 } 397 if (operator!=null) { 398 base.setAttribute("operator", operator); 399 } 400 if (authorizedName!=null) { 401 base.setAttribute("authorizedName", authorizedName); 402 } 403 if (name!=null) { 404 name.setLang(null); 406 name.saveToXML(base); 407 } 408 if (description!=null) { 409 for (int i=0; i < description.size(); i++) { 410 ((Description)(description.elementAt(i))).saveToXML(base); 411 } 412 } 413 if (overviewDoc!=null) { 414 overviewDoc.saveToXML(base); 415 } 416 if (identifierBag!=null) { 417 identifierBag.saveToXML(base); 418 } 419 if (categoryBag!=null) { 420 categoryBag.saveToXML(base); 421 } 422 parent.appendChild(base); 423 } 424 } 425 | Popular Tags |