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: /**
043: * This generated bean class TemplateFamilies matches the schema element 'templateFamilies'.
044: *
045: * Generated on Thu Jun 07 12:07:29 PDT 2007
046: *
047: * This class matches the root element of the XML Schema,
048: * and is the root of the following bean graph:
049: *
050: * templateFamilies <templateFamilies> : TemplateFamilies
051: * family <family> : Family[1,n]
052: * [attr: name CDATA #IMPLIED : java.lang.String]
053: * [attr: expanded CDATA #IMPLIED : boolean]
054: * domainObject <domainObject> : DomainObject[1,n]
055: * [attr: name CDATA #IMPLIED : java.lang.String]
056: * modelElement <modelElement> : java.lang.String
057: * stereotype <stereotype> : java.lang.String
058: * description <description> : java.lang.String
059: * template <template> : Template[1,n]
060: * filenameFormat <filenameFormat> : java.lang.String
061: * fileExtension <fileExtension> : java.lang.String
062: * folderPath <folderPath> : java.lang.String
063: * templateFile <templateFile> : java.lang.String
064: *
065: * @Generated
066: */package org.netbeans.modules.uml.codegen.dataaccess.xmlbeans;
067:
068: import org.w3c.dom.*;
069: import org.netbeans.modules.schema2beans.*;
070: import java.beans.*;
071: import java.util.*;
072: import java.io.*;
073:
074: // BEGIN_NOI18N
075:
076: public class TemplateFamilies extends
077: org.netbeans.modules.schema2beans.BaseBean
078: implements
079: org.netbeans.modules.uml.codegen.dataaccess.xmlbeans.TemplateFamiliesInterface,
080: org.netbeans.modules.uml.codegen.dataaccess.xmlbeans.CommonBean {
081: static Vector comparators = new Vector();
082: private static final org.netbeans.modules.schema2beans.Version runtimeVersion = new org.netbeans.modules.schema2beans.Version(
083: 4, 2, 0);
084:
085: static public final String FAMILY = "Family"; // NOI18N
086:
087: public TemplateFamilies()
088: throws org.netbeans.modules.schema2beans.Schema2BeansException {
089: this (null, Common.USE_DEFAULT_VALUES);
090: }
091:
092: public TemplateFamilies(org.w3c.dom.Node doc, int options)
093: throws org.netbeans.modules.schema2beans.Schema2BeansException {
094: this (Common.NO_DEFAULT_VALUES);
095: initFromNode(doc, options);
096: }
097:
098: protected void initFromNode(org.w3c.dom.Node doc, int options)
099: throws Schema2BeansException {
100: if (doc == null) {
101: doc = GraphManager
102: .createRootElementNode("templateFamilies"); // NOI18N
103: if (doc == null)
104: throw new Schema2BeansException(
105: "Cannot create DOM root"); // NOI18N
106: }
107: Node n = GraphManager.getElementNode("templateFamilies", doc); // NOI18N
108: if (n == null)
109: throw new Schema2BeansException(
110: "Doc root not in the DOM graph"); // NOI18N
111: ;
112:
113: this .graphManager.setXmlDocument(doc);
114:
115: // Entry point of the createBeans() recursive calls
116: this .createBean(n, this .graphManager());
117: this .initialize(options);
118: }
119:
120: public TemplateFamilies(int options) {
121: super (comparators, runtimeVersion);
122: initOptions(options);
123: }
124:
125: protected void initOptions(int options) {
126: // The graph manager is allocated in the bean root
127: this .graphManager = new GraphManager(this );
128: this .createRoot("templateFamilies",
129: "TemplateFamilies", // NOI18N
130: Common.TYPE_1 | Common.TYPE_BEAN,
131: TemplateFamilies.class);
132:
133: // Properties (see root bean comments for the bean graph)
134: initPropertyTables(1);
135: this .createProperty("family", // NOI18N
136: FAMILY, Common.TYPE_1_N | Common.TYPE_BEAN
137: | Common.TYPE_KEY, Family.class);
138: this .createAttribute(FAMILY, "name", "Name", AttrProp.CDATA
139: | AttrProp.IMPLIED, null, null);
140: this .createAttribute(FAMILY, "expanded", "Expanded",
141: AttrProp.CDATA | AttrProp.IMPLIED, null, null);
142: this .initialize(options);
143: }
144:
145: // Setting the default values of the properties
146: void initialize(int options) {
147:
148: }
149:
150: // This attribute is an array containing at least one element
151: public void setFamily(int index, Family value) {
152: this .setValue(FAMILY, index, value);
153: }
154:
155: //
156: public Family getFamily(int index) {
157: return (Family) this .getValue(FAMILY, index);
158: }
159:
160: // Return the number of properties
161: public int sizeFamily() {
162: return this .size(FAMILY);
163: }
164:
165: // This attribute is an array containing at least one element
166: public void setFamily(Family[] value) {
167: this .setValue(FAMILY, value);
168: }
169:
170: //
171: public Family[] getFamily() {
172: return (Family[]) this .getValues(FAMILY);
173: }
174:
175: // Add a new element returning its index in the list
176: public int addFamily(
177: org.netbeans.modules.uml.codegen.dataaccess.xmlbeans.Family value) {
178: int positionOfNewItem = this .addValue(FAMILY, value);
179: return positionOfNewItem;
180: }
181:
182: //
183: // Remove an element using its reference
184: // Returns the index the element had in the list
185: //
186: public int removeFamily(
187: org.netbeans.modules.uml.codegen.dataaccess.xmlbeans.Family value) {
188: return this .removeValue(FAMILY, value);
189: }
190:
191: /**
192: * Create a new bean using it's default constructor.
193: * This does not add it to any bean graph.
194: */
195: public Family newFamily() {
196: return new Family();
197: }
198:
199: //
200: public static void addComparator(
201: org.netbeans.modules.schema2beans.BeanComparator c) {
202: comparators.add(c);
203: }
204:
205: //
206: public static void removeComparator(
207: org.netbeans.modules.schema2beans.BeanComparator c) {
208: comparators.remove(c);
209: }
210:
211: // This method returns the root of the bean graph
212: // Each call creates a new bean graph from the specified DOM graph
213: public static TemplateFamilies createGraph(org.w3c.dom.Node doc)
214: throws org.netbeans.modules.schema2beans.Schema2BeansException {
215: return new TemplateFamilies(doc, Common.NO_DEFAULT_VALUES);
216: }
217:
218: public static TemplateFamilies createGraph(java.io.File f)
219: throws org.netbeans.modules.schema2beans.Schema2BeansException,
220: java.io.IOException {
221: java.io.InputStream in = new java.io.FileInputStream(f);
222: try {
223: return createGraph(in, false);
224: } finally {
225: in.close();
226: }
227: }
228:
229: public static TemplateFamilies createGraph(java.io.InputStream in)
230: throws org.netbeans.modules.schema2beans.Schema2BeansException {
231: return createGraph(in, false);
232: }
233:
234: public static TemplateFamilies createGraph(java.io.InputStream in,
235: boolean validate)
236: throws org.netbeans.modules.schema2beans.Schema2BeansException {
237: Document doc = GraphManager.createXmlDocument(in, validate);
238: return createGraph(doc);
239: }
240:
241: // This method returns the root for a new empty bean graph
242: public static TemplateFamilies createGraph() {
243: try {
244: return new TemplateFamilies();
245: } catch (Schema2BeansException e) {
246: throw new RuntimeException(e);
247: }
248: }
249:
250: public void validate()
251: throws org.netbeans.modules.schema2beans.ValidateException {
252: }
253:
254: // Special serializer: output XML as serialization
255: private void writeObject(java.io.ObjectOutputStream out)
256: throws java.io.IOException {
257: ByteArrayOutputStream baos = new ByteArrayOutputStream();
258: write(baos);
259: String str = baos.toString();
260: ;
261: // System.out.println("str='"+str+"'");
262: out.writeUTF(str);
263: }
264:
265: // Special deserializer: read XML as deserialization
266: private void readObject(java.io.ObjectInputStream in)
267: throws java.io.IOException, ClassNotFoundException {
268: try {
269: init(comparators, runtimeVersion);
270: String strDocument = in.readUTF();
271: // System.out.println("strDocument='"+strDocument+"'");
272: ByteArrayInputStream bais = new ByteArrayInputStream(
273: strDocument.getBytes());
274: Document doc = GraphManager.createXmlDocument(bais, false);
275: initOptions(Common.NO_DEFAULT_VALUES);
276: initFromNode(doc, Common.NO_DEFAULT_VALUES);
277: } catch (Schema2BeansException e) {
278: throw new RuntimeException(e);
279: }
280: }
281:
282: public void _setSchemaLocation(String location) {
283: if (beanProp().getAttrProp("xsi:schemaLocation", true) == null) {
284: createAttribute("xmlns:xsi", "xmlns:xsi", AttrProp.CDATA
285: | AttrProp.IMPLIED, null,
286: "http://www.w3.org/2001/XMLSchema-instance");
287: setAttributeValue("xmlns:xsi",
288: "http://www.w3.org/2001/XMLSchema-instance");
289: createAttribute("xsi:schemaLocation", "xsi:schemaLocation",
290: AttrProp.CDATA | AttrProp.IMPLIED, null, location);
291: }
292: setAttributeValue("xsi:schemaLocation", location);
293: }
294:
295: public String _getSchemaLocation() {
296: if (beanProp().getAttrProp("xsi:schemaLocation", true) == null) {
297: createAttribute("xmlns:xsi", "xmlns:xsi", AttrProp.CDATA
298: | AttrProp.IMPLIED, null,
299: "http://www.w3.org/2001/XMLSchema-instance");
300: setAttributeValue("xmlns:xsi",
301: "http://www.w3.org/2001/XMLSchema-instance");
302: createAttribute("xsi:schemaLocation", "xsi:schemaLocation",
303: AttrProp.CDATA | AttrProp.IMPLIED, null, null);
304: }
305: return getAttributeValue("xsi:schemaLocation");
306: }
307:
308: // Dump the content of this bean returning it as a String
309: public void dump(StringBuffer str, String indent) {
310: String s;
311: Object o;
312: org.netbeans.modules.schema2beans.BaseBean n;
313: str.append(indent);
314: str.append("Family[" + this .sizeFamily() + "]"); // NOI18N
315: for (int i = 0; i < this .sizeFamily(); i++) {
316: str.append(indent + "\t");
317: str.append("#" + i + ":");
318: n = (org.netbeans.modules.schema2beans.BaseBean) this
319: .getFamily(i);
320: if (n != null)
321: n.dump(str, indent + "\t"); // NOI18N
322: else
323: str.append(indent + "\tnull"); // NOI18N
324: this .dumpAttributes(FAMILY, i, str, indent);
325: }
326:
327: }
328:
329: public String dumpBeanNode() {
330: StringBuffer str = new StringBuffer();
331: str.append("TemplateFamilies\n"); // NOI18N
332: this .dump(str, "\n "); // NOI18N
333: return str.toString();
334: }
335:
336: public Family getFamilyByName(String familyName) {
337: Family[] familyList = getFamily();
338: Family theFamily = null;
339:
340: for (Family family : familyList) {
341: if (family.getName().equals(familyName)) {
342: theFamily = family;
343: break;
344: }
345: }
346:
347: return theFamily;
348: }
349:
350: public boolean isUniqueFamilyName(String familyName) {
351: return getFamilyByName(familyName) == null;
352: }
353:
354: }
355:
356: // END_NOI18N
357:
358: /*
359: The following schema file has been used for generation:
360:
361: <?xml version="1.0" encoding="UTF-8"?>
362:
363: <!--
364: The contents of this file are subject to the terms of the Common Development
365: and Distribution License (the License). You may not use this file except in
366: compliance with the License.
367:
368: You can obtain a copy of the License at http://www.netbeans.org/cddl.html
369: or http://www.netbeans.org/cddl.txt.
370:
371: When distributing Covered Code, include this CDDL Header Notice in each file
372: and include the License file at http://www.netbeans.org/cddl.txt.
373: If applicable, add the following below the CDDL Header, with the fields
374: enclosed by brackets [] replaced by your own identifying information:
375: "Portions Copyrighted [year] [name of copyright owner]"
376:
377: The Original Software is NetBeans. The Initial Developer of the Original
378: Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
379: Microsystems, Inc. All Rights Reserved.
380: -->
381:
382: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
383: <xsd:element name="templateFamilies">
384: <xsd:complexType>
385: <xsd:sequence>
386: <xsd:element name="family" maxOccurs="unbounded">
387: <xsd:complexType>
388: <xsd:sequence>
389: <xsd:element name="domainObject" maxOccurs="unbounded">
390: <xsd:complexType>
391: <xsd:sequence>
392: <xsd:element name="modelElement" type="xsd:string"/>
393: <xsd:element name="stereotype" type="xsd:string"/>
394: <xsd:element name="description" type="xsd:string"/>
395: <xsd:element name="template" maxOccurs="unbounded">
396: <xsd:complexType>
397: <xsd:sequence>
398: <xsd:element name="filenameFormat" type="xsd:string"/>
399: <xsd:element name="fileExtension" type="xsd:string"/>
400: <xsd:element name="folderPath" type="xsd:string"/>
401: <xsd:element name="templateFile" type="xsd:string"/>
402: </xsd:sequence>
403: </xsd:complexType>
404: </xsd:element>
405: </xsd:sequence>
406: <xsd:attribute name="name" type="xsd:string"/>
407: </xsd:complexType>
408: </xsd:element>
409: </xsd:sequence>
410: <xsd:attribute name="name" type="xsd:string"/>
411: <xsd:attribute name="expanded" type="xsd:boolean"/>
412: </xsd:complexType>
413: </xsd:element>
414: </xsd:sequence>
415: </xsd:complexType>
416: </xsd:element>
417: </xsd:schema>
418:
419: */
|