Source Code Cross Referenced for WildcardImpl.java in  » 6.0-JDK-Modules » jaxb-xjc » com » sun » xml » xsom » impl » 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 » 6.0 JDK Modules » jaxb xjc » com.sun.xml.xsom.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the terms
003:         * of the Common Development and Distribution License
004:         * (the "License").  You may not use this file except
005:         * in compliance with the License.
006:         * 
007:         * You can obtain a copy of the license at
008:         * https://jwsdp.dev.java.net/CDDLv1.0.html
009:         * See the License for the specific language governing
010:         * permissions and limitations under the License.
011:         * 
012:         * When distributing Covered Code, include this CDDL
013:         * HEADER in each file and include the License file at
014:         * https://jwsdp.dev.java.net/CDDLv1.0.html  If applicable,
015:         * add the following below this CDDL HEADER, with the
016:         * fields enclosed by brackets "[]" replaced with your
017:         * own identifying information: Portions Copyright [yyyy]
018:         * [name of copyright owner]
019:         */
020:        package com.sun.xml.xsom.impl;
021:
022:        import com.sun.xml.xsom.XSElementDecl;
023:        import com.sun.xml.xsom.XSModelGroup;
024:        import com.sun.xml.xsom.XSModelGroupDecl;
025:        import com.sun.xml.xsom.XSTerm;
026:        import com.sun.xml.xsom.XSWildcard;
027:        import com.sun.xml.xsom.impl.parser.SchemaDocumentImpl;
028:        import com.sun.xml.xsom.visitor.XSFunction;
029:        import com.sun.xml.xsom.visitor.XSTermFunction;
030:        import com.sun.xml.xsom.visitor.XSTermFunctionWithParam;
031:        import com.sun.xml.xsom.visitor.XSTermVisitor;
032:        import com.sun.xml.xsom.visitor.XSVisitor;
033:        import com.sun.xml.xsom.visitor.XSWildcardFunction;
034:        import com.sun.xml.xsom.visitor.XSWildcardVisitor;
035:        import org.xml.sax.Locator;
036:
037:        import java.util.Collection;
038:        import java.util.Collections;
039:        import java.util.HashSet;
040:        import java.util.Iterator;
041:        import java.util.Set;
042:
043:        public abstract class WildcardImpl extends ComponentImpl implements 
044:                XSWildcard, Ref.Term {
045:            protected WildcardImpl(SchemaDocumentImpl owner,
046:                    AnnotationImpl _annon, Locator _loc,
047:                    ForeignAttributesImpl _fa, int _mode) {
048:                super (owner, _annon, _loc, _fa);
049:                this .mode = _mode;
050:            }
051:
052:            private final int mode;
053:
054:            public int getMode() {
055:                return mode;
056:            }
057:
058:            // compute the union
059:            public WildcardImpl union(SchemaDocumentImpl owner, WildcardImpl rhs) {
060:                if (this  instanceof  Any || rhs instanceof  Any)
061:                    return new Any(owner, null, null, null, mode);
062:
063:                if (this  instanceof  Finite && rhs instanceof  Finite) {
064:                    Set<String> values = new HashSet<String>();
065:                    values.addAll(((Finite) this ).names);
066:                    values.addAll(((Finite) rhs).names);
067:                    return new Finite(owner, null, null, null, values, mode);
068:                }
069:
070:                if (this  instanceof  Other && rhs instanceof  Other) {
071:                    if (((Other) this ).otherNamespace
072:                            .equals(((Other) rhs).otherNamespace))
073:                        return new Other(owner, null, null, null,
074:                                ((Other) this ).otherNamespace, mode);
075:                    else
076:                        // this somewhat strange rule is indeed in the spec
077:                        return new Other(owner, null, null, null, "", mode);
078:                }
079:
080:                Other o;
081:                Finite f;
082:
083:                if (this  instanceof  Other) {
084:                    o = (Other) this ;
085:                    f = (Finite) rhs;
086:                } else {
087:                    o = (Other) rhs;
088:                    f = (Finite) this ;
089:                }
090:
091:                if (f.names.contains(o.otherNamespace))
092:                    return new Any(owner, null, null, null, mode);
093:                else
094:                    return new Other(owner, null, null, null, o.otherNamespace,
095:                            mode);
096:            }
097:
098:            public final static class Any extends WildcardImpl implements 
099:                    XSWildcard.Any {
100:                public Any(SchemaDocumentImpl owner, AnnotationImpl _annon,
101:                        Locator _loc, ForeignAttributesImpl _fa, int _mode) {
102:                    super (owner, _annon, _loc, _fa, _mode);
103:                }
104:
105:                public boolean acceptsNamespace(String namespaceURI) {
106:                    return true;
107:                }
108:
109:                public void visit(XSWildcardVisitor visitor) {
110:                    visitor.any(this );
111:                }
112:
113:                public Object apply(XSWildcardFunction function) {
114:                    return function.any(this );
115:                }
116:            }
117:
118:            public final static class Other extends WildcardImpl implements 
119:                    XSWildcard.Other {
120:                public Other(SchemaDocumentImpl owner, AnnotationImpl _annon,
121:                        Locator _loc, ForeignAttributesImpl _fa,
122:                        String otherNamespace, int _mode) {
123:                    super (owner, _annon, _loc, _fa, _mode);
124:                    this .otherNamespace = otherNamespace;
125:                }
126:
127:                private final String otherNamespace;
128:
129:                public String getOtherNamespace() {
130:                    return otherNamespace;
131:                }
132:
133:                public boolean acceptsNamespace(String namespaceURI) {
134:                    return !namespaceURI.equals(otherNamespace);
135:                }
136:
137:                public void visit(XSWildcardVisitor visitor) {
138:                    visitor.other(this );
139:                }
140:
141:                public Object apply(XSWildcardFunction function) {
142:                    return function.other(this );
143:                }
144:            }
145:
146:            public final static class Finite extends WildcardImpl implements 
147:                    XSWildcard.Union {
148:                public Finite(SchemaDocumentImpl owner, AnnotationImpl _annon,
149:                        Locator _loc, ForeignAttributesImpl _fa,
150:                        Set<String> ns, int _mode) {
151:                    super (owner, _annon, _loc, _fa, _mode);
152:                    names = ns;
153:                    namesView = Collections.unmodifiableSet(names);
154:                }
155:
156:                private final Set<String> names;
157:                private final Set<String> namesView;
158:
159:                public Iterator<String> iterateNamespaces() {
160:                    return names.iterator();
161:                }
162:
163:                public Collection<String> getNamespaces() {
164:                    return namesView;
165:                }
166:
167:                public boolean acceptsNamespace(String namespaceURI) {
168:                    return names.contains(namespaceURI);
169:                }
170:
171:                public void visit(XSWildcardVisitor visitor) {
172:                    visitor.union(this );
173:                }
174:
175:                public Object apply(XSWildcardFunction function) {
176:                    return function.union(this );
177:                }
178:            }
179:
180:            public final void visit(XSVisitor visitor) {
181:                visitor.wildcard(this );
182:            }
183:
184:            public final void visit(XSTermVisitor visitor) {
185:                visitor.wildcard(this );
186:            }
187:
188:            public Object apply(XSTermFunction function) {
189:                return function.wildcard(this );
190:            }
191:
192:            public <T, P> T apply(XSTermFunctionWithParam<T, P> function,
193:                    P param) {
194:                return function.wildcard(this , param);
195:            }
196:
197:            public Object apply(XSFunction function) {
198:                return function.wildcard(this );
199:            }
200:
201:            public boolean isWildcard() {
202:                return true;
203:            }
204:
205:            public boolean isModelGroupDecl() {
206:                return false;
207:            }
208:
209:            public boolean isModelGroup() {
210:                return false;
211:            }
212:
213:            public boolean isElementDecl() {
214:                return false;
215:            }
216:
217:            public XSWildcard asWildcard() {
218:                return this ;
219:            }
220:
221:            public XSModelGroupDecl asModelGroupDecl() {
222:                return null;
223:            }
224:
225:            public XSModelGroup asModelGroup() {
226:                return null;
227:            }
228:
229:            public XSElementDecl asElementDecl() {
230:                return null;
231:            }
232:
233:            // Ref.Term implementation
234:            public XSTerm getTerm() {
235:                return this;
236:            }
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.