001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.web.monitor.data;
043:
044: import org.w3c.dom.*;
045: import org.netbeans.modules.schema2beans.*;
046: import java.beans.*;
047: import java.util.*;
048:
049: public class ServletData extends BaseBean {
050:
051: static Vector comparators = new Vector();
052:
053: static public final String PARAM = "Param"; //NOI18N
054:
055: public ServletData() {
056: this (Common.USE_DEFAULT_VALUES);
057: }
058:
059: public ServletData(int options) {
060: super (ServletData.comparators,
061: new org.netbeans.modules.schema2beans.Version(1, 0, 6));
062: // Properties (see root bean comments for the bean graph)
063: this .createProperty("Param",
064: PARAM, //NOI18N
065: Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
066: Param.class);
067: this .createAttribute(PARAM, "name", "Name", //NOI18N
068: AttrProp.CDATA | AttrProp.REQUIRED, null, null);
069: this .createAttribute(PARAM, "value", "Value", //NOI18N
070: AttrProp.CDATA | AttrProp.IMPLIED, null, null);
071:
072: this .initialize(options);
073: }
074:
075: // Setting the default values of the properties
076: void initialize(int options) {
077: }
078:
079: // This attribute is an array, possibly empty
080: public void setParam(int index, Param value) {
081: this .setValue(PARAM, index, value);
082: }
083:
084: //
085: public Param getParam(int index) {
086: return (Param) this .getValue(PARAM, index);
087: }
088:
089: // This attribute is an array, possibly empty
090: public void setParam(Param[] value) {
091: this .setValue(PARAM, value);
092: }
093:
094: //
095: public Param[] getParam() {
096: return (Param[]) this .getValues(PARAM);
097: }
098:
099: // Return the number of properties
100: public int sizeParam() {
101: return this .size(PARAM);
102: }
103:
104: // Add a new element returning its index in the list
105: public int addParam(Param value) {
106: return this .addValue(PARAM, value);
107: }
108:
109: //
110: // Remove an element using its reference
111: // Returns the index the element had in the list
112: //
113: public int removeParam(Param value) {
114: return this .removeValue(PARAM, value);
115: }
116:
117: // This method verifies that the mandatory properties are set
118: public boolean verify() {
119: return true;
120: }
121:
122: //
123: static public void addComparator(BeanComparator c) {
124: ServletData.comparators.add(c);
125: }
126:
127: //
128: static public void removeComparator(BeanComparator c) {
129: ServletData.comparators.remove(c);
130: }
131:
132: //
133: public void addPropertyChangeListener(PropertyChangeListener l) {
134: BeanProp p = this .beanProp();
135: if (p != null)
136: p.addPCListener(l);
137: }
138:
139: //
140: public void removePropertyChangeListener(PropertyChangeListener l) {
141: BeanProp p = this .beanProp();
142: if (p != null)
143: p.removePCListener(l);
144: }
145:
146: //
147: public void addPropertyChangeListener(String n,
148: PropertyChangeListener l) {
149: BeanProp p = this .beanProp(n);
150: if (p != null)
151: p.addPCListener(l);
152: }
153:
154: //
155: public void removePropertyChangeListener(String n,
156: PropertyChangeListener l) {
157: BeanProp p = this .beanProp(n);
158: if (p != null)
159: p.removePCListener(l);
160: }
161:
162: // Dump the content of this bean returning it as a String
163: public void dump(StringBuffer str, String indent) {
164: String s;
165: BaseBean n;
166: str.append(indent);
167: str.append("Param[" + this .sizeParam() + "]"); //NOI18N
168: for (int i = 0; i < this .sizeParam(); i++) {
169: str.append(indent + "\t"); //NOI18N
170: str.append("#" + i + ":"); //NOI18N
171: n = this .getParam(i);
172: if (n != null)
173: n.dump(str, indent + "\t"); //NOI18N
174: else
175: str.append(indent + "\tnull"); //NOI18N
176: this .dumpAttributes(PARAM, i, str, indent);
177: }
178:
179: }
180:
181: public String dumpBeanNode() {
182: StringBuffer str = new StringBuffer();
183: str.append("ServletData\n"); //NOI18N
184: this .dump(str, "\n "); //NOI18N
185: return str.toString();
186: }
187: }
|