KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > serverresources > BaseResource


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 /*
20  * BaseResource.java
21  *
22  * Created on August 10, 2005, 5:34 PM
23  *
24  */

25
26 package org.netbeans.modules.j2ee.sun.share.serverresources;
27
28 import java.beans.*;
29
30 import org.netbeans.modules.j2ee.sun.dd.api.DDProvider;
31 import org.netbeans.modules.j2ee.sun.dd.api.serverresources.Resources;
32 import org.netbeans.modules.j2ee.sun.dd.api.serverresources.PropertyElement;
33
34 import org.netbeans.modules.j2ee.sun.ide.editors.NameValuePair;
35
36
37 /**
38  *
39  * @author Nitya Doraisamy
40  */

41 public class BaseResource extends Object JavaDoc implements java.io.Serializable JavaDoc {
42
43     protected String JavaDoc name;
44     protected String JavaDoc description;
45     protected NameValuePair[] extraParams;
46     
47     transient protected PropertyChangeSupport propertySupport;
48     
49     /** Creates a new instance of BaseResource */
50     public BaseResource() {
51         propertySupport = new PropertyChangeSupport(this);
52     }
53     
54     protected void initPropertyChangeSupport(){
55         if(propertySupport==null){
56             propertySupport = new PropertyChangeSupport ( this );
57         }
58
59     }
60     
61     public void addPropertyChangeListener (PropertyChangeListener listener) {
62         initPropertyChangeSupport();
63         propertySupport.addPropertyChangeListener (listener);
64     }
65
66     public void removePropertyChangeListener (PropertyChangeListener listener) {
67         initPropertyChangeSupport();
68         propertySupport.removePropertyChangeListener (listener);
69     }
70     
71     public String JavaDoc getName() {
72         return name;
73     }
74     public void setName(String JavaDoc value) {
75         String JavaDoc oldValue = name;
76         this.name = value;
77         initPropertyChangeSupport();
78         propertySupport.firePropertyChange ("name", oldValue, name);//NOI18N
79
}
80     
81     public String JavaDoc getDescription() {
82         return description;
83     }
84     public void setDescription(String JavaDoc value) {
85         String JavaDoc oldValue = description;
86         this.description = value;
87         initPropertyChangeSupport();
88         propertySupport.firePropertyChange ("description", oldValue, description);//NOI18N
89
}
90     
91     public NameValuePair[] getExtraParams() {
92         if(this.extraParams == null){
93             this.extraParams = new NameValuePair[0];
94         }
95         return this.extraParams;
96     }
97     public void setExtraParams(Object JavaDoc[] value) {
98         NameValuePair[] pairs = new NameValuePair[value.length];
99         for (int i = 0; i < value.length; i++) {
100             NameValuePair val = (NameValuePair)value[i];
101             NameValuePair pair = new NameValuePair();
102             pair.setParamName(val.getParamName());
103             pair.setParamValue(val.getParamValue());
104             //pair.setParamDescription(val.getParamDescription());
105
pairs[i] = pair;
106         }
107         NameValuePair[] oldValue = extraParams;
108         this.extraParams = pairs;
109         initPropertyChangeSupport();
110         propertySupport.firePropertyChange ("extraParams", oldValue, extraParams);//NOI18N
111
}
112     
113     public Resources getResourceGraph(){
114         return DDProvider.getDefault().getResourcesGraph();
115     }
116     
117     public PropertyElement populatePropertyElement(PropertyElement prop, NameValuePair pair){
118         prop.setName(pair.getParamName());
119         prop.setValue(pair.getParamValue());
120         return prop;
121     }
122 }
123
Popular Tags