1 8 9 package org.uddi4j.datatype.binding; 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.w3c.dom.Element ; 17 import org.w3c.dom.NodeList ; 18 19 41 public class BindingTemplate extends UDDIElement { 42 public static final String UDDI_TAG = "bindingTemplate"; 43 44 protected Element base = null; 45 46 String bindingKey = null; 47 String serviceKey = null; 48 AccessPoint accessPoint = null; 49 HostingRedirector hostingRedirector = null; 50 TModelInstanceDetails tModelInstanceDetails = null; 51 Vector description = new Vector (); 53 54 61 public BindingTemplate() { 62 } 63 64 73 public BindingTemplate(String bindingKey, 74 TModelInstanceDetails tModelInstanceDetails) { 75 this.bindingKey = bindingKey; 76 this.tModelInstanceDetails = tModelInstanceDetails; 77 } 78 79 86 public BindingTemplate(String bindingKey, 87 TModelInstanceDetails tModelInstanceDetails, 88 AccessPoint accessPoint) { 89 this.bindingKey = bindingKey; 90 this.tModelInstanceDetails = tModelInstanceDetails; 91 this.accessPoint = accessPoint; 92 } 93 94 101 public BindingTemplate(String bindingKey, 102 TModelInstanceDetails tModelInstanceDetails, 103 HostingRedirector hostingRedirector) { 104 this.bindingKey = bindingKey; 105 this.tModelInstanceDetails = tModelInstanceDetails; 106 this.hostingRedirector = hostingRedirector; 107 } 108 109 119 public BindingTemplate(Element base) throws UDDIException { 120 super(base); 122 bindingKey = base.getAttribute("bindingKey"); 123 serviceKey = getAttr(base,"serviceKey"); 124 NodeList nl = null; 125 nl = getChildElementsByTagName(base, AccessPoint.UDDI_TAG); 126 if (nl.getLength() > 0) { 127 accessPoint = new AccessPoint((Element)nl.item(0)); 128 } 129 nl = getChildElementsByTagName(base, HostingRedirector.UDDI_TAG); 130 if (nl.getLength() > 0) { 131 hostingRedirector = new HostingRedirector((Element)nl.item(0)); 132 } 133 nl = getChildElementsByTagName(base, TModelInstanceDetails.UDDI_TAG); 134 if (nl.getLength() > 0) { 135 tModelInstanceDetails = new TModelInstanceDetails((Element)nl.item(0)); 136 } 137 nl = getChildElementsByTagName(base, Description.UDDI_TAG); 138 for (int i=0; i < nl.getLength(); i++) { 139 description.addElement(new Description((Element)nl.item(i))); 140 } 141 } 142 143 private String getAttr(Element base, String attrname) 144 { 145 if(base.getAttributeNode(attrname)!=null && base.getAttributeNode(attrname).getSpecified() ) 146 { 147 return base.getAttribute(attrname); 148 } 149 return null; 150 } 151 152 public void setBindingKey(String s) { 153 bindingKey = s; 154 } 155 156 public void setServiceKey(String s) { 157 serviceKey = s; 158 } 159 160 public void setAccessPoint(AccessPoint s) { 161 accessPoint = s; 162 if( accessPoint != null && hostingRedirector != null ) 164 hostingRedirector = null; 165 } 166 167 public void setHostingRedirector(HostingRedirector s) { 168 hostingRedirector = s; 169 if( hostingRedirector != null && accessPoint != null ) 171 accessPoint = null; 172 } 173 174 public void setTModelInstanceDetails(TModelInstanceDetails s) { 175 tModelInstanceDetails = s; 176 } 177 178 183 public void setDescriptionVector(Vector s) { 184 description = s; 185 } 186 187 192 public void setDefaultDescriptionString(String s) { 193 if (description.size() > 0) { 194 description.setElementAt(new Description(s), 0); 195 } else { 196 description.addElement(new Description(s)); 197 } 198 } 199 200 public String getBindingKey() { 201 return bindingKey; 202 } 203 204 205 public String getServiceKey() { 206 return serviceKey; 207 } 208 209 210 public AccessPoint getAccessPoint() { 211 return accessPoint; 212 } 213 214 215 public HostingRedirector getHostingRedirector() { 216 return hostingRedirector; 217 } 218 219 220 public TModelInstanceDetails getTModelInstanceDetails() { 221 return tModelInstanceDetails; 222 } 223 224 225 230 public Vector getDescriptionVector() { 231 return description; 232 } 233 234 239 public String getDefaultDescriptionString() { 240 if ((description).size() > 0) { 241 Description t = (Description)description.elementAt(0); 242 return t.getText(); 243 } else { 244 return null; 245 } 246 } 247 248 257 public void saveToXML(Element parent) { 258 base = parent.getOwnerDocument().createElement(UDDI_TAG); 259 if (bindingKey!=null) { 261 base.setAttribute("bindingKey", bindingKey); 262 } 263 if (serviceKey!=null) { 264 base.setAttribute("serviceKey", serviceKey); 265 } 266 if (description!=null) { 267 for (int i=0; i < description.size(); i++) { 268 ((Description)(description.elementAt(i))).saveToXML(base); 269 } 270 } 271 if (accessPoint!=null) { 272 accessPoint.saveToXML(base); 273 } 274 if (hostingRedirector!=null) { 275 hostingRedirector.saveToXML(base); 276 } 277 if (tModelInstanceDetails!=null) { 278 tModelInstanceDetails.saveToXML(base); 279 } 280 parent.appendChild(base); 281 } 282 } 283 | Popular Tags |