1 8 9 package org.uddi4j.request; 10 11 import java.util.Vector ; 12 13 import org.uddi4j.UDDIElement; 14 import org.uddi4j.UDDIException; 15 import org.uddi4j.datatype.business.BusinessEntity; 16 import org.uddi4j.util.AuthInfo; 17 import org.uddi4j.util.UploadRegister; 18 import org.w3c.dom.Element ; 19 import org.w3c.dom.NodeList ; 20 21 47 public class SaveBusiness extends UDDIElement { 48 public static final String UDDI_TAG = "save_business"; 49 50 protected Element base = null; 51 52 AuthInfo authInfo = null; 53 Vector businessEntity = new Vector (); 55 Vector uploadRegister = new Vector (); 57 58 64 public SaveBusiness() { 65 } 66 67 72 public SaveBusiness(String authInfo) { 73 this.authInfo = new AuthInfo( authInfo ); 74 } 75 76 86 public SaveBusiness(Element base) throws UDDIException { 87 super(base); 89 NodeList nl = null; 90 nl = getChildElementsByTagName(base, AuthInfo.UDDI_TAG); 91 if (nl.getLength() > 0) { 92 authInfo = new AuthInfo((Element)nl.item(0)); 93 } 94 nl = getChildElementsByTagName(base, BusinessEntity.UDDI_TAG); 95 for (int i=0; i < nl.getLength(); i++) { 96 businessEntity.addElement(new BusinessEntity((Element)nl.item(i))); 97 } 98 nl = getChildElementsByTagName(base, UploadRegister.UDDI_TAG); 99 for (int i=0; i < nl.getLength(); i++) { 100 uploadRegister.addElement(new UploadRegister((Element)nl.item(i))); 101 } 102 } 103 104 public void setAuthInfo(AuthInfo s) { 105 authInfo = s; 106 } 107 public void setAuthInfo(String s) { 108 authInfo = new AuthInfo(); 109 authInfo.setText(s); 110 } 111 112 117 public void setBusinessEntityVector(Vector s) { 118 businessEntity = s; 119 } 120 121 127 public void setUploadRegisterVector(Vector s) { 128 uploadRegister = s; 129 } 130 131 137 public void setUploadRegisterStrings(Vector s) { 138 uploadRegister = new Vector (); 139 for (int i = 0; i < s.size(); i++) { 140 uploadRegister.addElement( new UploadRegister((String )s.elementAt(i)) ); 141 } 142 } 143 144 public AuthInfo getAuthInfo() { 145 return authInfo; 146 } 147 148 public String getAuthInfoString() { 149 if(authInfo!=null) 150 return authInfo.getText(); 151 else 152 return null; 153 } 154 155 160 public Vector getBusinessEntityVector() { 161 return businessEntity; 162 } 163 164 170 public Vector getUploadRegisterVector() { 171 return uploadRegister; 172 } 173 174 180 public Vector getUploadRegisterStrings() { 181 Vector strings = new Vector (); 182 for (int i = 0; i < uploadRegister.size(); i++) { 183 strings.addElement( ((UploadRegister)uploadRegister.elementAt(i)).getText()); 184 } 185 return strings; 186 } 187 188 197 public void saveToXML(Element parent) { 198 base = parent.getOwnerDocument().createElement(UDDI_TAG); 199 base.setAttribute("generic", UDDIElement.GENERIC); 201 base.setAttribute("xmlns", UDDIElement.XMLNS); 202 if (authInfo!=null) { 203 authInfo.saveToXML(base); 204 } 205 if (businessEntity!=null) { 206 for (int i=0; i < businessEntity.size(); i++) { 207 ((BusinessEntity)(businessEntity.elementAt(i))).saveToXML(base); 208 } 209 } 210 if (uploadRegister!=null) { 211 for (int i=0; i < uploadRegister.size(); i++) { 212 ((UploadRegister)(uploadRegister.elementAt(i))).saveToXML(base); 213 } 214 } 215 parent.appendChild(base); 216 } 217 } 218 | Popular Tags |