1 19 package org.netbeans.modules.j2ee.websphere6.dd.beans; 20 21 import org.w3c.dom.*; 22 import org.netbeans.modules.schema2beans.*; 23 import java.beans.*; 24 import java.util.*; 25 import java.io.*; 26 27 31 public class WSAppExt extends DDXmi{ 32 private static final String ROOT=TYPE_APP_EXT_APP_ID; 33 34 private static final String ROOT_NAME="ApplicationExt"; 35 36 37 public WSAppExt() { 38 this(null, Common.USE_DEFAULT_VALUES); 39 } 40 public WSAppExt(org.w3c.dom.Node doc, int options) { 41 this(Common.NO_DEFAULT_VALUES); 42 try { 43 initFromNode(doc, options); 44 } catch (Schema2BeansException e) { 45 throw new RuntimeException (e); 46 } 47 } 48 public WSAppExt(int options) { 49 super(options,ROOT); 50 } 52 53 public WSAppExt(File f,boolean validate) throws IOException{ 54 this(GraphManager.createXmlDocument(new FileInputStream(f), validate), Common.NO_DEFAULT_VALUES); 55 } 56 57 public WSAppExt(InputStream in, boolean validate) { 58 this(GraphManager.createXmlDocument(in, validate), Common.NO_DEFAULT_VALUES); 59 } 60 61 protected void initFromNode(org.w3c.dom.Node doc, int options) throws Schema2BeansException { 62 if (doc == null) { 63 doc = GraphManager.createRootElementNode(ROOT); if (doc == null) 65 throw new Schema2BeansException(Common.getMessage( 66 "CantCreateDOMRoot_msg", ROOT)); 67 } 68 Node n = GraphManager.getElementNode(ROOT, doc); if (n == null) { 70 throw new Schema2BeansException(Common.getMessage("DocRootNotInDOMGraph_msg", ROOT, doc.getFirstChild().getNodeName())); 71 } 72 this.graphManager.setXmlDocument(doc); 73 this.createBean(n, this.graphManager()); 74 this.initialize(options); 75 }; 76 77 public void initialize(int options) { 78 79 } 80 81 public void setDefaults() { 82 setXmiVersion(); 83 setNsXmi(); 84 setNsXsi(); 85 setNsAppExt(); 86 setNsApp(); 87 setXmiId("Application_ID_Ext"); 88 setApplicationHref("Application_ID"); 89 } 90 91 protected void initOptions(int options) { 92 this.graphManager = new GraphManager(this); 93 this.createRoot(ROOT, ROOT_NAME, Common.TYPE_1 | Common.TYPE_BEAN, WSAppExt.class); 95 96 initPropertyTables(2); 97 this.createAttribute(XMI_ID_ID, XMI_ID, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 98 this.createAttribute(NS_APP_ID, NS_APP, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 99 this.createAttribute(NS_APP_EXT_ID, NS_APP_EXT, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 100 this.createAttribute(NS_XMI_ID, NS_XMI, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 101 this.createAttribute(NS_XSI_ID, NS_XSI, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 102 this.createAttribute(XMI_VERSION_ID,XMI_VERSION, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 103 this.createAttribute(RELOAD_ENABLED_ID,RELOAD_ENABLED, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 104 this.createAttribute(RELOAD_INTERVAL_ID,RELOAD_INTERVAL, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 105 this.createAttribute(SHARED_SESSION_CONTEXT_ID,SHARED_SESSION_CONTEXT, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 106 107 this.createProperty(MODULE_EXTENSIONS_ID, 108 MODULE_EXTENSIONS, 109 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 110 ModuleExtensionsType.class); 111 this.createAttribute(MODULE_EXTENSIONS,XMI_TYPE_ID, MODULE_EXTENSIONS_XMI_TYPE,AttrProp.CDATA | AttrProp.IMPLIED,null, null); 112 this.createAttribute(MODULE_EXTENSIONS,ALT_ROOT_ID , MODULE_EXTENSIONS_ALT_ROOT ,AttrProp.CDATA | AttrProp.IMPLIED,null, null); 113 this.createAttribute(MODULE_EXTENSIONS,ALT_BINDINGS_ID, MODULE_EXTENSIONS_ALT_BINDINGS ,AttrProp.CDATA | AttrProp.IMPLIED,null, null); 114 this.createAttribute(MODULE_EXTENSIONS,ALT_EXTENSIONS_ID , MODULE_EXTENSIONS_ALT_EXTENSIONS ,AttrProp.CDATA | AttrProp.IMPLIED,null, null); 115 this.createAttribute(MODULE_EXTENSIONS,XMI_ID_ID , MODULE_EXTENSIONS_XMI_ID ,AttrProp.CDATA | AttrProp.IMPLIED,null, null); 116 117 this.createProperty(APPLICATION_ID, 118 APPLICATION, 119 Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY, 120 java.lang.String .class); 121 this.createAttribute(APPLICATION,HREF_ID,APPLICATION_HREF,AttrProp.CDATA | AttrProp.IMPLIED,null, null); 122 this.initialize(options); 123 } 124 125 public void setModuleExtensions(int index,ModuleExtensionsType value) { 126 this.setValue(MODULE_EXTENSIONS, index,value); 127 } 128 129 public void setModuleExtensions(ModuleExtensionsType[]value) { 130 this.setValue(MODULE_EXTENSIONS, value); 131 } 132 public ModuleExtensionsType[] getModuleExtensions() { 134 return (ModuleExtensionsType[])this.getValues(MODULE_EXTENSIONS); 135 } 136 public ModuleExtensionsType getModuleExtensions(int index) { 137 return (ModuleExtensionsType)this.getValue(MODULE_EXTENSIONS,index); 138 } 139 public int sizeModuleExtensions() { 140 return this.size(MODULE_EXTENSIONS); 141 } 142 public int addModuleExtensions(ModuleExtensionsType value) { 143 int positionOfNewItem = this.addValue(MODULE_EXTENSIONS, value); 144 return positionOfNewItem; 145 } 146 147 148 public int removeModuleExtensions(ModuleExtensionsType value) { 149 return this.removeValue(MODULE_EXTENSIONS, value); 150 } 151 152 public void setSharedSession(boolean value) { 153 this.setAttributeValue(SHARED_SESSION_CONTEXT, (value==true)?"true":"false"); 154 } 155 public boolean getSharedSession() { 157 String getSharedSting=this.getAttributeValue(SHARED_SESSION_CONTEXT); 158 if(getSharedSting==null) return false; 159 else return (getSharedSting.equals("true")?true:false); 160 } 161 162 163 164 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 165 if (getModuleExtensions()!= null) { 166 for (int _index = 0; _index < sizeModuleExtensions(); ++_index) { 168 ModuleExtensionsType element = getModuleExtensions(_index); 169 if (element != null) { 170 element.validate(); 171 } 172 } 173 } 174 if (getApplication()== null) { 175 throw new org.netbeans.modules.schema2beans.ValidateException("getApplication() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, APPLICATION, this); } 177 if(getApplicationHref()==null) { 178 throw new org.netbeans.modules.schema2beans.ValidateException("getApplicationHref() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, APPLICATION, this); } 180 if(getNsApp()==null) { 181 throw new org.netbeans.modules.schema2beans.ValidateException("getNsApp() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 183 if(getNsAppExt()==null) { 184 throw new org.netbeans.modules.schema2beans.ValidateException("getNsAppExt() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 186 if(getNsCommon()==null) { 187 throw new org.netbeans.modules.schema2beans.ValidateException("getNsCommon() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 189 if(getNsXmi()==null) { 190 throw new org.netbeans.modules.schema2beans.ValidateException("getNsXmi() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 192 if(getXmiId()==null) { 193 throw new org.netbeans.modules.schema2beans.ValidateException("getXmiId() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 195 if(getXmiVersion()==null) { 196 throw new org.netbeans.modules.schema2beans.ValidateException("getXmiVersion() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 198 199 } 200 201 public void dump(StringBuffer str, String indent){ 202 String s; 203 Object o; 204 BaseBean n; 205 206 str.append(indent); 207 str.append(MODULE_EXTENSIONS+"["+this.sizeModuleExtensions()+"]"); for(int i=0; i<this.sizeModuleExtensions(); i++) { 209 str.append(indent+"\t"); 210 str.append("#"+i+":"); 211 n = (BaseBean) this.getModuleExtensions(i); 212 if (n != null) 213 n.dump(str, indent + "\t"); else 215 str.append(indent+"\tnull"); this.dumpAttributes(MODULE_EXTENSIONS, i, str, indent); 217 } 218 str.append(indent); 219 str.append(APPLICATION); str.append(indent+"\t"); str.append("<"); o = this.getApplication(); 223 str.append((o==null?"null":o.toString().trim())); str.append(">\n"); this.dumpAttributes(APPLICATION, 0, str, indent); 226 } 227 public String dumpBeanNode(){ 228 StringBuffer str = new StringBuffer (); 229 str.append(getClass().getName()); this.dump(str, "\n "); return str.toString(); 232 } 233 } 234 | Popular Tags |