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.FindQualifiers; 19 import org.uddi4j.util.TModelBag; 20 import org.w3c.dom.Element ; 21 import org.w3c.dom.NodeList ; 22 23 49 public class FindService extends UDDIElement { 50 public static final String UDDI_TAG = "find_service"; 51 52 protected Element base = null; 53 54 String maxRows = null; 55 String businessKey = null; 56 FindQualifiers findQualifiers = null; 57 CategoryBag categoryBag = null; 58 TModelBag tModelBag = null; 59 Vector nameVector = new Vector (); 60 61 67 public FindService() { 68 } 69 70 75 public FindService(String businessKey) { 76 this.businessKey = businessKey; 77 } 78 79 89 public FindService(Element base) throws UDDIException { 90 super(base); 92 maxRows = base.getAttribute("maxRows"); 93 businessKey = base.getAttribute("businessKey"); 94 NodeList nl = null; 95 nl = getChildElementsByTagName(base, FindQualifiers.UDDI_TAG); 96 if (nl.getLength() > 0) { 97 findQualifiers = new FindQualifiers((Element)nl.item(0)); 98 } 99 nl = getChildElementsByTagName(base, Name.UDDI_TAG); 100 for (int i=0; i < nl.getLength(); i++) { 101 nameVector.addElement(new Name((Element)nl.item(i))); 102 } 103 nl = getChildElementsByTagName(base, CategoryBag.UDDI_TAG); 104 if (nl.getLength() > 0) { 105 categoryBag = new CategoryBag((Element)nl.item(0)); 106 } 107 nl = getChildElementsByTagName(base, TModelBag.UDDI_TAG); 108 if (nl.getLength() > 0) { 109 tModelBag = new TModelBag((Element)nl.item(0)); 110 } 111 } 112 113 public void setMaxRows(String s) { 114 maxRows = s; 115 } 116 public void setMaxRows(int s) { 117 maxRows = Integer.toString(s); 118 } 119 120 public void setBusinessKey(String s) { 121 businessKey = s; 122 } 123 124 public void setFindQualifiers(FindQualifiers s) { 125 findQualifiers = s; 126 } 127 128 133 public void setName(Name s) { 134 setDefaultName(s); 135 } 136 137 142 public void setName(String s) { 143 setDefaultNameString(s,null); 144 } 145 146 150 public void setDefaultName(Name name) { 151 if (nameVector.size() > 0) { 152 nameVector.setElementAt(name,0); 153 } else { 154 nameVector.addElement(name); 155 } 156 } 157 158 162 public void setDefaultNameString(String value, String lang) { 163 Name name = new Name(value, lang); 164 if (nameVector.size() > 0) { 165 nameVector.setElementAt(name,0); 166 } else { 167 nameVector.addElement(name); 168 } 169 } 170 171 174 public void setNameVector(Vector s) { 175 nameVector = s; 176 } 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 String getMaxRows() { 188 return maxRows; 189 } 190 191 public int getMaxRowsInt() { 192 return Integer.parseInt(maxRows); 193 } 194 195 public String getBusinessKey() { 196 return businessKey; 197 } 198 199 200 public FindQualifiers getFindQualifiers() { 201 return findQualifiers; 202 } 203 204 209 public Name getName() { 210 return getDefaultName(); 211 } 212 213 218 public String getNameString() { 219 return getDefaultNameString(); 220 } 221 222 public Name getDefaultName() { 223 if(nameVector.size() > 0) 224 return (Name) nameVector.elementAt(0); 225 else 226 return null; 227 } 228 229 public String getDefaultNameString() { 230 if ((nameVector).size() > 0) { 231 return ((Name)nameVector.elementAt(0)).getText(); 232 } else { 233 return null; 234 } 235 } 236 237 242 public Vector getNameVector() { 243 return nameVector ; 244 } 245 246 public CategoryBag getCategoryBag() { 247 return categoryBag; 248 } 249 250 public TModelBag getTModelBag() { 251 return tModelBag; 252 } 253 254 263 public void saveToXML(Element parent) { 264 base = parent.getOwnerDocument().createElement(UDDI_TAG); 265 base.setAttribute("generic", UDDIElement.GENERIC); 267 base.setAttribute("xmlns", UDDIElement.XMLNS); 268 if (maxRows!=null) { 269 base.setAttribute("maxRows", maxRows); 270 } 271 if (businessKey!=null) { 272 base.setAttribute("businessKey", businessKey); 273 } 274 if (findQualifiers!=null) { 275 findQualifiers.saveToXML(base); 276 } 277 if (nameVector!=null) { 278 for (int i=0; i < nameVector.size(); i++) { 279 ((Name)(nameVector.elementAt(i))).saveToXML(base); 280 } 281 } 282 if (categoryBag!=null) { 283 categoryBag.saveToXML(base); 284 } 285 if (tModelBag!=null) { 286 tModelBag.saveToXML(base); 287 } 288 parent.appendChild(base); 289 } 290 } 291 | Popular Tags |