KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > websphere6 > dd > beans > CommonRef


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

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 /**
26  *
27  * @author dlm198383
28  */

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 JavaDoc BINDING_REFERENCE;
33     private String JavaDoc BINDING_REFERENCE_XMI_ID;
34     private String JavaDoc BINDING_REFERENCE_XMI_TYPE;
35     private String JavaDoc BINDING_REFERENCE_JNDI_NAME;
36     private String JavaDoc BINDING_REFERENCE_HREF;
37     static public final String JavaDoc COMMON_REFERENCE="CommonReference"; //NOI18N
38
protected String JavaDoc hrefType=WEB_APPLICATION; //default value
39

40     public CommonRef(String JavaDoc dtdName, String JavaDoc propName, String JavaDoc xmiIdName, String JavaDoc jndiNamePropName, String JavaDoc hrefPropName, String JavaDoc typePropName) {
41         super(comparators, runtimeVersion);
42         // Properties (see root bean comments for the bean graph)
43

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, // NOI18N
51
BINDING_REFERENCE,
52                 Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY,
53                 java.lang.String JavaDoc.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     //
69
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); // NOI18N
79
}
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); // NOI18N
82
}
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); // NOI18N
85
}
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); // NOI18N
88
}
89     }
90     public String JavaDoc getBindingReference() {
91         return (String JavaDoc) this.getValue(BINDING_REFERENCE);
92     }
93     public String JavaDoc getHrefType() {
94         return hrefType;
95     }
96     public void setHrefType(String JavaDoc value) {
97         hrefType=value;
98     }
99     
100     public String JavaDoc getHref() {
101         return DDXmi.getIdFromHref((String JavaDoc)this.getAttributeValue(BINDING_REFERENCE, BINDING_REFERENCE_HREF));
102     }
103     public String JavaDoc getXmiId() {
104         return (String JavaDoc) getAttributeValue(BINDING_REFERENCE_XMI_ID);
105     }
106      public String JavaDoc getXmiType() {
107         return (String JavaDoc) getAttributeValue(BINDING_REFERENCE,BINDING_REFERENCE_XMI_TYPE);
108     }
109     public String JavaDoc getJndiName() {
110         return (String JavaDoc) this.getAttributeValue(BINDING_REFERENCE_JNDI_NAME);
111     }
112     
113     public void setBindingReference(String JavaDoc value) {
114         this.setValue(BINDING_REFERENCE, value);
115     }
116     
117     public void setHref(String JavaDoc 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 JavaDoc value) {
132         this.setAttributeValue(BINDING_REFERENCE_XMI_ID,value);
133     }
134     public void setXmiType(String JavaDoc value) {
135         this.setAttributeValue(BINDING_REFERENCE, BINDING_REFERENCE_XMI_TYPE,value);
136     }
137     public void setJndiName(String JavaDoc value) {
138         this.setAttributeValue(BINDING_REFERENCE_JNDI_NAME,value);
139     }
140     // Dump the content of this bean returning it as a String
141
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
142         String JavaDoc s;
143         Object JavaDoc o;
144         org.netbeans.modules.schema2beans.BaseBean n;
145         str.append(indent);
146         str.append(BINDING_REFERENCE); // NOI18N
147
str.append(indent+"\t"); // NOI18N
148
str.append("<"); // NOI18N
149
o = this.getBindingReference();
150         str.append((o==null?"null":o.toString().trim())); // NOI18N
151
str.append(">\n"); // NOI18N
152
this.dumpAttributes(BINDING_REFERENCE, 0, str, indent);
153         
154         
155     }
156     public String JavaDoc dumpBeanNode(){
157         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
158         str.append(getClass().getName()); // NOI18N
159
this.dump(str, "\n "); // NOI18N
160
return str.toString();
161     }
162     public abstract String JavaDoc getType();
163 }
164
Popular Tags