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 29 public abstract class CommonRef extends org.netbeans.modules.schema2beans.BaseBean implements DDXmiConstants{ 30 static Vector comparators = new Vector(); 31 private static final org.netbeans.modules.schema2beans.Version runtimeVersion = new org.netbeans.modules.schema2beans.Version(4, 2, 0); 32 private String BINDING_REFERENCE; 33 private String BINDING_REFERENCE_XMI_ID; 34 private String BINDING_REFERENCE_XMI_TYPE; 35 private String BINDING_REFERENCE_JNDI_NAME; 36 private String BINDING_REFERENCE_HREF; 37 static public final String COMMON_REFERENCE="CommonReference"; protected String hrefType=WEB_APPLICATION; 40 public CommonRef(String dtdName, String propName, String xmiIdName, String jndiNamePropName, String hrefPropName, String typePropName) { 41 super(comparators, runtimeVersion); 42 44 BINDING_REFERENCE=propName; 45 BINDING_REFERENCE_XMI_ID=xmiIdName; 46 BINDING_REFERENCE_JNDI_NAME=jndiNamePropName; 47 BINDING_REFERENCE_HREF=hrefPropName; 48 BINDING_REFERENCE_XMI_TYPE=typePropName; 49 initPropertyTables(2); 50 this.createProperty(dtdName, BINDING_REFERENCE, 52 Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY, 53 java.lang.String .class); 54 55 this.createAttribute(BINDING_REFERENCE, HREF_ID, BINDING_REFERENCE_HREF, 56 AttrProp.CDATA | AttrProp.IMPLIED, 57 null, null); 58 this.createAttribute(BINDING_REFERENCE, XMI_TYPE_ID, BINDING_REFERENCE_XMI_TYPE, 59 AttrProp.CDATA | AttrProp.IMPLIED, 60 null, null); 61 } 62 63 64 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 65 comparators.add(c); 66 } 67 68 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 70 comparators.remove(c); 71 } 72 73 74 75 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 76 77 if(getBindingReference()==null) { 78 throw new org.netbeans.modules.schema2beans.ValidateException("getBindingReference() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, COMMON_REFERENCE, this); } 80 if(getHref()==null) { 81 throw new org.netbeans.modules.schema2beans.ValidateException("getHref() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, COMMON_REFERENCE, this); } 83 if(getXmiId()==null) { 84 throw new org.netbeans.modules.schema2beans.ValidateException("getXmiId() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, COMMON_REFERENCE, this); } 86 if(getJndiName()==null) { 87 throw new org.netbeans.modules.schema2beans.ValidateException("getJndiName() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, COMMON_REFERENCE, this); } 89 } 90 public String getBindingReference() { 91 return (String ) this.getValue(BINDING_REFERENCE); 92 } 93 public String getHrefType() { 94 return hrefType; 95 } 96 public void setHrefType(String value) { 97 hrefType=value; 98 } 99 100 public String getHref() { 101 return DDXmi.getIdFromHref((String )this.getAttributeValue(BINDING_REFERENCE, BINDING_REFERENCE_HREF)); 102 } 103 public String getXmiId() { 104 return (String ) getAttributeValue(BINDING_REFERENCE_XMI_ID); 105 } 106 public String getXmiType() { 107 return (String ) getAttributeValue(BINDING_REFERENCE,BINDING_REFERENCE_XMI_TYPE); 108 } 109 public String getJndiName() { 110 return (String ) this.getAttributeValue(BINDING_REFERENCE_JNDI_NAME); 111 } 112 113 public void setBindingReference(String value) { 114 this.setValue(BINDING_REFERENCE, value); 115 } 116 117 public void setHref(String value) { 118 if(getBindingReference()==null) { 119 setBindingReference(""); 120 } 121 if(hrefType.equals(WEB_APPLICATION)) { 122 this.setAttributeValue(BINDING_REFERENCE, BINDING_REFERENCE_HREF,DDXmi.addWebHrefToId(value)); 123 } else if(hrefType.equals(EJB_JAR)) { 124 this.setAttributeValue(BINDING_REFERENCE, BINDING_REFERENCE_HREF,DDXmi.addEjbJarHrefToId(value)); 125 } else if(hrefType.equals(APPLICATION)) { 126 this.setAttributeValue(BINDING_REFERENCE, BINDING_REFERENCE_HREF,DDXmi.addAppHrefToId(value)); 127 } else { 128 this.setAttributeValue(BINDING_REFERENCE, BINDING_REFERENCE_HREF,value); 129 } 130 } 131 public void setXmiId(String value) { 132 this.setAttributeValue(BINDING_REFERENCE_XMI_ID,value); 133 } 134 public void setXmiType(String value) { 135 this.setAttributeValue(BINDING_REFERENCE, BINDING_REFERENCE_XMI_TYPE,value); 136 } 137 public void setJndiName(String value) { 138 this.setAttributeValue(BINDING_REFERENCE_JNDI_NAME,value); 139 } 140 public void dump(StringBuffer str, String indent){ 142 String s; 143 Object o; 144 org.netbeans.modules.schema2beans.BaseBean n; 145 str.append(indent); 146 str.append(BINDING_REFERENCE); str.append(indent+"\t"); str.append("<"); o = this.getBindingReference(); 150 str.append((o==null?"null":o.toString().trim())); str.append(">\n"); this.dumpAttributes(BINDING_REFERENCE, 0, str, indent); 153 154 155 } 156 public String dumpBeanNode(){ 157 StringBuffer str = new StringBuffer (); 158 str.append(getClass().getName()); this.dump(str, "\n "); return str.toString(); 161 } 162 public abstract String getType(); 163 } 164 | Popular Tags |