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 PortletCollectionType
043: * matches the schema element 'portlet-collectionType'.
044: * The root bean class is PortletApp
045: *
046: * ===============================================================
047: *
048: * The portlet-collectionType is used to identify a subset
049: * of portlets within a portlet application to which a
050: * security constraint applies.
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 PortletCollectionType
059: implements
060: org.netbeans.modules.visualweb.api.portlet.dd.PortletCollectionTypeInterface,
061: org.netbeans.modules.visualweb.api.portlet.dd.CommonBean {
062: public static final String PORTLET_NAME = "PortletName"; // NOI18N
063:
064: private java.util.List _PortletName = new java.util.ArrayList(); // List<java.lang.String>
065:
066: /**
067: * Normal starting point constructor.
068: */
069: public PortletCollectionType() {
070: }
071:
072: /**
073: * Required parameters constructor
074: */
075: public PortletCollectionType(java.lang.String[] portletName) {
076: if (portletName != null) {
077: ((java.util.ArrayList) _PortletName)
078: .ensureCapacity(portletName.length);
079: for (int i = 0; i < portletName.length; ++i) {
080: _PortletName.add(portletName[i]);
081: }
082: }
083: }
084:
085: /**
086: * Deep copy
087: */
088: public PortletCollectionType(
089: org.netbeans.modules.visualweb.api.portlet.dd.PortletCollectionType source) {
090: this (source, false);
091: }
092:
093: /**
094: * Deep copy
095: * @param justData just copy the XML relevant data
096: */
097: public PortletCollectionType(
098: org.netbeans.modules.visualweb.api.portlet.dd.PortletCollectionType source,
099: boolean justData) {
100: for (java.util.Iterator it = source._PortletName.iterator(); it
101: .hasNext();) {
102: java.lang.String srcElement = (java.lang.String) it.next();
103: _PortletName.add(srcElement);
104: }
105: }
106:
107: // This attribute is an array containing at least one element
108: public void setPortletName(java.lang.String[] value) {
109: if (value == null)
110: value = new java.lang.String[0];
111: _PortletName.clear();
112: ((java.util.ArrayList) _PortletName)
113: .ensureCapacity(value.length);
114: for (int i = 0; i < value.length; ++i) {
115: _PortletName.add(value[i]);
116: }
117: }
118:
119: public void setPortletName(int index, java.lang.String value) {
120: _PortletName.set(index, value);
121: }
122:
123: public java.lang.String[] getPortletName() {
124: java.lang.String[] arr = new java.lang.String[_PortletName
125: .size()];
126: return (java.lang.String[]) _PortletName.toArray(arr);
127: }
128:
129: public java.util.List fetchPortletNameList() {
130: return _PortletName;
131: }
132:
133: public java.lang.String getPortletName(int index) {
134: return (java.lang.String) _PortletName.get(index);
135: }
136:
137: // Return the number of portletName
138: public int sizePortletName() {
139: return _PortletName.size();
140: }
141:
142: public int addPortletName(java.lang.String value) {
143: _PortletName.add(value);
144: int positionOfNewItem = _PortletName.size() - 1;
145: return positionOfNewItem;
146: }
147:
148: /**
149: * Search from the end looking for @param value, and then remove it.
150: */
151: public int removePortletName(java.lang.String value) {
152: int pos = _PortletName.indexOf(value);
153: if (pos >= 0) {
154: _PortletName.remove(pos);
155: }
156: return pos;
157: }
158:
159: public void writeNode(java.io.Writer out)
160: throws java.io.IOException {
161: String myName;
162: myName = "portlet-collectionType";
163: writeNode(out, myName, ""); // NOI18N
164: }
165:
166: public void writeNode(java.io.Writer out, String nodeName,
167: String indent) throws java.io.IOException {
168: writeNode(out, nodeName, null, indent, new java.util.HashMap());
169: }
170:
171: /**
172: * It's not recommended to call this method directly.
173: */
174: public void writeNode(java.io.Writer out, String nodeName,
175: String namespace, String indent, java.util.Map namespaceMap)
176: throws java.io.IOException {
177: out.write(indent);
178: out.write("<");
179: if (namespace != null) {
180: out.write((String) namespaceMap.get(namespace));
181: out.write(":");
182: }
183: out.write(nodeName);
184: out.write(">\n");
185: String nextIndent = indent + " ";
186: for (java.util.Iterator it = _PortletName.iterator(); it
187: .hasNext();) {
188: java.lang.String element = (java.lang.String) it.next();
189: if (element != null) {
190: out.write(nextIndent);
191: out.write("<portlet-name"); // NOI18N
192: out.write(">"); // NOI18N
193: org.netbeans.modules.visualweb.api.portlet.dd.PortletApp
194: .writeXML(out, element, false);
195: out.write("</portlet-name>\n"); // NOI18N
196: }
197: }
198: out.write(indent);
199: out.write("</");
200: if (namespace != null) {
201: out.write((String) namespaceMap.get(namespace));
202: out.write(":");
203: }
204: out.write(nodeName);
205: out.write(">\n");
206: }
207:
208: public void readNode(org.w3c.dom.Node node) {
209: readNode(node, new java.util.HashMap());
210: }
211:
212: public void readNode(org.w3c.dom.Node node,
213: java.util.Map namespacePrefixes) {
214: if (node.hasAttributes()) {
215: org.w3c.dom.NamedNodeMap attrs = node.getAttributes();
216: org.w3c.dom.Attr attr;
217: java.lang.String attrValue;
218: boolean firstNamespaceDef = true;
219: for (int attrNum = 0; attrNum < attrs.getLength(); ++attrNum) {
220: attr = (org.w3c.dom.Attr) attrs.item(attrNum);
221: String attrName = attr.getName();
222: if (attrName.startsWith("xmlns:")) {
223: if (firstNamespaceDef) {
224: firstNamespaceDef = false;
225: // Dup prefix map, so as to not write over previous values, and to make it easy to clear out our entries.
226: namespacePrefixes = new java.util.HashMap(
227: namespacePrefixes);
228: }
229: String attrNSPrefix = attrName.substring(6,
230: attrName.length());
231: namespacePrefixes
232: .put(attrNSPrefix, attr.getValue());
233: }
234: }
235: }
236: org.w3c.dom.NodeList children = node.getChildNodes();
237: for (int i = 0, size = children.getLength(); i < size; ++i) {
238: org.w3c.dom.Node childNode = children.item(i);
239: String childNodeName = (childNode.getLocalName() == null ? childNode
240: .getNodeName().intern()
241: : childNode.getLocalName().intern());
242: String childNodeValue = "";
243: if (childNode.getFirstChild() != null) {
244: childNodeValue = childNode.getFirstChild()
245: .getNodeValue();
246: }
247: if (childNodeName == "portlet-name") {
248: java.lang.String aPortletName;
249: aPortletName = childNodeValue;
250: _PortletName.add(aPortletName);
251: } else {
252: // Found extra unrecognized childNode
253: }
254: }
255: }
256:
257: public void validate()
258: throws org.netbeans.modules.visualweb.api.portlet.dd.PortletApp.ValidateException {
259: boolean restrictionFailure = false;
260: boolean restrictionPassed = false;
261: // Validating property portletName
262: if (sizePortletName() == 0) {
263: throw new org.netbeans.modules.visualweb.api.portlet.dd.PortletApp.ValidateException(
264: "sizePortletName() == 0",
265: org.netbeans.modules.visualweb.api.portlet.dd.PortletApp.ValidateException.FailureType.NULL_VALUE,
266: "portletName", this ); // NOI18N
267: }
268: }
269:
270: public void changePropertyByName(String name, Object value) {
271: if (name == null)
272: return;
273: name = name.intern();
274: if (name == "portletName")
275: addPortletName((java.lang.String) value);
276: else if (name == "portletName[]")
277: setPortletName((java.lang.String[]) value);
278: else
279: throw new IllegalArgumentException(
280: name
281: + " is not a valid property name for PortletCollectionType");
282: }
283:
284: public Object fetchPropertyByName(String name) {
285: if (name == "portletName[]")
286: return getPortletName();
287: throw new IllegalArgumentException(
288: name
289: + " is not a valid property name for PortletCollectionType");
290: }
291:
292: public String nameSelf() {
293: return "PortletCollectionType";
294: }
295:
296: public String nameChild(Object childObj) {
297: return nameChild(childObj, false, false);
298: }
299:
300: /**
301: * @param childObj The child object to search for
302: * @param returnSchemaName Whether or not the schema name should be returned or the property name
303: * @return null if not found
304: */
305: public String nameChild(Object childObj, boolean returnConstName,
306: boolean returnSchemaName) {
307: return nameChild(childObj, returnConstName, returnSchemaName,
308: false);
309: }
310:
311: /**
312: * @param childObj The child object to search for
313: * @param returnSchemaName Whether or not the schema name should be returned or the property name
314: * @return null if not found
315: */
316: public String nameChild(Object childObj, boolean returnConstName,
317: boolean returnSchemaName, boolean returnXPathName) {
318: if (childObj instanceof java.lang.String) {
319: java.lang.String child = (java.lang.String) childObj;
320: int index = 0;
321: for (java.util.Iterator it = _PortletName.iterator(); it
322: .hasNext();) {
323: java.lang.String element = (java.lang.String) it.next();
324: if (child == element) {
325: if (returnConstName) {
326: return PORTLET_NAME;
327: } else if (returnSchemaName) {
328: return "portlet-name";
329: } else if (returnXPathName) {
330: return "portlet-name[position()=" + index + "]";
331: } else {
332: return "PortletName."
333: + Integer.toHexString(index);
334: }
335: }
336: ++index;
337: }
338: }
339: return null;
340: }
341:
342: /**
343: * Return an array of all of the properties that are beans and are set.
344: */
345: public org.netbeans.modules.visualweb.api.portlet.dd.CommonBean[] childBeans(
346: boolean recursive) {
347: java.util.List children = new java.util.LinkedList();
348: childBeans(recursive, children);
349: org.netbeans.modules.visualweb.api.portlet.dd.CommonBean[] result = new org.netbeans.modules.visualweb.api.portlet.dd.CommonBean[children
350: .size()];
351: return (org.netbeans.modules.visualweb.api.portlet.dd.CommonBean[]) children
352: .toArray(result);
353: }
354:
355: /**
356: * Put all child beans into the beans list.
357: */
358: public void childBeans(boolean recursive, java.util.List beans) {
359: }
360:
361: public boolean equals(Object o) {
362: return o instanceof org.netbeans.modules.visualweb.api.portlet.dd.PortletCollectionType
363: && equals((org.netbeans.modules.visualweb.api.portlet.dd.PortletCollectionType) o);
364: }
365:
366: public boolean equals(
367: org.netbeans.modules.visualweb.api.portlet.dd.PortletCollectionType inst) {
368: if (inst == this ) {
369: return true;
370: }
371: if (inst == null) {
372: return false;
373: }
374: if (sizePortletName() != inst.sizePortletName())
375: return false;
376: // Compare every element.
377: for (java.util.Iterator it = _PortletName.iterator(), it2 = inst._PortletName
378: .iterator(); it.hasNext() && it2.hasNext();) {
379: java.lang.String element = (java.lang.String) it.next();
380: java.lang.String element2 = (java.lang.String) it2.next();
381: if (!(element == null ? element2 == null : element
382: .equals(element2))) {
383: return false;
384: }
385: }
386: return true;
387: }
388:
389: public int hashCode() {
390: int result = 17;
391: result = 37 * result
392: + (_PortletName == null ? 0 : _PortletName.hashCode());
393: return result;
394: }
395:
396: public String toString() {
397: java.io.StringWriter sw = new java.io.StringWriter();
398: try {
399: writeNode(sw);
400: } catch (java.io.IOException e) {
401: // How can we actually get an IOException on a StringWriter?
402: throw new RuntimeException(e);
403: }
404: return sw.toString();
405: }
406:
407: }
|