Source Code Cross Referenced for BeanGraph.java in  » IDE-Netbeans » schema2beans » org » netbeans » modules » schema2beansdev » beangraph » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » schema2beans » org.netbeans.modules.schema2beansdev.beangraph 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:         * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 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 BeanGraph
043:         *	matches the schema element 'bean-graph'.
044:         *
045:         *
046:         *	This class matches the root element of the XML Schema,
047:         *	and is the root of the bean graph.
048:         *
049:         * 	beanGraph <bean-graph> : BeanGraph
050:         * 		schemaTypeMapping <schema-type-mapping> : SchemaTypeMappingType[0,n]
051:         * 			schemaTypeNamespace <schema-type-namespace> : java.lang.String[0,1]
052:         * 			schemaTypeName <schema-type-name> : java.lang.String
053:         * 			javaType <java-type> : java.lang.String
054:         * 			root <root> : boolean[0,1]
055:         * 			bean <bean> : boolean[0,1]
056:         * 			canBeEmpty <can-be-empty> : boolean[0,1]
057:         *
058:         * @Generated
059:         */package org.netbeans.modules.schema2beansdev.beangraph;
060:
061:        public class BeanGraph implements 
062:                org.netbeans.modules.schema2beansdev.beangraph.CommonBean {
063:            public static final String SCHEMA_TYPE_MAPPING = "SchemaTypeMapping"; // NOI18N
064:
065:            private java.util.List _SchemaTypeMapping = new java.util.ArrayList(); // List<SchemaTypeMappingType>
066:            private java.lang.String schemaLocation;
067:
068:            /**
069:             * Normal starting point constructor.
070:             */
071:            public BeanGraph() {
072:            }
073:
074:            /**
075:             * Deep copy
076:             */
077:            public BeanGraph(
078:                    org.netbeans.modules.schema2beansdev.beangraph.BeanGraph source) {
079:                this (source, false);
080:            }
081:
082:            /**
083:             * Deep copy
084:             * @param justData just copy the XML relevant data
085:             */
086:            public BeanGraph(
087:                    org.netbeans.modules.schema2beansdev.beangraph.BeanGraph source,
088:                    boolean justData) {
089:                for (java.util.Iterator it = source._SchemaTypeMapping
090:                        .iterator(); it.hasNext();) {
091:                    org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType srcElement = (org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType) it
092:                            .next();
093:                    _SchemaTypeMapping.add((srcElement == null) ? null
094:                            : newSchemaTypeMappingType(srcElement, justData));
095:                }
096:                schemaLocation = source.schemaLocation;
097:            }
098:
099:            // This attribute is an array, possibly empty
100:            public void setSchemaTypeMapping(
101:                    org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType[] value) {
102:                if (value == null)
103:                    value = new SchemaTypeMappingType[0];
104:                _SchemaTypeMapping.clear();
105:                ((java.util.ArrayList) _SchemaTypeMapping)
106:                        .ensureCapacity(value.length);
107:                for (int i = 0; i < value.length; ++i) {
108:                    _SchemaTypeMapping.add(value[i]);
109:                }
110:            }
111:
112:            public void setSchemaTypeMapping(
113:                    int index,
114:                    org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType value) {
115:                _SchemaTypeMapping.set(index, value);
116:            }
117:
118:            public org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType[] getSchemaTypeMapping() {
119:                SchemaTypeMappingType[] arr = new SchemaTypeMappingType[_SchemaTypeMapping
120:                        .size()];
121:                return (SchemaTypeMappingType[]) _SchemaTypeMapping
122:                        .toArray(arr);
123:            }
124:
125:            public java.util.List fetchSchemaTypeMappingList() {
126:                return _SchemaTypeMapping;
127:            }
128:
129:            public org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType getSchemaTypeMapping(
130:                    int index) {
131:                return (SchemaTypeMappingType) _SchemaTypeMapping.get(index);
132:            }
133:
134:            // Return the number of schemaTypeMapping
135:            public int sizeSchemaTypeMapping() {
136:                return _SchemaTypeMapping.size();
137:            }
138:
139:            public int addSchemaTypeMapping(
140:                    org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType value) {
141:                _SchemaTypeMapping.add(value);
142:                int positionOfNewItem = _SchemaTypeMapping.size() - 1;
143:                return positionOfNewItem;
144:            }
145:
146:            /**
147:             * Search from the end looking for @param value, and then remove it.
148:             */
149:            public int removeSchemaTypeMapping(
150:                    org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType value) {
151:                int pos = _SchemaTypeMapping.indexOf(value);
152:                if (pos >= 0) {
153:                    _SchemaTypeMapping.remove(pos);
154:                }
155:                return pos;
156:            }
157:
158:            public void _setSchemaLocation(String location) {
159:                schemaLocation = location;
160:            }
161:
162:            public String _getSchemaLocation() {
163:                return schemaLocation;
164:            }
165:
166:            /**
167:             * Create a new bean using it's default constructor.
168:             * This does not add it to any bean graph.
169:             */
170:            public org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType newSchemaTypeMappingType() {
171:                return new org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType();
172:            }
173:
174:            /**
175:             * Create a new bean, copying from another one.
176:             * This does not add it to any bean graph.
177:             */
178:            public org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType newSchemaTypeMappingType(
179:                    SchemaTypeMappingType source, boolean justData) {
180:                return new org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType(
181:                        source, justData);
182:            }
183:
184:            public void write(java.io.File f) throws java.io.IOException {
185:                java.io.OutputStream out = new java.io.FileOutputStream(f);
186:                try {
187:                    write(out);
188:                } finally {
189:                    out.close();
190:                }
191:            }
192:
193:            public void write(java.io.OutputStream out)
194:                    throws java.io.IOException {
195:                write(out, null);
196:            }
197:
198:            public void write(java.io.OutputStream out, String encoding)
199:                    throws java.io.IOException {
200:                java.io.Writer w;
201:                if (encoding == null) {
202:                    encoding = "UTF-8"; // NOI18N
203:                }
204:                w = new java.io.BufferedWriter(new java.io.OutputStreamWriter(
205:                        out, encoding));
206:                write(w, encoding);
207:                w.flush();
208:            }
209:
210:            /**
211:             * Print this Java Bean to @param out including an XML header.
212:             * @param encoding is the encoding style that @param out was opened with.
213:             */
214:            public void write(java.io.Writer out, String encoding)
215:                    throws java.io.IOException {
216:                out.write("<?xml version='1.0'"); // NOI18N
217:                if (encoding != null)
218:                    out.write(" encoding='" + encoding + "'"); // NOI18N
219:                out.write(" ?>\n"); // NOI18N
220:                writeNode(out, "bean-graph", ""); // NOI18N
221:            }
222:
223:            public void writeNode(java.io.Writer out)
224:                    throws java.io.IOException {
225:                String myName;
226:                myName = "bean-graph";
227:                writeNode(out, myName, ""); // NOI18N
228:            }
229:
230:            public void writeNode(java.io.Writer out, String nodeName,
231:                    String indent) throws java.io.IOException {
232:                writeNode(out, nodeName, null, indent, new java.util.HashMap());
233:            }
234:
235:            /**
236:             * It's not recommended to call this method directly.
237:             */
238:            public void writeNode(java.io.Writer out, String nodeName,
239:                    String namespace, String indent, java.util.Map namespaceMap)
240:                    throws java.io.IOException {
241:                out.write(indent);
242:                out.write("<");
243:                if (namespace != null) {
244:                    out.write((String) namespaceMap.get(namespace));
245:                    out.write(":");
246:                }
247:                out.write(nodeName);
248:                if (schemaLocation != null) {
249:                    namespaceMap.put(
250:                            "http://www.w3.org/2001/XMLSchema-instance", "xsi");
251:                    out
252:                            .write(" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='");
253:                    out.write(schemaLocation);
254:                    out.write("'"); // NOI18N
255:                }
256:                out.write(">\n");
257:                String nextIndent = indent + "	";
258:                for (java.util.Iterator it = _SchemaTypeMapping.iterator(); it
259:                        .hasNext();) {
260:                    org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType element = (org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType) it
261:                            .next();
262:                    if (element != null) {
263:                        element.writeNode(out, "schema-type-mapping", null,
264:                                nextIndent, namespaceMap);
265:                    }
266:                }
267:                out.write(indent);
268:                out.write("</");
269:                if (namespace != null) {
270:                    out.write((String) namespaceMap.get(namespace));
271:                    out.write(":");
272:                }
273:                out.write(nodeName);
274:                out.write(">\n");
275:            }
276:
277:            public static BeanGraph read(java.io.File f)
278:                    throws javax.xml.parsers.ParserConfigurationException,
279:                    org.xml.sax.SAXException, java.io.IOException {
280:                java.io.InputStream in = new java.io.FileInputStream(f);
281:                try {
282:                    return read(in);
283:                } finally {
284:                    in.close();
285:                }
286:            }
287:
288:            public static BeanGraph read(java.io.InputStream in)
289:                    throws javax.xml.parsers.ParserConfigurationException,
290:                    org.xml.sax.SAXException, java.io.IOException {
291:                return read(new org.xml.sax.InputSource(in), false, null, null);
292:            }
293:
294:            /**
295:             * Warning: in readNoEntityResolver character and entity references will
296:             * not be read from any DTD in the XML source.
297:             * However, this way is faster since no DTDs are looked up
298:             * (possibly skipping network access) or parsed.
299:             */
300:            public static BeanGraph readNoEntityResolver(java.io.InputStream in)
301:                    throws javax.xml.parsers.ParserConfigurationException,
302:                    org.xml.sax.SAXException, java.io.IOException {
303:                return read(new org.xml.sax.InputSource(in), false,
304:                        new org.xml.sax.EntityResolver() {
305:                            public org.xml.sax.InputSource resolveEntity(
306:                                    String publicId, String systemId) {
307:                                java.io.ByteArrayInputStream bin = new java.io.ByteArrayInputStream(
308:                                        new byte[0]);
309:                                return new org.xml.sax.InputSource(bin);
310:                            }
311:                        }, null);
312:            }
313:
314:            public static BeanGraph read(org.xml.sax.InputSource in,
315:                    boolean validate, org.xml.sax.EntityResolver er,
316:                    org.xml.sax.ErrorHandler eh)
317:                    throws javax.xml.parsers.ParserConfigurationException,
318:                    org.xml.sax.SAXException, java.io.IOException {
319:                javax.xml.parsers.DocumentBuilderFactory dbf = javax.xml.parsers.DocumentBuilderFactory
320:                        .newInstance();
321:                dbf.setValidating(validate);
322:                dbf.setNamespaceAware(true);
323:                javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder();
324:                if (er != null)
325:                    db.setEntityResolver(er);
326:                if (eh != null)
327:                    db.setErrorHandler(eh);
328:                org.w3c.dom.Document doc = db.parse(in);
329:                return read(doc);
330:            }
331:
332:            public static BeanGraph read(org.w3c.dom.Document document) {
333:                BeanGraph aBeanGraph = new BeanGraph();
334:                aBeanGraph.readFromDocument(document);
335:                return aBeanGraph;
336:            }
337:
338:            protected void readFromDocument(org.w3c.dom.Document document) {
339:                readNode(document.getDocumentElement());
340:            }
341:
342:            public void readNode(org.w3c.dom.Node node) {
343:                readNode(node, new java.util.HashMap());
344:            }
345:
346:            public void readNode(org.w3c.dom.Node node,
347:                    java.util.Map namespacePrefixes) {
348:                if (node.hasAttributes()) {
349:                    org.w3c.dom.NamedNodeMap attrs = node.getAttributes();
350:                    org.w3c.dom.Attr attr;
351:                    java.lang.String attrValue;
352:                    boolean firstNamespaceDef = true;
353:                    for (int attrNum = 0; attrNum < attrs.getLength(); ++attrNum) {
354:                        attr = (org.w3c.dom.Attr) attrs.item(attrNum);
355:                        String attrName = attr.getName();
356:                        if (attrName.startsWith("xmlns:")) {
357:                            if (firstNamespaceDef) {
358:                                firstNamespaceDef = false;
359:                                // Dup prefix map, so as to not write over previous values, and to make it easy to clear out our entries.
360:                                namespacePrefixes = new java.util.HashMap(
361:                                        namespacePrefixes);
362:                            }
363:                            String attrNSPrefix = attrName.substring(6,
364:                                    attrName.length());
365:                            namespacePrefixes
366:                                    .put(attrNSPrefix, attr.getValue());
367:                        }
368:                    }
369:                    String xsiPrefix = "xsi";
370:                    for (java.util.Iterator it = namespacePrefixes.keySet()
371:                            .iterator(); it.hasNext();) {
372:                        String prefix = (String) it.next();
373:                        String ns = (String) namespacePrefixes.get(prefix);
374:                        if ("http://www.w3.org/2001/XMLSchema-instance"
375:                                .equals(ns)) {
376:                            xsiPrefix = prefix;
377:                            break;
378:                        }
379:                    }
380:                    attr = (org.w3c.dom.Attr) attrs.getNamedItem("" + xsiPrefix
381:                            + ":schemaLocation");
382:                    if (attr != null) {
383:                        attrValue = attr.getValue();
384:                        schemaLocation = attrValue;
385:                    }
386:                }
387:                org.w3c.dom.NodeList children = node.getChildNodes();
388:                for (int i = 0, size = children.getLength(); i < size; ++i) {
389:                    org.w3c.dom.Node childNode = children.item(i);
390:                    String childNodeName = (childNode.getLocalName() == null ? childNode
391:                            .getNodeName().intern()
392:                            : childNode.getLocalName().intern());
393:                    String childNodeValue = "";
394:                    if (childNode.getFirstChild() != null) {
395:                        childNodeValue = childNode.getFirstChild()
396:                                .getNodeValue();
397:                    }
398:                    if (childNodeName == "schema-type-mapping") {
399:                        SchemaTypeMappingType aSchemaTypeMapping = newSchemaTypeMappingType();
400:                        aSchemaTypeMapping.readNode(childNode,
401:                                namespacePrefixes);
402:                        _SchemaTypeMapping.add(aSchemaTypeMapping);
403:                    } else {
404:                        // Found extra unrecognized childNode
405:                    }
406:                }
407:            }
408:
409:            /**
410:             * Takes some text to be printed into an XML stream and escapes any
411:             * characters that might make it invalid XML (like '<').
412:             */
413:            public static void writeXML(java.io.Writer out, String msg)
414:                    throws java.io.IOException {
415:                writeXML(out, msg, true);
416:            }
417:
418:            public static void writeXML(java.io.Writer out, String msg,
419:                    boolean attribute) throws java.io.IOException {
420:                if (msg == null)
421:                    return;
422:                int msgLength = msg.length();
423:                for (int i = 0; i < msgLength; ++i) {
424:                    char c = msg.charAt(i);
425:                    writeXML(out, c, attribute);
426:                }
427:            }
428:
429:            public static void writeXML(java.io.Writer out, char msg,
430:                    boolean attribute) throws java.io.IOException {
431:                if (msg == '&')
432:                    out.write("&amp;");
433:                else if (msg == '<')
434:                    out.write("&lt;");
435:                else if (msg == '>')
436:                    out.write("&gt;");
437:                else if (attribute) {
438:                    if (msg == '"')
439:                        out.write("&quot;");
440:                    else if (msg == '\'')
441:                        out.write("&apos;");
442:                    else if (msg == '\n')
443:                        out.write("&#xA;");
444:                    else if (msg == '\t')
445:                        out.write("&#x9;");
446:                    else
447:                        out.write(msg);
448:                } else
449:                    out.write(msg);
450:            }
451:
452:            public static class ValidateException extends Exception {
453:                private org.netbeans.modules.schema2beansdev.beangraph.CommonBean failedBean;
454:                private String failedPropertyName;
455:                private FailureType failureType;
456:
457:                public ValidateException(
458:                        String msg,
459:                        String failedPropertyName,
460:                        org.netbeans.modules.schema2beansdev.beangraph.CommonBean failedBean) {
461:                    super (msg);
462:                    this .failedBean = failedBean;
463:                    this .failedPropertyName = failedPropertyName;
464:                }
465:
466:                public ValidateException(
467:                        String msg,
468:                        FailureType ft,
469:                        String failedPropertyName,
470:                        org.netbeans.modules.schema2beansdev.beangraph.CommonBean failedBean) {
471:                    super (msg);
472:                    this .failureType = ft;
473:                    this .failedBean = failedBean;
474:                    this .failedPropertyName = failedPropertyName;
475:                }
476:
477:                public String getFailedPropertyName() {
478:                    return failedPropertyName;
479:                }
480:
481:                public FailureType getFailureType() {
482:                    return failureType;
483:                }
484:
485:                public org.netbeans.modules.schema2beansdev.beangraph.CommonBean getFailedBean() {
486:                    return failedBean;
487:                }
488:
489:                public static class FailureType {
490:                    private final String name;
491:
492:                    private FailureType(String name) {
493:                        this .name = name;
494:                    }
495:
496:                    public String toString() {
497:                        return name;
498:                    }
499:
500:                    public static final FailureType NULL_VALUE = new FailureType(
501:                            "NULL_VALUE");
502:                    public static final FailureType DATA_RESTRICTION = new FailureType(
503:                            "DATA_RESTRICTION");
504:                    public static final FailureType ENUM_RESTRICTION = new FailureType(
505:                            "ENUM_RESTRICTION");
506:                    public static final FailureType ALL_RESTRICTIONS = new FailureType(
507:                            "ALL_RESTRICTIONS");
508:                    public static final FailureType MUTUALLY_EXCLUSIVE = new FailureType(
509:                            "MUTUALLY_EXCLUSIVE");
510:                }
511:            }
512:
513:            public void validate()
514:                    throws org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.ValidateException {
515:                boolean restrictionFailure = false;
516:                boolean restrictionPassed = false;
517:                // Validating property schemaTypeMapping
518:                for (int _index = 0; _index < sizeSchemaTypeMapping(); ++_index) {
519:                    org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType element = getSchemaTypeMapping(_index);
520:                    if (element != null) {
521:                        element.validate();
522:                    }
523:                }
524:            }
525:
526:            public void changePropertyByName(String name, Object value) {
527:                if (name == null)
528:                    return;
529:                name = name.intern();
530:                if (name == "schemaTypeMapping")
531:                    addSchemaTypeMapping((SchemaTypeMappingType) value);
532:                else if (name == "schemaTypeMapping[]")
533:                    setSchemaTypeMapping((SchemaTypeMappingType[]) value);
534:                else
535:                    throw new IllegalArgumentException(name
536:                            + " is not a valid property name for BeanGraph");
537:            }
538:
539:            public Object fetchPropertyByName(String name) {
540:                if (name == "schemaTypeMapping[]")
541:                    return getSchemaTypeMapping();
542:                throw new IllegalArgumentException(name
543:                        + " is not a valid property name for BeanGraph");
544:            }
545:
546:            public String nameSelf() {
547:                return "/BeanGraph";
548:            }
549:
550:            public String nameChild(Object childObj) {
551:                return nameChild(childObj, false, false);
552:            }
553:
554:            /**
555:             * @param childObj  The child object to search for
556:             * @param returnSchemaName  Whether or not the schema name should be returned or the property name
557:             * @return null if not found
558:             */
559:            public String nameChild(Object childObj, boolean returnConstName,
560:                    boolean returnSchemaName) {
561:                return nameChild(childObj, returnConstName, returnSchemaName,
562:                        false);
563:            }
564:
565:            /**
566:             * @param childObj  The child object to search for
567:             * @param returnSchemaName  Whether or not the schema name should be returned or the property name
568:             * @return null if not found
569:             */
570:            public String nameChild(Object childObj, boolean returnConstName,
571:                    boolean returnSchemaName, boolean returnXPathName) {
572:                if (childObj instanceof  SchemaTypeMappingType) {
573:                    SchemaTypeMappingType child = (SchemaTypeMappingType) childObj;
574:                    int index = 0;
575:                    for (java.util.Iterator it = _SchemaTypeMapping.iterator(); it
576:                            .hasNext();) {
577:                        org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType element = (org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType) it
578:                                .next();
579:                        if (child == element) {
580:                            if (returnConstName) {
581:                                return SCHEMA_TYPE_MAPPING;
582:                            } else if (returnSchemaName) {
583:                                return "schema-type-mapping";
584:                            } else if (returnXPathName) {
585:                                return "schema-type-mapping[position()="
586:                                        + index + "]";
587:                            } else {
588:                                return "SchemaTypeMapping."
589:                                        + Integer.toHexString(index);
590:                            }
591:                        }
592:                        ++index;
593:                    }
594:                }
595:                return null;
596:            }
597:
598:            /**
599:             * Return an array of all of the properties that are beans and are set.
600:             */
601:            public org.netbeans.modules.schema2beansdev.beangraph.CommonBean[] childBeans(
602:                    boolean recursive) {
603:                java.util.List children = new java.util.LinkedList();
604:                childBeans(recursive, children);
605:                org.netbeans.modules.schema2beansdev.beangraph.CommonBean[] result = new org.netbeans.modules.schema2beansdev.beangraph.CommonBean[children
606:                        .size()];
607:                return (org.netbeans.modules.schema2beansdev.beangraph.CommonBean[]) children
608:                        .toArray(result);
609:            }
610:
611:            /**
612:             * Put all child beans into the beans list.
613:             */
614:            public void childBeans(boolean recursive, java.util.List beans) {
615:                for (java.util.Iterator it = _SchemaTypeMapping.iterator(); it
616:                        .hasNext();) {
617:                    org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType element = (org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType) it
618:                            .next();
619:                    if (element != null) {
620:                        if (recursive) {
621:                            element.childBeans(true, beans);
622:                        }
623:                        beans.add(element);
624:                    }
625:                }
626:            }
627:
628:            public boolean equals(Object o) {
629:                return o instanceof  org.netbeans.modules.schema2beansdev.beangraph.BeanGraph
630:                        && equals((org.netbeans.modules.schema2beansdev.beangraph.BeanGraph) o);
631:            }
632:
633:            public boolean equals(
634:                    org.netbeans.modules.schema2beansdev.beangraph.BeanGraph inst) {
635:                if (inst == this ) {
636:                    return true;
637:                }
638:                if (inst == null) {
639:                    return false;
640:                }
641:                if (sizeSchemaTypeMapping() != inst.sizeSchemaTypeMapping())
642:                    return false;
643:                // Compare every element.
644:                for (java.util.Iterator it = _SchemaTypeMapping.iterator(), it2 = inst._SchemaTypeMapping
645:                        .iterator(); it.hasNext() && it2.hasNext();) {
646:                    org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType element = (org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType) it
647:                            .next();
648:                    org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType element2 = (org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType) it2
649:                            .next();
650:                    if (!(element == null ? element2 == null : element
651:                            .equals(element2))) {
652:                        return false;
653:                    }
654:                }
655:                return true;
656:            }
657:
658:            public int hashCode() {
659:                int result = 17;
660:                result = 37
661:                        * result
662:                        + (_SchemaTypeMapping == null ? 0 : _SchemaTypeMapping
663:                                .hashCode());
664:                return result;
665:            }
666:
667:            public String toString() {
668:                java.io.StringWriter sw = new java.io.StringWriter();
669:                try {
670:                    writeNode(sw);
671:                } catch (java.io.IOException e) {
672:                    // How can we actually get an IOException on a StringWriter?
673:                    throw new RuntimeException(e);
674:                }
675:                return sw.toString();
676:            }
677:
678:        }
679:
680:        /*
681:         The following schema file has been used for generation:
682:
683:         <?xml version="1.0" ?>
684:
685:         <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
686:         <xsd:element name="bean-graph">
687:         <xsd:complexType>
688:         <xsd:sequence>
689:         <xsd:element name="schema-type-mapping" type="schemaTypeMappingType"
690:         minOccurs="0" maxOccurs="unbounded"/>
691:         </xsd:sequence>
692:         </xsd:complexType>
693:         </xsd:element>
694:
695:         <xsd:complexType name="schemaTypeMappingType">
696:         <xsd:annotation>
697:         <xsd:documentation>
698:         Map between schema types and java types.
699:         </xsd:documentation>
700:         </xsd:annotation>
701:         <xsd:sequence>
702:         <xsd:element name="schema-type-namespace" type="xsd:string" minOccurs="0"/>
703:         <xsd:element name="schema-type-name" type="xsd:string">
704:         <xsd:annotation>
705:         <xsd:documentation>
706:         The schema type; for instance, "string"
707:         </xsd:documentation>
708:         </xsd:annotation>
709:         </xsd:element>
710:         <xsd:element name="java-type" type="xsd:string">
711:         <xsd:annotation>
712:         <xsd:documentation>
713:         The java type; for instance, "java.lang.String", or "int"
714:         </xsd:documentation>
715:         </xsd:annotation>
716:         </xsd:element>
717:         <xsd:element name="root" type="xsd:boolean" minOccurs="0"/>
718:         <xsd:element name="bean" type="xsd:boolean" minOccurs="0"/>
719:         <xsd:element name="can-be-empty" type="xsd:boolean" minOccurs="0"/>
720:         </xsd:sequence>
721:         </xsd:complexType>
722:         </xsd:schema>
723:
724:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.