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