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.Name; 16 import org.w3c.dom.Element ; 17 import org.w3c.dom.NodeList ; 18 19 43 public class ServiceInfo extends UDDIElement { 44 public static final String UDDI_TAG = "serviceInfo"; 45 46 protected Element base = null; 47 48 String serviceKey = null; 49 String businessKey = null; 50 Vector nameVector = new Vector (); 52 53 59 60 public ServiceInfo() { 61 } 62 63 69 public ServiceInfo(String serviceKey, 70 String name) { 71 this.serviceKey = serviceKey; 72 this.nameVector.addElement(new Name(name)); 73 } 74 75 85 86 public ServiceInfo(Element base) throws UDDIException { 87 super(base); 89 serviceKey = base.getAttribute("serviceKey"); 90 businessKey = base.getAttribute("businessKey"); 91 NodeList nl = null; 92 nl = getChildElementsByTagName(base, Name.UDDI_TAG); 93 for (int i=0; i<nl.getLength(); i++) { 94 nameVector.addElement(new Name((Element)nl.item(0))); 95 } 96 } 97 98 public void setServiceKey(String s) { 99 serviceKey = s; 100 } 101 102 public void setBusinessKey(String s) { 103 businessKey = s; 104 } 105 106 111 public void setName(Name s) { 112 setDefaultName(s); 113 } 114 115 120 public void setName(String s) { 121 setDefaultNameString(s, null); 122 } 123 124 128 public void setDefaultName(Name name) { 129 if (nameVector.size() > 0) { 130 nameVector.setElementAt(name,0); 131 } else { 132 nameVector.addElement(name); 133 } 134 } 135 136 140 public void setDefaultNameString(String value, String lang) { 141 Name name = new Name(value, lang); 142 if (nameVector.size() > 0) { 143 nameVector.setElementAt(name,0); 144 } else { 145 nameVector.addElement(name); 146 } 147 } 148 149 152 public void setNameVector(Vector s) { 153 nameVector = s; 154 } 155 156 public String getServiceKey() { 157 return serviceKey; 158 } 159 160 161 public String getBusinessKey() { 162 return businessKey; 163 } 164 165 170 public Name getName() { 171 return getDefaultName(); 172 } 173 174 179 public String getNameString() { 180 return getDefaultNameString(); 181 } 182 183 184 public Name getDefaultName() { 185 return (Name) nameVector.elementAt(0); 186 } 187 188 193 public String getDefaultNameString() { 194 if ((nameVector).size() > 0) { 195 return ((Name)nameVector.elementAt(0)).getText(); 196 } else { 197 return null; 198 } 199 } 200 201 206 public Vector getNameVector() { 207 return nameVector ; 208 } 209 210 219 220 public void saveToXML(Element parent) { 221 base = parent.getOwnerDocument().createElement(UDDI_TAG); 222 if (serviceKey!=null) { 224 base.setAttribute("serviceKey", serviceKey); 225 } 226 if (businessKey!=null) { 227 base.setAttribute("businessKey", businessKey); 228 } 229 if (nameVector!=null && nameVector.size()>0) { 230 for(int i=0;i<nameVector.size();i++) { 231 ((Name)nameVector.elementAt(i)).saveToXML(base); 232 } 233 } 234 parent.appendChild(base); 235 } 236 } 237 | Popular Tags |