KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > configbean > customizers > data > PropertyParam


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  * This generated bean class PropertyParam
21  * matches the schema element 'property-param'.
22  * The root bean class is DynamicProperties
23  *
24  * Generated on Wed Sep 29 16:29:53 PDT 2004
25  * @Generated
26  */

27
28 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.data;
29
30 public class PropertyParam {
31     public static final String JavaDoc PARAM_NAME = "ParamName"; // NOI18N
32
public static final String JavaDoc PARAM_TYPE = "ParamType"; // NOI18N
33
public static final String JavaDoc PARAM_LABEL = "ParamLabel"; // NOI18N
34
public static final String JavaDoc PARAM_VALIDATOR = "ParamValidator"; // NOI18N
35
public static final String JavaDoc DEFAULT_VALUE = "DefaultValue"; // NOI18N
36
public static final String JavaDoc HELP_ID = "HelpId"; // NOI18N
37
public static final String JavaDoc PARAM_DESCRIPTION = "ParamDescription"; // NOI18N
38

39     private String JavaDoc _ParamName;
40     private ParamType _ParamType;
41     private String JavaDoc _ParamLabel;
42     private String JavaDoc _ParamValidator;
43     private String JavaDoc _DefaultValue;
44     private String JavaDoc _HelpId;
45     private String JavaDoc _ParamDescription;
46
47     /**
48      * Normal starting point constructor.
49      */

50     public PropertyParam() {
51         _ParamName = "";
52         _ParamType = newParamType();
53     }
54
55     /**
56      * Required parameters constructor
57      */

58     public PropertyParam(String JavaDoc paramName, org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.ParamType paramType) {
59         _ParamName = paramName;
60         _ParamType = paramType;
61     }
62
63     /**
64      * Deep copy
65      */

66     public PropertyParam(org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.PropertyParam source) {
67         this(source, false);
68     }
69
70     /**
71      * Deep copy
72      * @param justData just copy the XML relevant data
73      */

74     public PropertyParam(org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.PropertyParam source, boolean justData) {
75         _ParamName = source._ParamName;
76         _ParamType = (source._ParamType == null) ? null : newParamType(source._ParamType, justData);
77         _ParamLabel = source._ParamLabel;
78         _ParamValidator = source._ParamValidator;
79         _DefaultValue = source._DefaultValue;
80         _HelpId = source._HelpId;
81         _ParamDescription = source._ParamDescription;
82     }
83
84     // This attribute is mandatory
85
public void setParamName(String JavaDoc value) {
86         _ParamName = value;
87     }
88
89     public String JavaDoc getParamName() {
90         return _ParamName;
91     }
92
93     // This attribute is mandatory
94
public void setParamType(org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.ParamType value) {
95         _ParamType = value;
96     }
97
98     public org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.ParamType getParamType() {
99         return _ParamType;
100     }
101
102     // This attribute is optional
103
public void setParamLabel(String JavaDoc value) {
104         _ParamLabel = value;
105     }
106
107     public String JavaDoc getParamLabel() {
108         return _ParamLabel;
109     }
110
111     // This attribute is optional
112
public void setParamValidator(String JavaDoc value) {
113         _ParamValidator = value;
114     }
115
116     public String JavaDoc getParamValidator() {
117         return _ParamValidator;
118     }
119
120     // This attribute is optional
121
public void setDefaultValue(String JavaDoc value) {
122         _DefaultValue = value;
123     }
124
125     public String JavaDoc getDefaultValue() {
126         return _DefaultValue;
127     }
128
129     // This attribute is optional
130
public void setHelpId(String JavaDoc value) {
131         _HelpId = value;
132     }
133
134     public String JavaDoc getHelpId() {
135         return _HelpId;
136     }
137
138     // This attribute is optional
139
public void setParamDescription(String JavaDoc value) {
140         _ParamDescription = value;
141     }
142
143     public String JavaDoc getParamDescription() {
144         return _ParamDescription;
145     }
146
147     /**
148      * Create a new bean using it's default constructor.
149      * This does not add it to any bean graph.
150      */

151     public org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.ParamType newParamType() {
152         return new org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.ParamType();
153     }
154
155     /**
156      * Create a new bean, copying from another one.
157      * This does not add it to any bean graph.
158      */

159     public org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.ParamType newParamType(ParamType source, boolean justData) {
160         return new org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.ParamType(source, justData);
161     }
162
163     public void writeNode(java.io.Writer JavaDoc out) throws java.io.IOException JavaDoc {
164         String JavaDoc myName;
165         myName = "property-param";
166         writeNode(out, myName, ""); // NOI18N
167
}
168
169     public void writeNode(java.io.Writer JavaDoc out, String JavaDoc nodeName, String JavaDoc indent) throws java.io.IOException JavaDoc {
170         writeNode(out, nodeName, null, indent, new java.util.HashMap JavaDoc());
171     }
172
173     /**
174      * It's not recommended to call this method directly.
175      */

176     public void writeNode(java.io.Writer JavaDoc out, String JavaDoc nodeName, String JavaDoc namespace, String JavaDoc indent, java.util.Map JavaDoc namespaceMap) throws java.io.IOException JavaDoc {
177         out.write(indent);
178         out.write("<");
179         if (namespace != null) {
180             out.write((String JavaDoc)namespaceMap.get(namespace));
181             out.write(":");
182         }
183         out.write(nodeName);
184         out.write(">\n");
185         String JavaDoc nextIndent = indent + " ";
186         if (_ParamName != null) {
187             out.write(nextIndent);
188             out.write("<param-name"); // NOI18N
189
out.write(">"); // NOI18N
190
org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.DynamicProperties.writeXML(out, _ParamName, false);
191             out.write("</param-name>\n"); // NOI18N
192
}
193         if (_ParamType != null) {
194             _ParamType.writeNode(out, "param-type", null, nextIndent, namespaceMap);
195         }
196         if (_ParamLabel != null) {
197             out.write(nextIndent);
198             out.write("<param-label"); // NOI18N
199
out.write(">"); // NOI18N
200
org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.DynamicProperties.writeXML(out, _ParamLabel, false);
201             out.write("</param-label>\n"); // NOI18N
202
}
203         if (_ParamValidator != null) {
204             out.write(nextIndent);
205             out.write("<param-validator"); // NOI18N
206
out.write(">"); // NOI18N
207
org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.DynamicProperties.writeXML(out, _ParamValidator, false);
208             out.write("</param-validator>\n"); // NOI18N
209
}
210         if (_DefaultValue != null) {
211             out.write(nextIndent);
212             out.write("<default-value"); // NOI18N
213
out.write(">"); // NOI18N
214
org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.DynamicProperties.writeXML(out, _DefaultValue, false);
215             out.write("</default-value>\n"); // NOI18N
216
}
217         if (_HelpId != null) {
218             out.write(nextIndent);
219             out.write("<help-id"); // NOI18N
220
out.write(">"); // NOI18N
221
org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.DynamicProperties.writeXML(out, _HelpId, false);
222             out.write("</help-id>\n"); // NOI18N
223
}
224         if (_ParamDescription != null) {
225             out.write(nextIndent);
226             out.write("<param-description"); // NOI18N
227
out.write(">"); // NOI18N
228
org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.DynamicProperties.writeXML(out, _ParamDescription, false);
229             out.write("</param-description>\n"); // NOI18N
230
}
231         out.write(indent);
232         out.write("</");
233         if (namespace != null) {
234             out.write((String JavaDoc)namespaceMap.get(namespace));
235             out.write(":");
236         }
237         out.write(nodeName);
238         out.write(">\n");
239     }
240
241     public void readNode(org.w3c.dom.Node JavaDoc node) {
242         readNode(node, new java.util.HashMap JavaDoc());
243     }
244
245     public void readNode(org.w3c.dom.Node JavaDoc node, java.util.Map JavaDoc namespacePrefixes) {
246         if (node.hasAttributes()) {
247             org.w3c.dom.NamedNodeMap JavaDoc attrs = node.getAttributes();
248             org.w3c.dom.Attr JavaDoc attr;
249             java.lang.String JavaDoc attrValue;
250             boolean firstNamespaceDef = true;
251             for (int attrNum = 0; attrNum < attrs.getLength(); ++attrNum) {
252                 attr = (org.w3c.dom.Attr JavaDoc) attrs.item(attrNum);
253                 String JavaDoc attrName = attr.getName();
254                 if (attrName.startsWith("xmlns:")) {
255                     if (firstNamespaceDef) {
256                         firstNamespaceDef = false;
257                         // Dup prefix map, so as to not write over previous values, and to make it easy to clear out our entries.
258
namespacePrefixes = new java.util.HashMap JavaDoc(namespacePrefixes);
259                     }
260                     String JavaDoc attrNSPrefix = attrName.substring(6, attrName.length());
261                     namespacePrefixes.put(attrNSPrefix, attr.getValue());
262                 }
263             }
264         }
265         org.w3c.dom.NodeList JavaDoc children = node.getChildNodes();
266         for (int i = 0, size = children.getLength(); i < size; ++i) {
267             org.w3c.dom.Node JavaDoc childNode = children.item(i);
268             String JavaDoc childNodeName = (childNode.getLocalName() == null ? childNode.getNodeName().intern() : childNode.getLocalName().intern());
269             String JavaDoc childNodeValue = "";
270             if (childNode.getFirstChild() != null) {
271                 childNodeValue = childNode.getFirstChild().getNodeValue();
272             }
273             if (childNodeName == "param-name") {
274                 _ParamName = childNodeValue;
275             }
276             else if (childNodeName == "param-type") {
277                 _ParamType = newParamType();
278                 _ParamType.readNode(childNode, namespacePrefixes);
279             }
280             else if (childNodeName == "param-label") {
281                 _ParamLabel = childNodeValue;
282             }
283             else if (childNodeName == "param-validator") {
284                 _ParamValidator = childNodeValue;
285             }
286             else if (childNodeName == "default-value") {
287                 _DefaultValue = childNodeValue;
288             }
289             else if (childNodeName == "help-id") {
290                 _HelpId = childNodeValue;
291             }
292             else if (childNodeName == "param-description") {
293                 _ParamDescription = childNodeValue;
294             }
295             else {
296                 // Found extra unrecognized childNode
297
}
298         }
299     }
300
301     public void changePropertyByName(String JavaDoc name, Object JavaDoc value) {
302         if (name == null) return;
303         name = name.intern();
304         if (name == "paramName")
305             setParamName((String JavaDoc)value);
306         else if (name == "paramType")
307             setParamType((ParamType)value);
308         else if (name == "paramLabel")
309             setParamLabel((String JavaDoc)value);
310         else if (name == "paramValidator")
311             setParamValidator((String JavaDoc)value);
312         else if (name == "defaultValue")
313             setDefaultValue((String JavaDoc)value);
314         else if (name == "helpId")
315             setHelpId((String JavaDoc)value);
316         else if (name == "paramDescription")
317             setParamDescription((String JavaDoc)value);
318         else
319             throw new IllegalArgumentException JavaDoc(name+" is not a valid property name for PropertyParam");
320     }
321
322     public Object JavaDoc fetchPropertyByName(String JavaDoc name) {
323         if (name == "paramName")
324             return getParamName();
325         if (name == "paramType")
326             return getParamType();
327         if (name == "paramLabel")
328             return getParamLabel();
329         if (name == "paramValidator")
330             return getParamValidator();
331         if (name == "defaultValue")
332             return getDefaultValue();
333         if (name == "helpId")
334             return getHelpId();
335         if (name == "paramDescription")
336             return getParamDescription();
337         throw new IllegalArgumentException JavaDoc(name+" is not a valid property name for PropertyParam");
338     }
339
340     public String JavaDoc nameSelf() {
341         return "PropertyParam";
342     }
343
344     public String JavaDoc nameChild(Object JavaDoc childObj) {
345         return nameChild(childObj, false, false);
346     }
347
348     /**
349      * @param childObj The child object to search for
350      * @param returnSchemaName Whether or not the schema name should be returned or the property name
351      * @return null if not found
352      */

353     public String JavaDoc nameChild(Object JavaDoc childObj, boolean returnConstName, boolean returnSchemaName) {
354         return nameChild(childObj, returnConstName, returnSchemaName, false);
355     }
356
357     /**
358      * @param childObj The child object to search for
359      * @param returnSchemaName Whether or not the schema name should be returned or the property name
360      * @return null if not found
361      */

362     public String JavaDoc nameChild(Object JavaDoc childObj, boolean returnConstName, boolean returnSchemaName, boolean returnXPathName) {
363         if (childObj instanceof java.lang.String JavaDoc) {
364             java.lang.String JavaDoc child = (java.lang.String JavaDoc) childObj;
365             if (child == _ParamName) {
366                 if (returnConstName) {
367                     return PARAM_NAME;
368                 } else if (returnSchemaName) {
369                     return "param-name";
370                 } else if (returnXPathName) {
371                     return "param-name";
372                 } else {
373                     return "ParamName";
374                 }
375             }
376             if (child == _ParamLabel) {
377                 if (returnConstName) {
378                     return PARAM_LABEL;
379                 } else if (returnSchemaName) {
380                     return "param-label";
381                 } else if (returnXPathName) {
382                     return "param-label";
383                 } else {
384                     return "ParamLabel";
385                 }
386             }
387             if (child == _ParamValidator) {
388                 if (returnConstName) {
389                     return PARAM_VALIDATOR;
390                 } else if (returnSchemaName) {
391                     return "param-validator";
392                 } else if (returnXPathName) {
393                     return "param-validator";
394                 } else {
395                     return "ParamValidator";
396                 }
397             }
398             if (child == _DefaultValue) {
399                 if (returnConstName) {
400                     return DEFAULT_VALUE;
401                 } else if (returnSchemaName) {
402                     return "default-value";
403                 } else if (returnXPathName) {
404                     return "default-value";
405                 } else {
406                     return "DefaultValue";
407                 }
408             }
409             if (child == _HelpId) {
410                 if (returnConstName) {
411                     return HELP_ID;
412                 } else if (returnSchemaName) {
413                     return "help-id";
414                 } else if (returnXPathName) {
415                     return "help-id";
416                 } else {
417                     return "HelpId";
418                 }
419             }
420             if (child == _ParamDescription) {
421                 if (returnConstName) {
422                     return PARAM_DESCRIPTION;
423                 } else if (returnSchemaName) {
424                     return "param-description";
425                 } else if (returnXPathName) {
426                     return "param-description";
427                 } else {
428                     return "ParamDescription";
429                 }
430             }
431         }
432         if (childObj instanceof ParamType) {
433             ParamType child = (ParamType) childObj;
434             if (child == _ParamType) {
435                 if (returnConstName) {
436                     return PARAM_TYPE;
437                 } else if (returnSchemaName) {
438                     return "param-type";
439                 } else if (returnXPathName) {
440                     return "param-type";
441                 } else {
442                     return "ParamType";
443                 }
444             }
445         }
446         return null;
447     }
448
449     /**
450      * Return an array of all of the properties that are beans and are set.
451      */

452     public java.lang.Object JavaDoc[] childBeans(boolean recursive) {
453         java.util.List JavaDoc children = new java.util.LinkedList JavaDoc();
454         childBeans(recursive, children);
455         java.lang.Object JavaDoc[] result = new java.lang.Object JavaDoc[children.size()];
456         return (java.lang.Object JavaDoc[]) children.toArray(result);
457     }
458
459     /**
460      * Put all child beans into the beans list.
461      */

462     public void childBeans(boolean recursive, java.util.List JavaDoc beans) {
463         if (_ParamType != null) {
464             if (recursive) {
465                 _ParamType.childBeans(true, beans);
466             }
467             beans.add(_ParamType);
468         }
469     }
470
471     public boolean equals(Object JavaDoc o) {
472         return o instanceof org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.PropertyParam && equals((org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.PropertyParam) o);
473     }
474
475     public boolean equals(org.netbeans.modules.j2ee.sun.share.configbean.customizers.data.PropertyParam inst) {
476         if (inst == this) {
477             return true;
478         }
479         if (inst == null) {
480             return false;
481         }
482         if (!(_ParamName == null ? inst._ParamName == null : _ParamName.equals(inst._ParamName))) {
483             return false;
484         }
485         if (!(_ParamType == null ? inst._ParamType == null : _ParamType.equals(inst._ParamType))) {
486             return false;
487         }
488         if (!(_ParamLabel == null ? inst._ParamLabel == null : _ParamLabel.equals(inst._ParamLabel))) {
489             return false;
490         }
491         if (!(_ParamValidator == null ? inst._ParamValidator == null : _ParamValidator.equals(inst._ParamValidator))) {
492             return false;
493         }
494         if (!(_DefaultValue == null ? inst._DefaultValue == null : _DefaultValue.equals(inst._DefaultValue))) {
495             return false;
496         }
497         if (!(_HelpId == null ? inst._HelpId == null : _HelpId.equals(inst._HelpId))) {
498             return false;
499         }
500         if (!(_ParamDescription == null ? inst._ParamDescription == null : _ParamDescription.equals(inst._ParamDescription))) {
501             return false;
502         }
503         return true;
504     }
505
506     public int hashCode() {
507         int result = 17;
508         result = 37*result + (_ParamName == null ? 0 : _ParamName.hashCode());
509         result = 37*result + (_ParamType == null ? 0 : _ParamType.hashCode());
510         result = 37*result + (_ParamLabel == null ? 0 : _ParamLabel.hashCode());
511         result = 37*result + (_ParamValidator == null ? 0 : _ParamValidator.hashCode());
512         result = 37*result + (_DefaultValue == null ? 0 : _DefaultValue.hashCode());
513         result = 37*result + (_HelpId == null ? 0 : _HelpId.hashCode());
514         result = 37*result + (_ParamDescription == null ? 0 : _ParamDescription.hashCode());
515         return result;
516     }
517
518 }
519
520
521 /*
522         The following schema file has been used for generation:
523
524 <?xml version="1.0" encoding="UTF-8"?>
525
526 <!--
527     Document : dynamic-properties.dtd
528     Created on : January 28, 2004, 8:48 PM
529     Author : Peter Williams
530     Description:
531         Purpose of the document follows.
532         
533     DTD for definition of properties, their editors and validators to allow for
534     name/value pair property editing to be handled nicely in the plugin.
535 -->
536
537 <!-- The file is a list of property lists -->
538 <!ELEMENT dynamic-properties (property-list*, validator*)>
539
540 <!-- Each property list can be fixed or editable and has a name -->
541 <!ELEMENT property-list (property-name, property-param+, help-id?)>
542 <!ATTLIST property-list editable CDATA "false"
543                         description CDATA "true"
544                         bundle-path CDATA #IMPLIED>
545
546 <!ELEMENT property-name (#PCDATA)>
547
548 <!--
549     Each element in a property list has a name. It may also have a type, a
550     validator, and possibly a min and/or max if the type is 'number'. Lastly,
551     it could have a helpId
552 -->
553 <!ELEMENT property-param (param-name, param-type, param-label?, param-validator?, default-value?,
554                           help-id?, param-description?)>
555
556 <!ELEMENT param-name (#PCDATA)>
557
558 <!--
559     There are four allowed types: boolean, text, number, and list. The editable
560     attribute is ignored for all types except the list type.
561     
562     For boolean properties, default value should be string using the boolean
563       'ENTITY' definitions in the sun-xxx dtd's, preferably true/false.
564     For text properties, you should provide a validator (or none to allow
565       arbitrary text) and a default value if desired.
566     For number properties, the number is assumed to be a signed long integer.
567       Use the min & max params to specify a range if required.
568     For list properties, use as many param-value entries as necessary to represent
569       the list. If the list is editable, set the editable attribute on the type.
570       One exception here is if the list is the list of charsets or locales, use
571       param-locale or param-charset to specify this. These lists are provided by
572       the Locale and Charset classes in the JVM.
573
574     (I'm not actually defining ENTITY's here because Schema2Beans does not support them.)
575 -->
576 <!ELEMENT param-type ((param-value* | param-locale | param-charset), param-min?, param-max?)>
577 <!ATTLIST param-type type CDATA "text"
578                      editable CDATA "false"
579                      required CDATA "true">
580
581 <!ELEMENT param-value (#PCDATA)>
582 <!ELEMENT param-locale EMPTY>
583 <!ELEMENT param-charset EMPTY>
584 <!ELEMENT param-min (#PCDATA)>
585 <!ELEMENT param-max (#PCDATA)>
586
587 <!--
588     The text label (actually, will become bundle string id) to be used for the
589     value field instead of the word 'Value'
590 -->
591 <!ELEMENT param-label (#PCDATA)>
592
593 <!--
594     Validators are used to ensure the text in a text field matches a specific
595     pattern. The following validators are supported: (Can I support java
596     regular expression patterns here? It would make it lots easier!!!)
597     
598         directory: A directory path specification
599         javaid: A legal java identifier (allows java keywords though)
600         url: A URL string
601         domain: A domain. This is probably similar to javaid + represents a server domain
602         package: A legal java package name, e.g. javaid's separated by periods.
603         memorysize: A number followed by kb or mb (case insensitive)
604         classid: A windows classid (GUID)
605 -->
606 <!ELEMENT param-validator (#PCDATA)>
607
608 <!--
609     String that will become the default value for the property. If the property
610     value must fit a specific pattern, the default-value must qualify.
611 -->
612 <!ELEMENT default-value (#PCDATA)>
613
614 <!--
615     The help id for this field (or panel if specified at the property level,
616     which is likely what we'll do.
617 -->
618 <!ELEMENT help-id (#PCDATA)>
619
620
621 <!--
622     ID of string in bundle (see property-list attributes) to use for default
623     description.
624 -->
625 <!ELEMENT param-description (#PCDATA)>
626
627 <!-- !PW this would be used by property-param once it's done
628
629     Version of the appserver this property-param belongs to. Not present means
630     the property is applicable to all versions.
631     
632     Allowable Strings: major[.minor][pe|se|ee]
633         Major version is require.
634         Minor is optional (not present matches all)
635         Type is optional (not present matches all)
636         
637     For range attribute, valid values are:
638         ending, only, starting
639 <!ELEMENT appserver-version (#PCDATA)>
640 <!ATTLIST appserver-version range CDATA #IMPLIED>
641 -->
642
643 <!--
644     Validator definition. These are referred to by name from the <param-validator>
645     entry in <property-param>, above.
646 -->
647 <!ELEMENT validator (validator-name, validator-pattern)>
648
649 <!ELEMENT validator-name (#PCDATA)>
650
651 <!ELEMENT validator-pattern (#PCDATA)>
652
653
654
655 */

656
657
Popular Tags