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 UserDataConstraintType
043: * matches the schema element 'user-data-constraintType'.
044: * The root bean class is PortletApp
045: *
046: * ===============================================================
047: *
048: * The user-data-constraintType is used to indicate how
049: * data communicated between the client and portlet should be
050: * protected.
051: * Used in: security-constraint
052: *
053: * ===============================================================
054: * Generated on Tue Apr 26 19:08:25 MDT 2005
055: * @Generated
056: */package org.netbeans.modules.visualweb.api.portlet.dd;
057:
058: public class UserDataConstraintType
059: implements
060: org.netbeans.modules.visualweb.api.portlet.dd.UserDataConstraintTypeInterface,
061: org.netbeans.modules.visualweb.api.portlet.dd.CommonBean {
062: public static final String ID = "Id"; // NOI18N
063: public static final String DESCRIPTION = "Description"; // NOI18N
064: public static final String DESCRIPTIONXMLLANG = "DescriptionXmlLang"; // NOI18N
065: public static final String TRANSPORT_GUARANTEE = "TransportGuarantee"; // 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 _TransportGuarantee = "NONE";
071:
072: /**
073: * Normal starting point constructor.
074: */
075: public UserDataConstraintType() {
076: }
077:
078: /**
079: * Required parameters constructor
080: */
081: public UserDataConstraintType(java.lang.String transportGuarantee) {
082: _TransportGuarantee = transportGuarantee;
083: }
084:
085: /**
086: * Deep copy
087: */
088: public UserDataConstraintType(
089: org.netbeans.modules.visualweb.api.portlet.dd.UserDataConstraintType source) {
090: this (source, false);
091: }
092:
093: /**
094: * Deep copy
095: * @param justData just copy the XML relevant data
096: */
097: public UserDataConstraintType(
098: org.netbeans.modules.visualweb.api.portlet.dd.UserDataConstraintType 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: _TransportGuarantee = source._TransportGuarantee;
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 setTransportGuarantee(java.lang.String value) {
232: _TransportGuarantee = value;
233: }
234:
235: public java.lang.String getTransportGuarantee() {
236: return _TransportGuarantee;
237: }
238:
239: public void writeNode(java.io.Writer out)
240: throws java.io.IOException {
241: String myName;
242: myName = "user-data-constraintType";
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 (_TransportGuarantee != null) {
299: out.write(nextIndent);
300: out.write("<transport-guarantee"); // NOI18N
301: out.write(">"); // NOI18N
302: org.netbeans.modules.visualweb.api.portlet.dd.PortletApp
303: .writeXML(out, _TransportGuarantee, false);
304: out.write("</transport-guarantee>\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 == "transport-guarantee") {
378: _TransportGuarantee = 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 transportGuarantee
393: if (getTransportGuarantee() == null) {
394: throw new org.netbeans.modules.visualweb.api.portlet.dd.PortletApp.ValidateException(
395: "getTransportGuarantee() == null",
396: org.netbeans.modules.visualweb.api.portlet.dd.PortletApp.ValidateException.FailureType.NULL_VALUE,
397: "transportGuarantee", this ); // NOI18N
398: }
399: final java.lang.String[] enumRestrictionTransportGuarantee = {
400: "NONE", "INTEGRAL", "CONFIDENTIAL" };
401: restrictionFailure = true;
402: for (int _index2 = 0; _index2 < enumRestrictionTransportGuarantee.length; ++_index2) {
403: if (enumRestrictionTransportGuarantee[_index2]
404: .equals(getTransportGuarantee())) {
405: restrictionFailure = false;
406: break;
407: }
408: }
409: if (restrictionFailure) {
410: throw new org.netbeans.modules.visualweb.api.portlet.dd.PortletApp.ValidateException(
411: "getTransportGuarantee() enumeration test",
412: org.netbeans.modules.visualweb.api.portlet.dd.PortletApp.ValidateException.FailureType.ENUM_RESTRICTION,
413: "transportGuarantee", this ); // NOI18N
414: }
415: }
416:
417: public void changePropertyByName(String name, Object value) {
418: if (name == null)
419: return;
420: name = name.intern();
421: if (name == "id")
422: setId((java.lang.String) value);
423: else if (name == "description")
424: addDescription((java.lang.String) value);
425: else if (name == "description[]")
426: setDescription((java.lang.String[]) value);
427: else if (name == "descriptionXmlLang")
428: addDescriptionXmlLang((java.lang.String) value);
429: else if (name == "descriptionXmlLang[]")
430: setDescriptionXmlLang((java.lang.String[]) value);
431: else if (name == "transportGuarantee")
432: setTransportGuarantee((java.lang.String) value);
433: else
434: throw new IllegalArgumentException(
435: name
436: + " is not a valid property name for UserDataConstraintType");
437: }
438:
439: public Object fetchPropertyByName(String name) {
440: if (name == "id")
441: return getId();
442: if (name == "description[]")
443: return getDescription();
444: if (name == "descriptionXmlLang[]")
445: return getDescriptionXmlLang();
446: if (name == "transportGuarantee")
447: return getTransportGuarantee();
448: throw new IllegalArgumentException(
449: name
450: + " is not a valid property name for UserDataConstraintType");
451: }
452:
453: public String nameSelf() {
454: return "UserDataConstraintType";
455: }
456:
457: public String nameChild(Object childObj) {
458: return nameChild(childObj, false, false);
459: }
460:
461: /**
462: * @param childObj The child object to search for
463: * @param returnSchemaName Whether or not the schema name should be returned or the property name
464: * @return null if not found
465: */
466: public String nameChild(Object childObj, boolean returnConstName,
467: boolean returnSchemaName) {
468: return nameChild(childObj, returnConstName, returnSchemaName,
469: false);
470: }
471:
472: /**
473: * @param childObj The child object to search for
474: * @param returnSchemaName Whether or not the schema name should be returned or the property name
475: * @return null if not found
476: */
477: public String nameChild(Object childObj, boolean returnConstName,
478: boolean returnSchemaName, boolean returnXPathName) {
479: if (childObj instanceof java.lang.String) {
480: java.lang.String child = (java.lang.String) childObj;
481: if (child == _Id) {
482: if (returnConstName) {
483: return ID;
484: } else if (returnSchemaName) {
485: return "id";
486: } else if (returnXPathName) {
487: return "@id";
488: } else {
489: return "Id";
490: }
491: }
492: int index = 0;
493: for (java.util.Iterator it = _Description.iterator(); it
494: .hasNext();) {
495: java.lang.String element = (java.lang.String) it.next();
496: if (child == element) {
497: if (returnConstName) {
498: return DESCRIPTION;
499: } else if (returnSchemaName) {
500: return "description";
501: } else if (returnXPathName) {
502: return "description[position()=" + index + "]";
503: } else {
504: return "Description."
505: + Integer.toHexString(index);
506: }
507: }
508: ++index;
509: }
510: index = 0;
511: for (java.util.Iterator it = _DescriptionXmlLang.iterator(); it
512: .hasNext();) {
513: java.lang.String element = (java.lang.String) it.next();
514: if (child == element) {
515: if (returnConstName) {
516: return DESCRIPTIONXMLLANG;
517: } else if (returnSchemaName) {
518: return "xml:lang";
519: } else if (returnXPathName) {
520: return "@xml:lang[position()=" + index + "]";
521: } else {
522: return "DescriptionXmlLang."
523: + Integer.toHexString(index);
524: }
525: }
526: ++index;
527: }
528: if (child == _TransportGuarantee) {
529: if (returnConstName) {
530: return TRANSPORT_GUARANTEE;
531: } else if (returnSchemaName) {
532: return "transport-guarantee";
533: } else if (returnXPathName) {
534: return "transport-guarantee";
535: } else {
536: return "TransportGuarantee";
537: }
538: }
539: }
540: return null;
541: }
542:
543: /**
544: * Return an array of all of the properties that are beans and are set.
545: */
546: public org.netbeans.modules.visualweb.api.portlet.dd.CommonBean[] childBeans(
547: boolean recursive) {
548: java.util.List children = new java.util.LinkedList();
549: childBeans(recursive, children);
550: org.netbeans.modules.visualweb.api.portlet.dd.CommonBean[] result = new org.netbeans.modules.visualweb.api.portlet.dd.CommonBean[children
551: .size()];
552: return (org.netbeans.modules.visualweb.api.portlet.dd.CommonBean[]) children
553: .toArray(result);
554: }
555:
556: /**
557: * Put all child beans into the beans list.
558: */
559: public void childBeans(boolean recursive, java.util.List beans) {
560: }
561:
562: public boolean equals(Object o) {
563: return o instanceof org.netbeans.modules.visualweb.api.portlet.dd.UserDataConstraintType
564: && equals((org.netbeans.modules.visualweb.api.portlet.dd.UserDataConstraintType) o);
565: }
566:
567: public boolean equals(
568: org.netbeans.modules.visualweb.api.portlet.dd.UserDataConstraintType inst) {
569: if (inst == this ) {
570: return true;
571: }
572: if (inst == null) {
573: return false;
574: }
575: if (!(_Id == null ? inst._Id == null : _Id.equals(inst._Id))) {
576: return false;
577: }
578: if (sizeDescription() != inst.sizeDescription())
579: return false;
580: // Compare every element.
581: for (java.util.Iterator it = _Description.iterator(), it2 = inst._Description
582: .iterator(); it.hasNext() && it2.hasNext();) {
583: java.lang.String element = (java.lang.String) it.next();
584: java.lang.String element2 = (java.lang.String) it2.next();
585: if (!(element == null ? element2 == null : element
586: .equals(element2))) {
587: return false;
588: }
589: }
590: if (sizeDescriptionXmlLang() != inst.sizeDescriptionXmlLang())
591: return false;
592: // Compare every element.
593: for (java.util.Iterator it = _DescriptionXmlLang.iterator(), it2 = inst._DescriptionXmlLang
594: .iterator(); it.hasNext() && it2.hasNext();) {
595: java.lang.String element = (java.lang.String) it.next();
596: java.lang.String element2 = (java.lang.String) it2.next();
597: if (!(element == null ? element2 == null : element
598: .equals(element2))) {
599: return false;
600: }
601: }
602: if (!(_TransportGuarantee == null ? inst._TransportGuarantee == null
603: : _TransportGuarantee.equals(inst._TransportGuarantee))) {
604: return false;
605: }
606: return true;
607: }
608:
609: public int hashCode() {
610: int result = 17;
611: result = 37 * result + (_Id == null ? 0 : _Id.hashCode());
612: result = 37 * result
613: + (_Description == null ? 0 : _Description.hashCode());
614: result = 37
615: * result
616: + (_DescriptionXmlLang == null ? 0
617: : _DescriptionXmlLang.hashCode());
618: result = 37
619: * result
620: + (_TransportGuarantee == null ? 0
621: : _TransportGuarantee.hashCode());
622: return result;
623: }
624:
625: public String toString() {
626: java.io.StringWriter sw = new java.io.StringWriter();
627: try {
628: writeNode(sw);
629: } catch (java.io.IOException e) {
630: // How can we actually get an IOException on a StringWriter?
631: throw new RuntimeException(e);
632: }
633: return sw.toString();
634: }
635:
636: }
|