KickJava   Java API By Example, From Geeks To Geeks.

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


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  * RequestAttributesIn.java
22  *
23  * Matches the DTD element RequestAttributesIn
24  *
25  * Created: Tue Jan 15 18:22:27 2002
26  *
27  * @author Ana von Klopp
28  * @version
29  */

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

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

194     Param[] params = getParam();
195     buf.append(String.valueOf(params.length));
196     buf.append(" attribute lines\n"); // NOI18N
197
for(int i=0; i<params.length; ++i) {
198         buf.append(String.valueOf(i));
199         buf.append(". Attribute: "); // NOI18N
200
buf.append(params[i].getAttributeValue("name")); // NOI18N
201
buf.append(", Value: "); // NOI18N
202
buf.append(params[i].getAttributeValue("value")); // NOI18N
203
buf.append("\n"); // NOI18N
204
}
205     return buf.toString();
206     }
207 }
208
Popular Tags