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 PortletInfoType
043: * matches the schema element 'portlet-infoType'.
044: * The root bean class is PortletApp
045: *
046: * Generated on Tue Apr 26 19:08:25 MDT 2005
047: * @Generated
048: */package org.netbeans.modules.visualweb.api.portlet.dd;
049:
050: public class PortletInfoType
051: implements
052: org.netbeans.modules.visualweb.api.portlet.dd.PortletInfoTypeInterface,
053: org.netbeans.modules.visualweb.api.portlet.dd.CommonBean {
054: public static final String ID = "Id"; // NOI18N
055: public static final String TITLE = "Title"; // NOI18N
056: public static final String SHORT_TITLE = "ShortTitle"; // NOI18N
057: public static final String KEYWORDS = "Keywords"; // NOI18N
058:
059: private java.lang.String _Id;
060: private java.lang.String _Title;
061: private java.lang.String _ShortTitle;
062: private java.lang.String _Keywords;
063:
064: /**
065: * Normal starting point constructor.
066: */
067: public PortletInfoType() {
068: _Title = "";
069: }
070:
071: /**
072: * Required parameters constructor
073: */
074: public PortletInfoType(java.lang.String title) {
075: _Title = title;
076: }
077:
078: /**
079: * Deep copy
080: */
081: public PortletInfoType(
082: org.netbeans.modules.visualweb.api.portlet.dd.PortletInfoType source) {
083: this (source, false);
084: }
085:
086: /**
087: * Deep copy
088: * @param justData just copy the XML relevant data
089: */
090: public PortletInfoType(
091: org.netbeans.modules.visualweb.api.portlet.dd.PortletInfoType source,
092: boolean justData) {
093: _Id = source._Id;
094: _Title = source._Title;
095: _ShortTitle = source._ShortTitle;
096: _Keywords = source._Keywords;
097: }
098:
099: // This attribute is optional
100: public void setId(java.lang.String value) {
101: _Id = value;
102: }
103:
104: public java.lang.String getId() {
105: return _Id;
106: }
107:
108: // This attribute is mandatory
109: public void setTitle(java.lang.String value) {
110: _Title = value;
111: }
112:
113: public java.lang.String getTitle() {
114: return _Title;
115: }
116:
117: // This attribute is optional
118: public void setShortTitle(java.lang.String value) {
119: _ShortTitle = value;
120: }
121:
122: public java.lang.String getShortTitle() {
123: return _ShortTitle;
124: }
125:
126: // This attribute is optional
127: public void setKeywords(java.lang.String value) {
128: _Keywords = value;
129: }
130:
131: public java.lang.String getKeywords() {
132: return _Keywords;
133: }
134:
135: public void writeNode(java.io.Writer out)
136: throws java.io.IOException {
137: String myName;
138: myName = "portlet-infoType";
139: writeNode(out, myName, ""); // NOI18N
140: }
141:
142: public void writeNode(java.io.Writer out, String nodeName,
143: String indent) throws java.io.IOException {
144: writeNode(out, nodeName, null, indent, new java.util.HashMap());
145: }
146:
147: /**
148: * It's not recommended to call this method directly.
149: */
150: public void writeNode(java.io.Writer out, String nodeName,
151: String namespace, String indent, java.util.Map namespaceMap)
152: throws java.io.IOException {
153: out.write(indent);
154: out.write("<");
155: if (namespace != null) {
156: out.write((String) namespaceMap.get(namespace));
157: out.write(":");
158: }
159: out.write(nodeName);
160: // id is an attribute with namespace http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd
161: if (_Id != null) {
162: out.write(" id='");
163: org.netbeans.modules.visualweb.api.portlet.dd.PortletApp
164: .writeXML(out, _Id, true);
165: out.write("'"); // NOI18N
166: }
167: out.write(">\n");
168: String nextIndent = indent + " ";
169: if (_Title != null) {
170: out.write(nextIndent);
171: out.write("<title"); // NOI18N
172: out.write(">"); // NOI18N
173: org.netbeans.modules.visualweb.api.portlet.dd.PortletApp
174: .writeXML(out, _Title, false);
175: out.write("</title>\n"); // NOI18N
176: }
177: if (_ShortTitle != null) {
178: out.write(nextIndent);
179: out.write("<short-title"); // NOI18N
180: out.write(">"); // NOI18N
181: org.netbeans.modules.visualweb.api.portlet.dd.PortletApp
182: .writeXML(out, _ShortTitle, false);
183: out.write("</short-title>\n"); // NOI18N
184: }
185: if (_Keywords != null) {
186: out.write(nextIndent);
187: out.write("<keywords"); // NOI18N
188: out.write(">"); // NOI18N
189: org.netbeans.modules.visualweb.api.portlet.dd.PortletApp
190: .writeXML(out, _Keywords, false);
191: out.write("</keywords>\n"); // NOI18N
192: }
193: out.write(indent);
194: out.write("</");
195: if (namespace != null) {
196: out.write((String) namespaceMap.get(namespace));
197: out.write(":");
198: }
199: out.write(nodeName);
200: out.write(">\n");
201: }
202:
203: public void readNode(org.w3c.dom.Node node) {
204: readNode(node, new java.util.HashMap());
205: }
206:
207: public void readNode(org.w3c.dom.Node node,
208: java.util.Map namespacePrefixes) {
209: if (node.hasAttributes()) {
210: org.w3c.dom.NamedNodeMap attrs = node.getAttributes();
211: org.w3c.dom.Attr attr;
212: java.lang.String attrValue;
213: boolean firstNamespaceDef = true;
214: for (int attrNum = 0; attrNum < attrs.getLength(); ++attrNum) {
215: attr = (org.w3c.dom.Attr) attrs.item(attrNum);
216: String attrName = attr.getName();
217: if (attrName.startsWith("xmlns:")) {
218: if (firstNamespaceDef) {
219: firstNamespaceDef = false;
220: // Dup prefix map, so as to not write over previous values, and to make it easy to clear out our entries.
221: namespacePrefixes = new java.util.HashMap(
222: namespacePrefixes);
223: }
224: String attrNSPrefix = attrName.substring(6,
225: attrName.length());
226: namespacePrefixes
227: .put(attrNSPrefix, attr.getValue());
228: }
229: }
230: attr = (org.w3c.dom.Attr) attrs.getNamedItem("id");
231: if (attr != null) {
232: attrValue = attr.getValue();
233: _Id = attrValue;
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 == "title") {
248: _Title = childNodeValue;
249: } else if (childNodeName == "short-title") {
250: _ShortTitle = childNodeValue;
251: } else if (childNodeName == "keywords") {
252: _Keywords = childNodeValue;
253: } else {
254: // Found extra unrecognized childNode
255: }
256: }
257: }
258:
259: public void validate()
260: throws org.netbeans.modules.visualweb.api.portlet.dd.PortletApp.ValidateException {
261: boolean restrictionFailure = false;
262: boolean restrictionPassed = false;
263: // Validating property id
264: // Validating property title
265: if (getTitle() == null) {
266: throw new org.netbeans.modules.visualweb.api.portlet.dd.PortletApp.ValidateException(
267: "getTitle() == null",
268: org.netbeans.modules.visualweb.api.portlet.dd.PortletApp.ValidateException.FailureType.NULL_VALUE,
269: "title", this ); // NOI18N
270: }
271: // Validating property shortTitle
272: // Validating property keywords
273: }
274:
275: public void changePropertyByName(String name, Object value) {
276: if (name == null)
277: return;
278: name = name.intern();
279: if (name == "id")
280: setId((java.lang.String) value);
281: else if (name == "title")
282: setTitle((java.lang.String) value);
283: else if (name == "shortTitle")
284: setShortTitle((java.lang.String) value);
285: else if (name == "keywords")
286: setKeywords((java.lang.String) value);
287: else
288: throw new IllegalArgumentException(
289: name
290: + " is not a valid property name for PortletInfoType");
291: }
292:
293: public Object fetchPropertyByName(String name) {
294: if (name == "id")
295: return getId();
296: if (name == "title")
297: return getTitle();
298: if (name == "shortTitle")
299: return getShortTitle();
300: if (name == "keywords")
301: return getKeywords();
302: throw new IllegalArgumentException(name
303: + " is not a valid property name for PortletInfoType");
304: }
305:
306: public String nameSelf() {
307: return "PortletInfoType";
308: }
309:
310: public String nameChild(Object childObj) {
311: return nameChild(childObj, false, false);
312: }
313:
314: /**
315: * @param childObj The child object to search for
316: * @param returnSchemaName Whether or not the schema name should be returned or the property name
317: * @return null if not found
318: */
319: public String nameChild(Object childObj, boolean returnConstName,
320: boolean returnSchemaName) {
321: return nameChild(childObj, returnConstName, returnSchemaName,
322: false);
323: }
324:
325: /**
326: * @param childObj The child object to search for
327: * @param returnSchemaName Whether or not the schema name should be returned or the property name
328: * @return null if not found
329: */
330: public String nameChild(Object childObj, boolean returnConstName,
331: boolean returnSchemaName, boolean returnXPathName) {
332: if (childObj instanceof java.lang.String) {
333: java.lang.String child = (java.lang.String) childObj;
334: if (child == _Id) {
335: if (returnConstName) {
336: return ID;
337: } else if (returnSchemaName) {
338: return "id";
339: } else if (returnXPathName) {
340: return "@id";
341: } else {
342: return "Id";
343: }
344: }
345: if (child == _Title) {
346: if (returnConstName) {
347: return TITLE;
348: } else if (returnSchemaName) {
349: return "title";
350: } else if (returnXPathName) {
351: return "title";
352: } else {
353: return "Title";
354: }
355: }
356: if (child == _ShortTitle) {
357: if (returnConstName) {
358: return SHORT_TITLE;
359: } else if (returnSchemaName) {
360: return "short-title";
361: } else if (returnXPathName) {
362: return "short-title";
363: } else {
364: return "ShortTitle";
365: }
366: }
367: if (child == _Keywords) {
368: if (returnConstName) {
369: return KEYWORDS;
370: } else if (returnSchemaName) {
371: return "keywords";
372: } else if (returnXPathName) {
373: return "keywords";
374: } else {
375: return "Keywords";
376: }
377: }
378: }
379: return null;
380: }
381:
382: /**
383: * Return an array of all of the properties that are beans and are set.
384: */
385: public org.netbeans.modules.visualweb.api.portlet.dd.CommonBean[] childBeans(
386: boolean recursive) {
387: java.util.List children = new java.util.LinkedList();
388: childBeans(recursive, children);
389: org.netbeans.modules.visualweb.api.portlet.dd.CommonBean[] result = new org.netbeans.modules.visualweb.api.portlet.dd.CommonBean[children
390: .size()];
391: return (org.netbeans.modules.visualweb.api.portlet.dd.CommonBean[]) children
392: .toArray(result);
393: }
394:
395: /**
396: * Put all child beans into the beans list.
397: */
398: public void childBeans(boolean recursive, java.util.List beans) {
399: }
400:
401: public boolean equals(Object o) {
402: return o instanceof org.netbeans.modules.visualweb.api.portlet.dd.PortletInfoType
403: && equals((org.netbeans.modules.visualweb.api.portlet.dd.PortletInfoType) o);
404: }
405:
406: public boolean equals(
407: org.netbeans.modules.visualweb.api.portlet.dd.PortletInfoType inst) {
408: if (inst == this ) {
409: return true;
410: }
411: if (inst == null) {
412: return false;
413: }
414: if (!(_Id == null ? inst._Id == null : _Id.equals(inst._Id))) {
415: return false;
416: }
417: if (!(_Title == null ? inst._Title == null : _Title
418: .equals(inst._Title))) {
419: return false;
420: }
421: if (!(_ShortTitle == null ? inst._ShortTitle == null
422: : _ShortTitle.equals(inst._ShortTitle))) {
423: return false;
424: }
425: if (!(_Keywords == null ? inst._Keywords == null : _Keywords
426: .equals(inst._Keywords))) {
427: return false;
428: }
429: return true;
430: }
431:
432: public int hashCode() {
433: int result = 17;
434: result = 37 * result + (_Id == null ? 0 : _Id.hashCode());
435: result = 37 * result + (_Title == null ? 0 : _Title.hashCode());
436: result = 37 * result
437: + (_ShortTitle == null ? 0 : _ShortTitle.hashCode());
438: result = 37 * result
439: + (_Keywords == null ? 0 : _Keywords.hashCode());
440: return result;
441: }
442:
443: public String toString() {
444: java.io.StringWriter sw = new java.io.StringWriter();
445: try {
446: writeNode(sw);
447: } catch (java.io.IOException e) {
448: // How can we actually get an IOException on a StringWriter?
449: throw new RuntimeException(e);
450: }
451: return sw.toString();
452: }
453:
454: }
|