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