KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > monitor > data > ContextData


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 /**
21  * ContextData.java
22  *
23  *
24  * Created: Wed Jan 16 17:08:27 2002
25  *
26  * @author Ana von Klopp
27  * @version
28  */

29
30
31 package org.netbeans.modules.web.monitor.data;
32
33 import org.w3c.dom.*;
34 import org.netbeans.modules.schema2beans.*;
35 import java.beans.*;
36 import java.util.*;
37
38
39 public class ContextData extends BaseBean {
40
41     static Vector comparators = new Vector();
42
43     static public final String JavaDoc PARAM = "Param"; //NOI18N
44
static public final String JavaDoc CONTEXTATTRIBUTES =
45     "ContextAttributes"; //NOI18N
46

47     public ContextData() {
48     this(Common.USE_DEFAULT_VALUES);
49     }
50
51     public ContextData(int options) {
52     super(ContextData.comparators, new org.netbeans.modules.schema2beans.Version(1, 0, 6));
53     // Properties (see root bean comments for the bean graph)
54
this.createProperty("Param", PARAM, //NOI18N
55
Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
56                 Param.class);
57     this.createAttribute(PARAM, "name", "Name", //NOI18N
58
AttrProp.CDATA | AttrProp.REQUIRED,
59                  null, null);
60     this.createAttribute(PARAM, "value", "Value", //NOI18N
61
AttrProp.CDATA | AttrProp.IMPLIED,
62                  null, null);
63
64     this.createProperty("ContextAttributes", CONTEXTATTRIBUTES, //NOI18N
65
Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
66                 ContextAttributes.class);
67
68
69     this.initialize(options);
70     }
71
72     // Setting the default values of the properties
73
void initialize(int options) {
74     }
75
76
77     // This attribute is an array, possibly empty
78
public void setParam(int index, Param value) {
79     this.setValue(PARAM, index, value);
80     }
81
82     //
83
public Param getParam(int index) {
84     return (Param)this.getValue(PARAM, index);
85     }
86
87     // This attribute is an array, possibly empty
88
public void setParam(Param[] value) {
89     this.setValue(PARAM, value);
90     }
91
92     //
93
public Param[] getParam() {
94     return (Param[])this.getValues(PARAM);
95     }
96
97     // Return the number of properties
98
public int sizeParam() {
99     return this.size(PARAM);
100     }
101
102     // Add a new element returning its index in the list
103
public int addParam(Param value) {
104     return this.addValue(PARAM, value);
105     }
106
107     //
108
// Remove an element using its reference
109
// Returns the index the element had in the list
110
//
111
public int removeParam(Param value) {
112     return this.removeValue(PARAM, value);
113     }
114
115
116     // This attribute is mandatory
117
public void setContextAttributes(ContextAttributes value) {
118     this.setValue(CONTEXTATTRIBUTES, value);
119     }
120
121     //
122
public ContextAttributes getContextAttributes() {
123     return (ContextAttributes)this.getValue(CONTEXTATTRIBUTES);
124     }
125
126
127
128     // This method verifies that the mandatory properties are set
129
public boolean verify() {
130     return true;
131     }
132
133     //
134
static public void addComparator(BeanComparator c) {
135     ContextData.comparators.add(c);
136     }
137
138     //
139
static public void removeComparator(BeanComparator c) {
140     ContextData.comparators.remove(c);
141     }
142     //
143
public void addPropertyChangeListener(PropertyChangeListener l) {
144     BeanProp p = this.beanProp();
145     if (p != null)
146         p.addPCListener(l);
147     }
148
149     //
150
public void removePropertyChangeListener(PropertyChangeListener l) {
151     BeanProp p = this.beanProp();
152     if (p != null)
153         p.removePCListener(l);
154     }
155
156     //
157
public void addPropertyChangeListener(String JavaDoc n, PropertyChangeListener l) {
158     BeanProp p = this.beanProp(n);
159     if (p != null)
160         p.addPCListener(l);
161     }
162
163     //
164
public void removePropertyChangeListener(String JavaDoc n,
165                          PropertyChangeListener l) {
166     BeanProp p = this.beanProp(n);
167     if (p != null)
168         p.removePCListener(l);
169     }
170
171     // Dump the content of this bean returning it as a String
172
public void dump(StringBuffer JavaDoc str, String JavaDoc indent) {
173     String JavaDoc s;
174     BaseBean n;
175     str.append(indent);
176     str.append("Param["+this.sizeParam()+"]"); //NOI18N
177
for(int i=0; i<this.sizeParam(); i++)
178         {
179         str.append(indent+"\t"); //NOI18N
180
str.append("#"+i+":"); //NOI18N
181
n = this.getParam(i);
182         if (n != null)
183             n.dump(str, indent + "\t"); //NOI18N
184
else
185             str.append(indent+"\tnull"); //NOI18N
186
this.dumpAttributes(PARAM, i, str, indent);
187         }
188
189     }
190
191     public String JavaDoc dumpBeanNode() {
192     StringBuffer JavaDoc str = new StringBuffer JavaDoc();
193     str.append("ContextData\n"); //NOI18N
194
this.dump(str, "\n "); //NOI18N
195
return str.toString();
196     }
197 }
198
199
200
Popular Tags