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