Source Code Cross Referenced for JEntityResolver.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas_lib » deployment » validation » 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 » J2EE » JOnAS 4.8.6 » org.objectweb.jonas_lib.deployment.validation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or 1any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * Initial developer: Florent BENOIT
022:         * --------------------------------------------------------------------------
023:         * $Id: JEntityResolver.java 7486 2005-10-07 22:30:10Z glapouch $
024:         * --------------------------------------------------------------------------
025:         */package org.objectweb.jonas_lib.deployment.validation;
026:
027:        import java.io.IOException;
028:        import java.util.HashMap;
029:        import java.util.Iterator;
030:        import java.util.List;
031:        import java.util.Map;
032:
033:        import org.xml.sax.EntityResolver;
034:        import org.xml.sax.InputSource;
035:        import org.xml.sax.SAXException;
036:
037:        import org.objectweb.jonas_lib.deployment.api.DTDs;
038:        import org.objectweb.jonas_lib.deployment.api.Schemas;
039:        import org.objectweb.jonas_lib.deployment.digester.JDigester;
040:
041:        /**
042:         * This class defines the entity resolver used to resolve DTDs/Schemas during
043:         * the xml parsing
044:         * @author Florent Benoit
045:         */
046:        public class JEntityResolver implements  EntityResolver {
047:
048:            /**
049:             * Map which contains DTDs and Schemas available in local
050:             */
051:            private HashMap entries = new HashMap();
052:
053:            /**
054:             * Constructor without JDigester instance (used in WsGen only)
055:             */
056:            public JEntityResolver() {
057:                super ();
058:            }
059:
060:            /**
061:             * Add a local schema to the known entries
062:             * @param path path to a local schema
063:             */
064:            private void addSchema(String path) {
065:                String id = path.substring(path.lastIndexOf('/') + 1);
066:                entries.put(id, path);
067:            }
068:
069:            /**
070:             * The Parser will call this method before opening any external entity except
071:             * the top-level document entity.
072:             * @param publicId The public identifier of the external entity being referenced,
073:             *                 or null if none was supplied.
074:             * @param systemId The system identifier of the external entity being referenced.
075:             * @return An InputSource object describing the new input source, or null to request that
076:             *         the parser open a regular URI connection to the system identifier.
077:             * @throws SAXException Any SAX exception, possibly wrapping another exception.
078:             * @throws IOException A Java-specific IO exception, possibly the result of creating
079:             *                     a new InputStream or Reader for the InputSource.
080:             */
081:            public InputSource resolveEntity(String publicId, String systemId)
082:                    throws IOException, SAXException {
083:
084:                // DTD : check if we got this entry
085:                String localPath = null;
086:                if (publicId != null) {
087:                    localPath = (String) entries.get(publicId);
088:                } else if (systemId != null) {
089:                    // Can be a schema
090:                    if (systemId.toLowerCase().endsWith(".xsd")) {
091:                        // Retrieve basename
092:                        String baseName = systemId.substring(systemId
093:                                .lastIndexOf('/') + 1);
094:
095:                        // Registred ?
096:                        localPath = (String) entries.get(baseName);
097:                    }
098:                }
099:
100:                if (localPath == null) {
101:                    // This DTD/Schema was not added to this DTD/Schame local repository
102:                    return null;
103:                }
104:
105:                // Return the local path source
106:                return (new InputSource(localPath));
107:            }
108:
109:            /**
110:             * Add the mapping between a public Id and the local path of the DTD
111:             * @param dtds Object containing the mapping PublicId --> Local URL
112:             */
113:            public void addDtds(DTDs dtds) {
114:                if (dtds != null) {
115:                    Map dtdsMapping = dtds.getMapping();
116:                    if (dtdsMapping != null) {
117:                        for (Iterator it = dtdsMapping.entrySet().iterator(); it
118:                                .hasNext();) {
119:                            Map.Entry entry = (Map.Entry) it.next();
120:                            String publicId = (String) entry.getKey();
121:                            String localURL = (String) entry.getValue();
122:                            entries.put(publicId, localURL);
123:                        }
124:                    }
125:                }
126:            }
127:
128:            /**
129:             * Add the given Schemas to the schemas available for this resolver
130:             * @param schemas Definition of the schemas to add to this resolver
131:             */
132:            public void addSchemas(Schemas schemas) {
133:                // no schemas
134:                if (schemas == null) {
135:                    return;
136:                }
137:
138:                List localSchemas = schemas.getlocalSchemas();
139:
140:                // there are schemas
141:                if (localSchemas != null) {
142:                    for (Iterator it = localSchemas.iterator(); it.hasNext();) {
143:                        String schema = (String) it.next();
144:                        addSchema(schema);
145:                    }
146:                }
147:            }
148:
149:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.