Source Code Cross Referenced for AbstractDocument.java in  » 6.0-JDK-Modules-com.sun » tools » com » sun » tools » internal » ws » wsdl » framework » 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 com.sun » tools » com.sun.tools.internal.ws.wsdl.framework 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Portions Copyright 2006 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:
026:        package com.sun.tools.internal.ws.wsdl.framework;
027:
028:        import java.util.ArrayList;
029:        import java.util.HashMap;
030:        import java.util.HashSet;
031:        import java.util.Iterator;
032:        import java.util.List;
033:        import java.util.Map;
034:        import java.util.Set;
035:
036:        import javax.xml.namespace.QName;
037:
038:        /**
039:         * An abstract class for documents containing entities.
040:         *
041:         * @author WS Development Team
042:         */
043:        public abstract class AbstractDocument {
044:
045:            protected AbstractDocument() {
046:                _kinds = new HashMap();
047:                _identifiables = new HashMap();
048:                _importedEntities = new ArrayList();
049:                _importedDocuments = new HashSet();
050:                _includedEntities = new ArrayList();
051:                _includedDocuments = new HashSet();
052:            }
053:
054:            public String getSystemId() {
055:                return _systemId;
056:            }
057:
058:            public void setSystemId(String s) {
059:                if (_systemId != null && !_systemId.equals(s)) {
060:                    // avoid redefinition of a system identifier
061:                    throw new IllegalArgumentException();
062:                }
063:
064:                _systemId = s;
065:                if (s != null) {
066:                    _importedDocuments.add(s);
067:                }
068:            }
069:
070:            public void addIncludedDocument(String systemId) {
071:                _includedDocuments.add(systemId);
072:            }
073:
074:            public boolean isIncludedDocument(String systemId) {
075:                return _includedDocuments.contains(systemId);
076:            }
077:
078:            public void addIncludedEntity(Entity entity) {
079:                _includedEntities.add(entity);
080:            }
081:
082:            public void addImportedDocument(String systemId) {
083:                _importedDocuments.add(systemId);
084:            }
085:
086:            public boolean isImportedDocument(String systemId) {
087:                return _importedDocuments.contains(systemId);
088:            }
089:
090:            public void addImportedEntity(Entity entity) {
091:                _importedEntities.add(entity);
092:            }
093:
094:            public void withAllSubEntitiesDo(EntityAction action) {
095:                if (getRoot() != null) {
096:                    action.perform(getRoot());
097:                }
098:
099:                for (Iterator iter = _importedEntities.iterator(); iter
100:                        .hasNext();) {
101:                    action.perform((Entity) iter.next());
102:                }
103:
104:                for (Iterator iter = _includedEntities.iterator(); iter
105:                        .hasNext();) {
106:                    action.perform((Entity) iter.next());
107:                }
108:            }
109:
110:            public Map getMap(Kind k) {
111:                Map m = (Map) _kinds.get(k.getName());
112:                if (m == null) {
113:                    m = new HashMap();
114:                    _kinds.put(k.getName(), m);
115:                }
116:                return m;
117:            }
118:
119:            public void define(GloballyKnown e) {
120:                Map map = getMap(e.getKind());
121:                if (e.getName() == null)
122:                    return;
123:                QName name = new QName(e.getDefining().getTargetNamespaceURI(),
124:                        e.getName());
125:
126:                if (map.containsKey(name))
127:                    throw new DuplicateEntityException(e);
128:                else
129:                    map.put(name, e);
130:            }
131:
132:            public void undefine(GloballyKnown e) {
133:                Map map = getMap(e.getKind());
134:                if (e.getName() == null)
135:                    return;
136:                QName name = new QName(e.getDefining().getTargetNamespaceURI(),
137:                        e.getName());
138:
139:                if (map.containsKey(name))
140:                    throw new NoSuchEntityException(name);
141:                else
142:                    map.remove(name);
143:            }
144:
145:            public GloballyKnown find(Kind k, QName name) {
146:                Map map = getMap(k);
147:                Object result = map.get(name);
148:                if (result == null)
149:                    throw new NoSuchEntityException(name);
150:                return (GloballyKnown) result;
151:            }
152:
153:            public void defineID(Identifiable e) {
154:                String id = e.getID();
155:                if (id == null)
156:                    return;
157:
158:                if (_identifiables.containsKey(id))
159:                    throw new DuplicateEntityException(e);
160:                else
161:                    _identifiables.put(id, e);
162:            }
163:
164:            public void undefineID(Identifiable e) {
165:                String id = e.getID();
166:
167:                if (id == null)
168:                    return;
169:
170:                if (_identifiables.containsKey(id))
171:                    throw new NoSuchEntityException(id);
172:                else
173:                    _identifiables.remove(id);
174:            }
175:
176:            public Identifiable findByID(String id) {
177:                Object result = _identifiables.get(id);
178:                if (result == null)
179:                    throw new NoSuchEntityException(id);
180:                return (Identifiable) result;
181:            }
182:
183:            public Set collectAllQNames() {
184:                final Set result = new HashSet();
185:                EntityAction action = new EntityAction() {
186:                    public void perform(Entity entity) {
187:                        entity.withAllQNamesDo(new QNameAction() {
188:                            public void perform(QName name) {
189:                                result.add(name);
190:                            }
191:                        });
192:                        entity.withAllSubEntitiesDo(this );
193:                    }
194:                };
195:                withAllSubEntitiesDo(action);
196:                return result;
197:            }
198:
199:            public Set collectAllNamespaces() {
200:                final Set result = new HashSet();
201:
202:                EntityAction action = new EntityAction() {
203:                    public void perform(Entity entity) {
204:                        entity.withAllQNamesDo(new QNameAction() {
205:                            public void perform(QName name) {
206:                                result.add(name.getNamespaceURI());
207:                            }
208:                        });
209:
210:                        entity.withAllSubEntitiesDo(this );
211:                    }
212:                };
213:                withAllSubEntitiesDo(action);
214:                return result;
215:            }
216:
217:            public void validateLocally() {
218:                LocallyValidatingAction action = new LocallyValidatingAction();
219:                withAllSubEntitiesDo(action);
220:                if (action.getException() != null) {
221:                    throw action.getException();
222:                }
223:            }
224:
225:            public void validate() {
226:                validate(null);
227:            }
228:
229:            public abstract void validate(EntityReferenceValidator validator);
230:
231:            protected abstract Entity getRoot();
232:
233:            private Map _kinds;
234:            private Map _identifiables;
235:            private String _systemId;
236:            private Set _importedDocuments;
237:            private List _importedEntities;
238:            private Set _includedDocuments;
239:            private List _includedEntities;
240:
241:            private class LocallyValidatingAction implements  EntityAction {
242:                public LocallyValidatingAction() {
243:                }
244:
245:                public void perform(Entity entity) {
246:                    try {
247:                        entity.validateThis();
248:                        entity.withAllSubEntitiesDo(this );
249:                    } catch (ValidationException e) {
250:                        if (_exception == null) {
251:                            _exception = e;
252:                        }
253:                    }
254:                }
255:
256:                public ValidationException getException() {
257:                    return _exception;
258:                }
259:
260:                private ValidationException _exception;
261:            }
262:        }
www_._j_a_va_2___s__.__c___o___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.