1 19 24 25 package org.netbeans.modules.j2ee.sun.dd.impl.app; 26 27 import org.netbeans.modules.j2ee.sun.dd.api.DDException; 28 import org.netbeans.modules.j2ee.sun.dd.api.CommonDDBean; 29 import org.netbeans.modules.j2ee.sun.dd.api.app.SunApplication; 30 import org.netbeans.modules.j2ee.sun.dd.impl.DTDRegistry; 31 32 import org.w3c.dom.Document ; 33 37 public class SunApplicationProxy implements SunApplication { 38 39 private SunApplication appRoot; 40 private String version; 41 private OutputProvider outputProvider; 42 private int ddStatus; 43 private org.xml.sax.SAXParseException error; 44 private java.util.List listeners; 45 46 47 public SunApplicationProxy(SunApplication appRoot, String version) { 48 this.appRoot = appRoot; 49 this.version = version; 50 } 51 52 public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl) { 53 if (appRoot != null) 54 appRoot.addPropertyChangeListener(pcl); 55 listeners.add(pcl); 56 } 57 58 public int addSecurityRoleMapping(org.netbeans.modules.j2ee.sun.dd.api.common.SecurityRoleMapping value) { 59 return appRoot==null?-1:appRoot.addSecurityRoleMapping(value); 60 } 61 62 public int addWeb(org.netbeans.modules.j2ee.sun.dd.api.app.Web value) { 63 return appRoot==null?-1:appRoot.addWeb(value); 64 } 65 66 public String dumpBeanNode() { 67 return appRoot==null?null:appRoot.dumpBeanNode(); 68 } 69 70 public String getPassByReference() { 71 return appRoot==null?null:appRoot.getPassByReference(); 72 } 73 74 public String getRealm() { 75 return appRoot==null?null:appRoot.getRealm(); 76 } 77 78 public org.netbeans.modules.j2ee.sun.dd.api.common.SecurityRoleMapping[] getSecurityRoleMapping() { 79 return appRoot==null?null:appRoot.getSecurityRoleMapping(); 80 } 81 82 public org.netbeans.modules.j2ee.sun.dd.api.common.SecurityRoleMapping getSecurityRoleMapping(int index) { 83 return appRoot==null?null:appRoot.getSecurityRoleMapping(index); 84 } 85 86 public String getUniqueId() { 87 return appRoot==null?null:appRoot.getUniqueId(); 88 } 89 90 public Object getValue(String propertyName) { 91 return appRoot==null?null:appRoot.getValue(propertyName); 92 } 93 94 public java.math.BigDecimal getVersion() { 95 return new java.math.BigDecimal (version); 96 } 97 98 public org.netbeans.modules.j2ee.sun.dd.api.app.Web[] getWeb() { 99 return appRoot==null?null:appRoot.getWeb(); 100 } 101 102 public org.netbeans.modules.j2ee.sun.dd.api.app.Web getWeb(int index) { 103 return appRoot==null?null:appRoot.getWeb(index); 104 } 105 106 public org.netbeans.modules.j2ee.sun.dd.api.common.SecurityRoleMapping newSecurityRoleMapping() { 107 return appRoot==null?null:appRoot.newSecurityRoleMapping(); 108 } 109 110 public org.netbeans.modules.j2ee.sun.dd.api.app.Web newWeb() { 111 return appRoot==null?null:appRoot.newWeb(); 112 } 113 114 public void removePropertyChangeListener(java.beans.PropertyChangeListener pcl) { 115 if (appRoot != null) 116 appRoot.removePropertyChangeListener(pcl); 117 listeners.remove(pcl); 118 } 119 120 public int removeSecurityRoleMapping(org.netbeans.modules.j2ee.sun.dd.api.common.SecurityRoleMapping value) { 121 return appRoot==null?-1:appRoot.removeSecurityRoleMapping(value); 122 } 123 124 public int removeWeb(org.netbeans.modules.j2ee.sun.dd.api.app.Web value) { 125 return appRoot==null?-1:appRoot.removeWeb(value); 126 } 127 128 public void setPassByReference(String value) { 129 if (appRoot!=null) appRoot.setPassByReference(value); 130 } 131 132 public void setRealm(String value) { 133 if (appRoot!=null) appRoot.setRealm(value); 134 } 135 136 public void setSecurityRoleMapping(org.netbeans.modules.j2ee.sun.dd.api.common.SecurityRoleMapping[] value) { 137 if (appRoot!=null) appRoot.setSecurityRoleMapping(value); 138 } 139 140 public void setSecurityRoleMapping(int index, org.netbeans.modules.j2ee.sun.dd.api.common.SecurityRoleMapping value) { 141 if (appRoot!=null) appRoot.setSecurityRoleMapping(index, value); 142 } 143 144 public void setUniqueId(String value) { 145 if (appRoot!=null) appRoot.setUniqueId(value); 146 } 147 148 public void setVersion(java.math.BigDecimal version) { 149 String newVersion = version.toString(); 150 151 if (this.version.equals(newVersion)) 152 return; 153 if (appRoot != null) { 154 Document document = null; 155 if(newVersion.equals(SunApplication.VERSION_5_0_0)){ 156 document = getDocument(); 158 org.netbeans.modules.j2ee.sun.dd.impl.app.model_5_0_0.SunApplication appGraph = 159 org.netbeans.modules.j2ee.sun.dd.impl.app.model_5_0_0.SunApplication.createGraph(document); 160 appGraph.changeDocType(DTDRegistry.SUN_APPLICATION_50_DTD_PUBLIC_ID, DTDRegistry.SUN_APPLICATION_50_DTD_SYSTEM_ID); 161 this.appRoot = appGraph; 162 } 163 if(newVersion.equals(SunApplication.VERSION_1_4_0)){ 164 document = getDocument(); 165 org.netbeans.modules.j2ee.sun.dd.impl.app.model_1_4_0.SunApplication appGraph = 166 org.netbeans.modules.j2ee.sun.dd.impl.app.model_1_4_0.SunApplication.createGraph(document); 167 appGraph.changeDocType(DTDRegistry.SUN_APPLICATION_140_DTD_PUBLIC_ID, DTDRegistry.SUN_APPLICATION_140_DTD_SYSTEM_ID); 168 this.appRoot = appGraph; 169 } 170 if(newVersion.equals(SunApplication.VERSION_1_3_0)){ 171 appRoot.setRealm(null); 172 document = getDocument(); 173 org.netbeans.modules.j2ee.sun.dd.impl.app.model_1_3_0.SunApplication appGraph = 174 org.netbeans.modules.j2ee.sun.dd.impl.app.model_1_3_0.SunApplication.createGraph(document); 175 appGraph.changeDocType(DTDRegistry.SUN_APPCLIENT_130_DTD_PUBLIC_ID, DTDRegistry.SUN_APPLICATION_130_DTD_SYSTEM_ID); 176 this.appRoot = appGraph; 177 } 178 } 179 } 180 181 private Document getDocument(){ 182 Document document = null; 183 if (appRoot instanceof org.netbeans.modules.j2ee.sun.dd.impl.app.model_1_3_0.SunApplication) { 184 document = 185 ((org.netbeans.modules.j2ee.sun.dd.impl.app.model_1_3_0.SunApplication)appRoot).graphManager().getXmlDocument(); 186 }else if (appRoot instanceof org.netbeans.modules.j2ee.sun.dd.impl.app.model_1_4_0.SunApplication) { 187 document = 188 ((org.netbeans.modules.j2ee.sun.dd.impl.app.model_1_4_0.SunApplication)appRoot).graphManager().getXmlDocument(); 189 }else if (appRoot instanceof org.netbeans.modules.j2ee.sun.dd.impl.app.model_5_0_0.SunApplication) { 190 document = 191 ((org.netbeans.modules.j2ee.sun.dd.impl.app.model_5_0_0.SunApplication)appRoot).graphManager().getXmlDocument(); 192 } 193 return document; 194 } 195 196 public void setWeb(org.netbeans.modules.j2ee.sun.dd.api.app.Web[] value) { 197 if (appRoot!=null) appRoot.setWeb(value); 198 } 199 200 public void setWeb(int index, org.netbeans.modules.j2ee.sun.dd.api.app.Web value) { 201 if (appRoot!=null) appRoot.setWeb(index, value); 202 } 203 204 public int sizeSecurityRoleMapping() { 205 return appRoot==null?-1:appRoot.sizeSecurityRoleMapping(); 206 } 207 208 public int sizeWeb() { 209 return appRoot==null?-1:appRoot.sizeWeb(); 210 } 211 212 public void write(java.io.OutputStream os) throws java.io.IOException { 213 if (appRoot!=null) { 214 appRoot.write(os); 215 } 216 } 217 218 public SunApplication getOriginal() { 219 return appRoot; 220 } 221 222 public org.xml.sax.SAXParseException getError() { 223 return error; 224 } 225 public void setError(org.xml.sax.SAXParseException error) { 226 this.error = error; 227 } 228 229 public void setValue(String name, Object [] value) { 230 if (appRoot!=null) appRoot.setValue(name, value); 231 } 232 233 public Object [] getValues(String name) { 234 return appRoot==null?null:appRoot.getValues(name); 235 } 236 237 public void setValue(String name, int index, Object value) { 238 if (appRoot!=null) appRoot.setValue(name, index, value); 239 } 240 241 public void setValue(String name, Object value) { 242 if (appRoot!=null) appRoot.setValue(name, value); 243 } 244 245 public Object getValue(String name, int index) { 246 return appRoot==null?null:appRoot.getValue(name, index); 247 } 248 249 public String getAttributeValue(String name) { 250 return appRoot==null?null:appRoot.getAttributeValue(name); 251 } 252 253 public int size(String name) { 254 return appRoot==null?-1:appRoot.size(name); 255 } 256 257 public int addValue(String name, Object value) { 258 return appRoot==null?-1:appRoot.addValue(name, value); 259 } 260 261 public String [] findPropertyValue(String propName, Object value) { 262 return appRoot==null?null:appRoot.findPropertyValue(propName, value); 263 } 264 265 public int removeValue(String name, Object value) { 266 return appRoot==null?-1:appRoot.removeValue(name, value); 267 } 268 269 public void write(java.io.Writer w) throws java.io.IOException , org.netbeans.modules.j2ee.sun.dd.api.DDException { 270 if (appRoot!=null) appRoot.write(w); 271 } 272 273 public void removeValue(String name, int index) { 274 if (appRoot!=null) appRoot.removeValue(name, index); 275 } 276 277 public Object clone() { 278 SunApplicationProxy proxy = null; 279 if (appRoot==null) 280 proxy = new SunApplicationProxy(null, version); 281 else { 282 SunApplication clonedSunApp=(SunApplication)appRoot.clone(); 283 proxy = new SunApplicationProxy(clonedSunApp, version); 284 } 285 proxy.setError(error); 286 return proxy; 287 } 288 289 public String getAttributeValue(String propName, String name) { 290 return appRoot==null?null:appRoot.getAttributeValue(propName, name); 291 } 292 293 public String getAttributeValue(String propName, int index, String name) { 294 return appRoot==null?null:appRoot.getAttributeValue(propName, index, name); 295 } 296 297 public void setAttributeValue(String name, String value) { 298 if (appRoot!=null) appRoot.setAttributeValue(name, value); 299 } 300 301 public void setAttributeValue(String propName, String name, String value) { 302 if (appRoot!=null) appRoot.setAttributeValue(propName, name, value); 303 } 304 305 public void setAttributeValue(String propName, int index, String name, String value) { 306 if (appRoot!=null) appRoot.setAttributeValue(propName, index, name, value); 307 } 308 309 public CommonDDBean getPropertyParent(String name) { 310 return appRoot.getPropertyParent(name); 311 } 312 313 public void merge(CommonDDBean root, int mode) { 314 if (root != null) { 315 if (root instanceof SunApplicationProxy) 316 appRoot.merge(((SunApplicationProxy)root).getOriginal(), mode); 317 else appRoot.merge(root, mode); 318 } 319 } 320 321 public CommonDDBean cloneVersion(String version) { 322 return appRoot == null ? null : appRoot.cloneVersion(version); 323 } 324 325 public static interface OutputProvider { 326 public void write(SunApplication appRoot) throws java.io.IOException ; 327 } 328 } 329 | Popular Tags |