Source Code Cross Referenced for GlobalComplexType.java in  » Library » Apache-commons-betwixt-0.8-src » org » apache » commons » betwixt » schema » 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 » Library » Apache commons betwixt 0.8 src » org.apache.commons.betwixt.schema 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.commons.betwixt.schema;
019:
020:        import java.beans.IntrospectionException;
021:        import java.util.Collection;
022:        import java.util.Iterator;
023:
024:        import org.apache.commons.betwixt.ElementDescriptor;
025:
026:        /**
027:         * Models a <code>complexType</code> from an XML schema.
028:         * A complex type may contain element content and may have attributes.
029:         * @author <a href='http://jakarta.apache.org/'>Jakarta Commons Team</a>
030:         * @version $Revision: 438373 $
031:         */
032:        public class GlobalComplexType extends ComplexType {
033:
034:            private String name;
035:            private TranscriptionConfiguration configuration;
036:
037:            public GlobalComplexType() {
038:            }
039:
040:            /**
041:             * Constructs a new ComplexType from the descriptor given.
042:             * @param elementDescriptor
043:             */
044:            public GlobalComplexType(TranscriptionConfiguration configuration,
045:                    ElementDescriptor elementDescriptor, Schema schema)
046:                    throws IntrospectionException {
047:                super (configuration, elementDescriptor, schema);
048:            }
049:
050:            protected void init(TranscriptionConfiguration configuration,
051:                    ElementDescriptor elementDescriptor, Schema schema)
052:                    throws IntrospectionException {
053:                this .configuration = configuration;
054:                setName(nameFromDescriptor(elementDescriptor));
055:            }
056:
057:            /**
058:             * Fills the complex type description.
059:             * @since 0.7
060:             * @param configuration
061:             * @param elementDescriptor
062:             * @param schema
063:             * @throws IntrospectionException
064:             */
065:            protected void fill(TranscriptionConfiguration configuration,
066:                    ElementDescriptor elementDescriptor, Schema schema)
067:                    throws IntrospectionException {
068:                elementDescriptor = fillDescriptor(elementDescriptor, schema);
069:                super .init(configuration, elementDescriptor, schema);
070:            }
071:
072:            private String nameFromDescriptor(
073:                    ElementDescriptor elementDescriptor) {
074:                return configuration.getSchemaTypeNamingStrategy()
075:                        .nameSchemaType(elementDescriptor);
076:            }
077:
078:            /**
079:             * Does the given element descriptor match this complex type?
080:             * @since 0.7
081:             * @param elementDescriptor
082:             * @return true if the descriptor matches
083:             */
084:            public boolean matches(ElementDescriptor elementDescriptor) {
085:                String nameFromDescriptor = nameFromDescriptor(elementDescriptor);
086:                return nameFromDescriptor.equals(getName());
087:            }
088:
089:            /**
090:             * Gets the name of this type.
091:             * @return the name of this type
092:             */
093:            public String getName() {
094:                return name;
095:            }
096:
097:            /**
098:             * Sets the name of this type.
099:             * @param string
100:             */
101:            public void setName(String string) {
102:                name = string;
103:            }
104:
105:            public boolean equals(Object obj) {
106:                boolean result = false;
107:                if (obj instanceof  GlobalComplexType) {
108:                    GlobalComplexType complexType = (GlobalComplexType) obj;
109:                    result = isEqual(name, complexType.name)
110:                            && equalContents(attributes, complexType.attributes)
111:                            && equalContents(elements, complexType.elements);
112:
113:                }
114:                return result;
115:            }
116:
117:            public int hashCode() {
118:                return 0;
119:            }
120:
121:            private boolean equalContents(Collection one, Collection two) {
122:                // doesn't check cardinality but should be ok
123:                if (one.size() != two.size()) {
124:                    return false;
125:                }
126:                for (Iterator it = one.iterator(); it.hasNext();) {
127:                    Object object = it.next();
128:                    if (!two.contains(object)) {
129:                        return false;
130:                    }
131:                }
132:                return true;
133:            }
134:
135:            /**
136:             * Null safe equals method
137:             * @param one
138:             * @param two
139:             * @return
140:             */
141:            private boolean isEqual(String one, String two) {
142:                boolean result = false;
143:                if (one == null) {
144:                    result = (two == null);
145:                } else {
146:                    result = one.equals(two);
147:                }
148:
149:                return result;
150:            }
151:
152:            public String toString() {
153:                StringBuffer buffer = new StringBuffer();
154:                buffer.append("<xsd:complexType name='");
155:                buffer.append(name);
156:                buffer.append("'>");
157:                buffer.append("<xsd:sequence>");
158:                for (Iterator it = elements.iterator(); it.hasNext();) {
159:                    buffer.append(it.next());
160:                }
161:                buffer.append("</xsd:sequence>");
162:
163:                for (Iterator it = attributes.iterator(); it.hasNext();) {
164:                    buffer.append(it.next());
165:                }
166:                buffer.append("</xsd:complexType>");
167:                return buffer.toString();
168:            }
169:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.