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-2007 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: * This generated bean class InitParamType
043: * matches the schema element 'init-paramType'.
044: * The root bean class is PortletApp
045: *
046: * ===============================================================
047: *
048: * The init-param element contains a name/value pair as an
049: * initialization param of the portlet
050: * Used in:portlet
051: *
052: * ===============================================================
053: * Generated on Tue Apr 26 19:08:25 MDT 2005
054: * @Generated
055: */package org.netbeans.modules.visualweb.api.portlet.dd;
056:
057: public class InitParamType
058: implements
059: org.netbeans.modules.visualweb.api.portlet.dd.InitParamTypeInterface,
060: org.netbeans.modules.visualweb.api.portlet.dd.CommonBean {
061: public static final String ID = "Id"; // NOI18N
062: public static final String DESCRIPTION = "Description"; // NOI18N
063: public static final String DESCRIPTIONXMLLANG = "DescriptionXmlLang"; // NOI18N
064: public static final String NAME = "Name"; // NOI18N
065: public static final String VALUE = "Value"; // NOI18N
066:
067: private java.lang.String _Id;
068: private java.util.List _Description = new java.util.ArrayList(); // List<java.lang.String>
069: private java.util.List _DescriptionXmlLang = new java.util.ArrayList(); // List<java.lang.String>
070: private java.lang.String _Name;
071: private java.lang.String _Value;
072:
073: /**
074: * Normal starting point constructor.
075: */
076: public InitParamType() {
077: _Name = "";
078: _Value = "";
079: }
080:
081: /**
082: * Required parameters constructor
083: */
084: public InitParamType(java.lang.String name, java.lang.String value) {
085: _Name = name;
086: _Value = value;
087: }
088:
089: /**
090: * Deep copy
091: */
092: public InitParamType(
093: org.netbeans.modules.visualweb.api.portlet.dd.InitParamType source) {
094: this (source, false);
095: }
096:
097: /**
098: * Deep copy
099: * @param justData just copy the XML relevant data
100: */
101: public InitParamType(
102: org.netbeans.modules.visualweb.api.portlet.dd.InitParamType source,
103: boolean justData) {
104: _Id = source._Id;
105: for (java.util.Iterator it = source._Description.iterator(); it
106: .hasNext();) {
107: java.lang.String srcElement = (java.lang.String) it.next();
108: _Description.add(srcElement);
109: }
110: for (java.util.Iterator it = source._DescriptionXmlLang
111: .iterator(); it.hasNext();) {
112: java.lang.String srcElement = (java.lang.String) it.next();
113: _DescriptionXmlLang.add(srcElement);
114: }
115: _Name = source._Name;
116: _Value = source._Value;
117: }
118:
119: // This attribute is optional
120: public void setId(java.lang.String value) {
121: _Id = value;
122: }
123:
124: public java.lang.String getId() {
125: return _Id;
126: }
127:
128: // This attribute is an array, possibly empty
129: public void setDescription(java.lang.String[] value) {
130: if (value == null)
131: value = new java.lang.String[0];
132: _Description.clear();
133: ((java.util.ArrayList) _Description)
134: .ensureCapacity(value.length);
135: for (int i = 0; i < value.length; ++i) {
136: _Description.add(value[i]);
137: }
138: }
139:
140: public void setDescription(int index, java.lang.String value) {
141: _Description.set(index, value);
142: }
143:
144: public java.lang.String[] getDescription() {
145: java.lang.String[] arr = new java.lang.String[_Description
146: .size()];
147: return (java.lang.String[]) _Description.toArray(arr);
148: }
149:
150: public java.util.List fetchDescriptionList() {
151: return _Description;
152: }
153:
154: public java.lang.String getDescription(int index) {
155: return (java.lang.String) _Description.get(index);
156: }
157:
158: // Return the number of description
159: public int sizeDescription() {
160: return _Description.size();
161: }
162:
163: public int addDescription(java.lang.String value) {
164: _Description.add(value);
165: int positionOfNewItem = _Description.size() - 1;
166: return positionOfNewItem;
167: }
168:
169: /**
170: * Search from the end looking for @param value, and then remove it.
171: */
172: public int removeDescription(java.lang.String value) {
173: int pos = _Description.indexOf(value);
174: if (pos >= 0) {
175: _Description.remove(pos);
176: }
177: return pos;
178: }
179:
180: // This attribute is an array, possibly empty
181: public void setDescriptionXmlLang(java.lang.String[] value) {
182: if (value == null)
183: value = new java.lang.String[0];
184: _DescriptionXmlLang.clear();
185: ((java.util.ArrayList) _DescriptionXmlLang)
186: .ensureCapacity(value.length);
187: for (int i = 0; i < value.length; ++i) {
188: _DescriptionXmlLang.add(value[i]);
189: }
190: }
191:
192: public void setDescriptionXmlLang(int index, java.lang.String value) {
193: for (int size = _DescriptionXmlLang.size(); index >= size; ++size) {
194: _DescriptionXmlLang.add(null);
195: }
196: _DescriptionXmlLang.set(index, value);
197: }
198:
199: public java.lang.String[] getDescriptionXmlLang() {
200: java.lang.String[] arr = new java.lang.String[_DescriptionXmlLang
201: .size()];
202: return (java.lang.String[]) _DescriptionXmlLang.toArray(arr);
203: }
204:
205: public java.util.List fetchDescriptionXmlLangList() {
206: return _DescriptionXmlLang;
207: }
208:
209: public java.lang.String getDescriptionXmlLang(int index) {
210: return (java.lang.String) _DescriptionXmlLang.get(index);
211: }
212:
213: // Return the number of descriptionXmlLang
214: public int sizeDescriptionXmlLang() {
215: return _DescriptionXmlLang.size();
216: }
217:
218: public int addDescriptionXmlLang(java.lang.String value) {
219: _DescriptionXmlLang.add(value);
220: int positionOfNewItem = _DescriptionXmlLang.size() - 1;
221: return positionOfNewItem;
222: }
223:
224: /**
225: * Search from the end looking for @param value, and then remove it.
226: */
227: public int removeDescriptionXmlLang(java.lang.String value) {
228: int pos = _DescriptionXmlLang.indexOf(value);
229: if (pos >= 0) {
230: _DescriptionXmlLang.remove(pos);
231: }
232: return pos;
233: }
234:
235: // This attribute is mandatory
236: public void setName(java.lang.String value) {
237: _Name = value;
238: }
239:
240: public java.lang.String getName() {
241: return _Name;
242: }
243:
244: // This attribute is mandatory
245: public void setValue(java.lang.String value) {
246: _Value = value;
247: }
248:
249: public java.lang.String getValue() {
250: return _Value;
251: }
252:
253: public void writeNode(java.io.Writer out)
254: throws java.io.IOException {
255: String myName;
256: myName = "init-paramType";
257: writeNode(out, myName, ""); // NOI18N
258: }
259:
260: public void writeNode(java.io.Writer out, String nodeName,
261: String indent) throws java.io.IOException {
262: writeNode(out, nodeName, null, indent, new java.util.HashMap());
263: }
264:
265: /**
266: * It's not recommended to call this method directly.
267: */
268: public void writeNode(java.io.Writer out, String nodeName,
269: String namespace, String indent, java.util.Map namespaceMap)
270: throws java.io.IOException {
271: out.write(indent);
272: out.write("<");
273: if (namespace != null) {
274: out.write((String) namespaceMap.get(namespace));
275: out.write(":");
276: }
277: out.write(nodeName);
278: // id is an attribute with namespace http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd
279: if (_Id != null) {
280: out.write(" id='");
281: org.netbeans.modules.visualweb.api.portlet.dd.PortletApp
282: .writeXML(out, _Id, true);
283: out.write("'"); // NOI18N
284: }
285: out.write(">\n");
286: String nextIndent = indent + " ";
287: int index = 0;
288: for (java.util.Iterator it = _Description.iterator(); it
289: .hasNext();) {
290: java.lang.String element = (java.lang.String) it.next();
291: if (element != null) {
292: out.write(nextIndent);
293: out.write("<description"); // NOI18N
294: if (index < sizeDescriptionXmlLang()) {
295: // xml:lang is an attribute with namespace http://www.w3.org/XML/1998/namespace
296: if (getDescriptionXmlLang(index) != null) {
297: out.write(" xml:lang='");
298: org.netbeans.modules.visualweb.api.portlet.dd.PortletApp
299: .writeXML(out,
300: getDescriptionXmlLang(index),
301: true);
302: out.write("'"); // NOI18N
303: }
304: }
305: out.write(">"); // NOI18N
306: org.netbeans.modules.visualweb.api.portlet.dd.PortletApp
307: .writeXML(out, element, false);
308: out.write("</description>\n"); // NOI18N
309: }
310: ++index;
311: }
312: if (_Name != null) {
313: out.write(nextIndent);
314: out.write("<name"); // NOI18N
315: out.write(">"); // NOI18N
316: org.netbeans.modules.visualweb.api.portlet.dd.PortletApp
317: .writeXML(out, _Name, false);
318: out.write("</name>\n"); // NOI18N
319: }
320: if (_Value != null) {
321: out.write(nextIndent);
322: out.write("<value"); // NOI18N
323: out.write(">"); // NOI18N
324: org.netbeans.modules.visualweb.api.portlet.dd.PortletApp
325: .writeXML(out, _Value, false);
326: out.write("</value>\n"); // NOI18N
327: }
328: out.write(indent);
329: out.write("</");
330: if (namespace != null) {
331: out.write((String) namespaceMap.get(namespace));
332: out.write(":");
333: }
334: out.write(nodeName);
335: out.write(">\n");
336: }
337:
338: public void readNode(org.w3c.dom.Node node) {
339: readNode(node, new java.util.HashMap());
340: }
341:
342: public void readNode(org.w3c.dom.Node node,
343: java.util.Map namespacePrefixes) {
344: if (node.hasAttributes()) {
345: org.w3c.dom.NamedNodeMap attrs = node.getAttributes();
346: org.w3c.dom.Attr attr;
347: java.lang.String attrValue;
348: boolean firstNamespaceDef = true;
349: for (int attrNum = 0; attrNum < attrs.getLength(); ++attrNum) {
350: attr = (org.w3c.dom.Attr) attrs.item(attrNum);
351: String attrName = attr.getName();
352: if (attrName.startsWith("xmlns:")) {
353: if (firstNamespaceDef) {
354: firstNamespaceDef = false;
355: // Dup prefix map, so as to not write over previous values, and to make it easy to clear out our entries.
356: namespacePrefixes = new java.util.HashMap(
357: namespacePrefixes);
358: }
359: String attrNSPrefix = attrName.substring(6,
360: attrName.length());
361: namespacePrefixes
362: .put(attrNSPrefix, attr.getValue());
363: }
364: }
365: attr = (org.w3c.dom.Attr) attrs.getNamedItem("id");
366: if (attr != null) {
367: attrValue = attr.getValue();
368: _Id = attrValue;
369: }
370: }
371: org.w3c.dom.NodeList children = node.getChildNodes();
372: for (int i = 0, size = children.getLength(); i < size; ++i) {
373: org.w3c.dom.Node childNode = children.item(i);
374: String childNodeName = (childNode.getLocalName() == null ? childNode
375: .getNodeName().intern()
376: : childNode.getLocalName().intern());
377: String childNodeValue = "";
378: if (childNode.getFirstChild() != null) {
379: childNodeValue = childNode.getFirstChild()
380: .getNodeValue();
381: }
382: org.w3c.dom.NamedNodeMap attrs = childNode.getAttributes();
383: org.w3c.dom.Attr attr;
384: java.lang.String attrValue;
385: if (childNodeName == "description") {
386: java.lang.String aDescription;
387: aDescription = childNodeValue;
388: attr = (org.w3c.dom.Attr) attrs
389: .getNamedItem("xml:lang");
390: if (attr != null) {
391: attrValue = attr.getValue();
392: } else {
393: attrValue = null;
394: }
395: java.lang.String processedValueFor_DescriptionXmlLang;
396: processedValueFor_DescriptionXmlLang = attrValue;
397: addDescriptionXmlLang(processedValueFor_DescriptionXmlLang);
398: _Description.add(aDescription);
399: } else if (childNodeName == "name") {
400: _Name = childNodeValue;
401: } else if (childNodeName == "value") {
402: _Value = childNodeValue;
403: } else {
404: // Found extra unrecognized childNode
405: }
406: }
407: }
408:
409: public void validate()
410: throws org.netbeans.modules.visualweb.api.portlet.dd.PortletApp.ValidateException {
411: boolean restrictionFailure = false;
412: boolean restrictionPassed = false;
413: // Validating property id
414: // Validating property description
415: // Validating property descriptionXmlLang
416: // Validating property name
417: if (getName() == null) {
418: throw new org.netbeans.modules.visualweb.api.portlet.dd.PortletApp.ValidateException(
419: "getName() == null",
420: org.netbeans.modules.visualweb.api.portlet.dd.PortletApp.ValidateException.FailureType.NULL_VALUE,
421: "name", this ); // NOI18N
422: }
423: // Validating property value
424: if (getValue() == null) {
425: throw new org.netbeans.modules.visualweb.api.portlet.dd.PortletApp.ValidateException(
426: "getValue() == null",
427: org.netbeans.modules.visualweb.api.portlet.dd.PortletApp.ValidateException.FailureType.NULL_VALUE,
428: "value", this ); // NOI18N
429: }
430: }
431:
432: public void changePropertyByName(String name, Object value) {
433: if (name == null)
434: return;
435: name = name.intern();
436: if (name == "id")
437: setId((java.lang.String) value);
438: else if (name == "description")
439: addDescription((java.lang.String) value);
440: else if (name == "description[]")
441: setDescription((java.lang.String[]) value);
442: else if (name == "descriptionXmlLang")
443: addDescriptionXmlLang((java.lang.String) value);
444: else if (name == "descriptionXmlLang[]")
445: setDescriptionXmlLang((java.lang.String[]) value);
446: else if (name == "name")
447: setName((java.lang.String) value);
448: else if (name == "value")
449: setValue((java.lang.String) value);
450: else
451: throw new IllegalArgumentException(name
452: + " is not a valid property name for InitParamType");
453: }
454:
455: public Object fetchPropertyByName(String name) {
456: if (name == "id")
457: return getId();
458: if (name == "description[]")
459: return getDescription();
460: if (name == "descriptionXmlLang[]")
461: return getDescriptionXmlLang();
462: if (name == "name")
463: return getName();
464: if (name == "value")
465: return getValue();
466: throw new IllegalArgumentException(name
467: + " is not a valid property name for InitParamType");
468: }
469:
470: public String nameSelf() {
471: return "InitParamType";
472: }
473:
474: public String nameChild(Object childObj) {
475: return nameChild(childObj, false, false);
476: }
477:
478: /**
479: * @param childObj The child object to search for
480: * @param returnSchemaName Whether or not the schema name should be returned or the property name
481: * @return null if not found
482: */
483: public String nameChild(Object childObj, boolean returnConstName,
484: boolean returnSchemaName) {
485: return nameChild(childObj, returnConstName, returnSchemaName,
486: false);
487: }
488:
489: /**
490: * @param childObj The child object to search for
491: * @param returnSchemaName Whether or not the schema name should be returned or the property name
492: * @return null if not found
493: */
494: public String nameChild(Object childObj, boolean returnConstName,
495: boolean returnSchemaName, boolean returnXPathName) {
496: if (childObj instanceof java.lang.String) {
497: java.lang.String child = (java.lang.String) childObj;
498: if (child == _Id) {
499: if (returnConstName) {
500: return ID;
501: } else if (returnSchemaName) {
502: return "id";
503: } else if (returnXPathName) {
504: return "@id";
505: } else {
506: return "Id";
507: }
508: }
509: int index = 0;
510: for (java.util.Iterator it = _Description.iterator(); it
511: .hasNext();) {
512: java.lang.String element = (java.lang.String) it.next();
513: if (child == element) {
514: if (returnConstName) {
515: return DESCRIPTION;
516: } else if (returnSchemaName) {
517: return "description";
518: } else if (returnXPathName) {
519: return "description[position()=" + index + "]";
520: } else {
521: return "Description."
522: + Integer.toHexString(index);
523: }
524: }
525: ++index;
526: }
527: index = 0;
528: for (java.util.Iterator it = _DescriptionXmlLang.iterator(); it
529: .hasNext();) {
530: java.lang.String element = (java.lang.String) it.next();
531: if (child == element) {
532: if (returnConstName) {
533: return DESCRIPTIONXMLLANG;
534: } else if (returnSchemaName) {
535: return "xml:lang";
536: } else if (returnXPathName) {
537: return "@xml:lang[position()=" + index + "]";
538: } else {
539: return "DescriptionXmlLang."
540: + Integer.toHexString(index);
541: }
542: }
543: ++index;
544: }
545: if (child == _Name) {
546: if (returnConstName) {
547: return NAME;
548: } else if (returnSchemaName) {
549: return "name";
550: } else if (returnXPathName) {
551: return "name";
552: } else {
553: return "Name";
554: }
555: }
556: if (child == _Value) {
557: if (returnConstName) {
558: return VALUE;
559: } else if (returnSchemaName) {
560: return "value";
561: } else if (returnXPathName) {
562: return "value";
563: } else {
564: return "Value";
565: }
566: }
567: }
568: return null;
569: }
570:
571: /**
572: * Return an array of all of the properties that are beans and are set.
573: */
574: public org.netbeans.modules.visualweb.api.portlet.dd.CommonBean[] childBeans(
575: boolean recursive) {
576: java.util.List children = new java.util.LinkedList();
577: childBeans(recursive, children);
578: org.netbeans.modules.visualweb.api.portlet.dd.CommonBean[] result = new org.netbeans.modules.visualweb.api.portlet.dd.CommonBean[children
579: .size()];
580: return (org.netbeans.modules.visualweb.api.portlet.dd.CommonBean[]) children
581: .toArray(result);
582: }
583:
584: /**
585: * Put all child beans into the beans list.
586: */
587: public void childBeans(boolean recursive, java.util.List beans) {
588: }
589:
590: public boolean equals(Object o) {
591: return o instanceof org.netbeans.modules.visualweb.api.portlet.dd.InitParamType
592: && equals((org.netbeans.modules.visualweb.api.portlet.dd.InitParamType) o);
593: }
594:
595: public boolean equals(
596: org.netbeans.modules.visualweb.api.portlet.dd.InitParamType inst) {
597: if (inst == this ) {
598: return true;
599: }
600: if (inst == null) {
601: return false;
602: }
603: if (!(_Id == null ? inst._Id == null : _Id.equals(inst._Id))) {
604: return false;
605: }
606: if (sizeDescription() != inst.sizeDescription())
607: return false;
608: // Compare every element.
609: for (java.util.Iterator it = _Description.iterator(), it2 = inst._Description
610: .iterator(); it.hasNext() && it2.hasNext();) {
611: java.lang.String element = (java.lang.String) it.next();
612: java.lang.String element2 = (java.lang.String) it2.next();
613: if (!(element == null ? element2 == null : element
614: .equals(element2))) {
615: return false;
616: }
617: }
618: if (sizeDescriptionXmlLang() != inst.sizeDescriptionXmlLang())
619: return false;
620: // Compare every element.
621: for (java.util.Iterator it = _DescriptionXmlLang.iterator(), it2 = inst._DescriptionXmlLang
622: .iterator(); it.hasNext() && it2.hasNext();) {
623: java.lang.String element = (java.lang.String) it.next();
624: java.lang.String element2 = (java.lang.String) it2.next();
625: if (!(element == null ? element2 == null : element
626: .equals(element2))) {
627: return false;
628: }
629: }
630: if (!(_Name == null ? inst._Name == null : _Name
631: .equals(inst._Name))) {
632: return false;
633: }
634: if (!(_Value == null ? inst._Value == null : _Value
635: .equals(inst._Value))) {
636: return false;
637: }
638: return true;
639: }
640:
641: public int hashCode() {
642: int result = 17;
643: result = 37 * result + (_Id == null ? 0 : _Id.hashCode());
644: result = 37 * result
645: + (_Description == null ? 0 : _Description.hashCode());
646: result = 37
647: * result
648: + (_DescriptionXmlLang == null ? 0
649: : _DescriptionXmlLang.hashCode());
650: result = 37 * result + (_Name == null ? 0 : _Name.hashCode());
651: result = 37 * result + (_Value == null ? 0 : _Value.hashCode());
652: return result;
653: }
654:
655: public String toString() {
656: java.io.StringWriter sw = new java.io.StringWriter();
657: try {
658: writeNode(sw);
659: } catch (java.io.IOException e) {
660: // How can we actually get an IOException on a StringWriter?
661: throw new RuntimeException(e);
662: }
663: return sw.toString();
664: }
665:
666: }
|