1 9 10 package org.uddi4j.request; 11 12 import java.util.Vector ; 13 14 import org.uddi4j.UDDIElement; 15 import org.uddi4j.UDDIException; 16 import org.uddi4j.datatype.Name; 17 import org.uddi4j.util.CategoryBag; 18 import org.uddi4j.util.DiscoveryURLs; 19 import org.uddi4j.util.FindQualifiers; 20 import org.uddi4j.util.IdentifierBag; 21 import org.uddi4j.util.TModelBag; 22 import org.w3c.dom.Element ; 23 import org.w3c.dom.NodeList ; 24 25 51 public class FindBusiness extends UDDIElement { 52 public static final String UDDI_TAG = "find_business"; 53 54 protected Element base = null; 55 56 String maxRows = null; 57 FindQualifiers findQualifiers = null; 58 IdentifierBag identifierBag = null; 59 CategoryBag categoryBag = null; 60 TModelBag tModelBag = null; 61 DiscoveryURLs discoveryURLs = null; 62 Vector nameVector = new Vector (); 63 64 70 public FindBusiness() { 71 } 72 73 83 public FindBusiness(Element base) throws UDDIException { 84 super(base); 86 maxRows = base.getAttribute("maxRows"); 87 NodeList nl = null; 88 nl = getChildElementsByTagName(base, FindQualifiers.UDDI_TAG); 89 if (nl.getLength() > 0) { 90 findQualifiers = new FindQualifiers((Element)nl.item(0)); 91 } 92 nl = getChildElementsByTagName(base, Name.UDDI_TAG); 93 for (int i=0; i < nl.getLength(); i++) { 94 nameVector.addElement(new Name((Element)nl.item(i))); 95 } 96 nl = getChildElementsByTagName(base, IdentifierBag.UDDI_TAG); 97 if (nl.getLength() > 0) { 98 identifierBag = new IdentifierBag((Element)nl.item(0)); 99 } 100 nl = getChildElementsByTagName(base, CategoryBag.UDDI_TAG); 101 if (nl.getLength() > 0) { 102 categoryBag = new CategoryBag((Element)nl.item(0)); 103 } 104 nl = getChildElementsByTagName(base, TModelBag.UDDI_TAG); 105 if (nl.getLength() > 0) { 106 tModelBag = new TModelBag((Element)nl.item(0)); 107 } 108 nl = getChildElementsByTagName(base, DiscoveryURLs.UDDI_TAG); 109 if (nl.getLength() > 0) { 110 discoveryURLs = new DiscoveryURLs((Element)nl.item(0)); 111 } 112 } 113 114 public void setMaxRows(String s) { 115 maxRows = s; 116 } 117 public void setMaxRows(int s) { 118 maxRows = Integer.toString(s); 119 } 120 121 public void setFindQualifiers(FindQualifiers s) { 122 findQualifiers = s; 123 } 124 125 130 public void setName(Name s) { 131 setDefaultName(s); 132 } 133 134 139 public void setName(String s) { 140 setDefaultNameString(s,null); 141 } 142 143 147 public void setDefaultName(Name name) { 148 if (nameVector.size() > 0) { 149 nameVector.setElementAt(name,0); 150 } else { 151 nameVector.addElement(name); 152 } 153 } 154 155 159 public void setDefaultNameString(String value, String lang) { 160 Name name = new Name(value, lang); 161 if (nameVector.size() > 0) { 162 nameVector.setElementAt(name,0); 163 } else { 164 nameVector.addElement(name); 165 } 166 } 167 168 171 public void setNameVector(Vector s) { 172 nameVector = s; 173 } 174 175 public void setIdentifierBag(IdentifierBag s) { 176 identifierBag = s; 177 } 178 179 public void setCategoryBag(CategoryBag s) { 180 categoryBag = s; 181 } 182 183 public void setTModelBag(TModelBag s) { 184 tModelBag = s; 185 } 186 187 public void setDiscoveryURLs(DiscoveryURLs s) { 188 discoveryURLs = s; 189 } 190 191 public String getMaxRows() { 192 return maxRows; 193 } 194 195 public int getMaxRowsInt() { 196 return Integer.parseInt(maxRows); 197 } 198 199 public FindQualifiers getFindQualifiers() { 200 return findQualifiers; 201 } 202 203 208 public Name getName() { 209 return getDefaultName(); 210 } 211 212 217 public String getNameString() { 218 return getDefaultNameString(); 219 } 220 221 public Name getDefaultName() { 222 if(nameVector.size() > 0) 223 return (Name) nameVector.elementAt(0); 224 else 225 return null; 226 } 227 228 public String getDefaultNameString() { 229 if ((nameVector).size() > 0) { 230 return ((Name)nameVector.elementAt(0)).getText(); 231 } else { 232 return null; 233 } 234 } 235 236 241 public Vector getNameVector() { 242 return nameVector ; 243 } 244 245 public IdentifierBag getIdentifierBag() { 246 return identifierBag; 247 } 248 249 250 public CategoryBag getCategoryBag() { 251 return categoryBag; 252 } 253 254 255 public TModelBag getTModelBag() { 256 return tModelBag; 257 } 258 259 260 public DiscoveryURLs getDiscoveryURLs() { 261 return discoveryURLs; 262 } 263 264 265 274 public void saveToXML(Element parent) { 275 base = parent.getOwnerDocument().createElement(UDDI_TAG); 276 base.setAttribute("generic", UDDIElement.GENERIC); 278 base.setAttribute("xmlns", UDDIElement.XMLNS); 279 if (maxRows!=null) { 280 base.setAttribute("maxRows", maxRows); 281 } 282 if (findQualifiers!=null) { 283 findQualifiers.saveToXML(base); 284 } 285 if (nameVector!=null) { 286 for (int i=0; i < nameVector.size(); i++) { 287 ((Name)(nameVector.elementAt(i))).saveToXML(base); 288 } 289 } 290 if (identifierBag!=null) { 291 identifierBag.saveToXML(base); 292 } 293 if (categoryBag!=null) { 294 categoryBag.saveToXML(base); 295 } 296 if (tModelBag!=null) { 297 tModelBag.saveToXML(base); 298 } 299 if (discoveryURLs!=null) { 300 discoveryURLs.saveToXML(base); 301 } 302 parent.appendChild(base); 303 } 304 } 305 | Popular Tags |