Source Code Cross Referenced for XMLBasicReader.java in  » Database-ORM » MMBase » org » mmbase » util » 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 » Database ORM » MMBase » org.mmbase.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:        This software is OSI Certified Open Source Software.
004:        OSI Certified is a certification mark of the Open Source Initiative.
005:
006:        The license (Mozilla version 1.0) can be read at the MMBase site.
007:        See http://www.MMBase.org/license
008:
009:         */
010:        package org.mmbase.util;
011:
012:        import java.io.*;
013:
014:        import javax.xml.parsers.DocumentBuilder;
015:
016:        import org.mmbase.util.logging.Logger;
017:        import org.mmbase.util.logging.Logging;
018:        import org.mmbase.util.xml.DocumentReader;
019:        import org.xml.sax.*;
020:
021:        /**
022:         * XMLBasicReader has two goals.
023:         *  <ul>
024:         *    <li>It provides a way for parsing XML</li>
025:         *    <li>It provides a way for searching in this XML, without the need for an XPath implementation, and without the hassle of org.w3c.dom alone.
026:         *    It uses dots to lay a path in the XML (XPath uses slashes).</li>
027:         *  </ul>
028:         *
029:         * @deprecated use DocumentReader or DocumentWriter. Some code may need to be moved to DocumentReader
030:         * @author Case Roule
031:         * @author Rico Jansen
032:         * @author Pierre van Rooden
033:         * @author Michiel Meeuwissen
034:         * @version $Id: XMLBasicReader.java,v 1.46 2006/01/26 10:21:50 michiel Exp $
035:         */
036:        public class XMLBasicReader extends DocumentReader {
037:
038:            private static Logger log = Logging
039:                    .getLoggerInstance(XMLBasicReader.class);
040:
041:            public XMLBasicReader(String path) {
042:                super (getInputSource(path));
043:            }
044:
045:            public XMLBasicReader(String path, boolean validating) {
046:                super (getInputSource(path), validating, null);
047:            }
048:
049:            public XMLBasicReader(String path, Class resolveBase) {
050:                super (getInputSource(path), DocumentReader.validate(),
051:                        resolveBase);
052:            }
053:
054:            public XMLBasicReader() {
055:                super ();
056:            }
057:
058:            public XMLBasicReader(InputSource source, boolean validating,
059:                    Class resolveBase) {
060:                super (source, validating, resolveBase);
061:            }
062:
063:            public XMLBasicReader(InputSource source, boolean validating) {
064:                super (source, validating);
065:            }
066:
067:            public XMLBasicReader(InputSource source, Class resolveBase) {
068:                super (source, resolveBase);
069:            }
070:
071:            public XMLBasicReader(InputSource source) {
072:                super (source);
073:            }
074:
075:            /**
076:             * Creates an input source for a document, based on a filepath
077:             * If the file cannot be opened, the method returns an inputsource of an error document describing the condition
078:             * under which this failed.
079:             * @param  path the path to the file containing the document
080:             * @return the input source to the document.
081:             * @deprecated
082:             */
083:            public static InputSource getInputSource(String path) {
084:                InputSource is;
085:                try {
086:                    // remove file protocol if present to avoid errors in accessing file
087:                    if (path.startsWith("file://")) {
088:                        try {
089:                            path = new java.net.URL(path).getPath();
090:                        } catch (java.net.MalformedURLException mfe) {
091:                        }
092:                    }
093:                    is = new InputSource(new FileInputStream(path));
094:                    try {
095:                        is.setSystemId(new File(path).toURL().toExternalForm());
096:                    } catch (java.net.MalformedURLException mfe) {
097:                    }
098:                    is.setSystemId("file://" + path);
099:                } catch (java.io.FileNotFoundException e) {
100:                    log.error("Error reading " + path + ": " + e.toString());
101:                    log.service("Using empty source");
102:                    // try to handle more or less gracefully
103:                    is = new InputSource();
104:                    is.setSystemId(FILENOTFOUND + path);
105:                    is
106:                            .setCharacterStream(new StringReader(
107:                                    "<?xml version=\"1.0\"?>\n"
108:                                            + "<!DOCTYPE error PUBLIC \""
109:                                            + PUBLIC_ID_ERROR
110:                                            + "\""
111:                                            + " \"http://www.mmbase.org/dtd/error_1_0.dtd\">\n"
112:                                            + "<error>" + path
113:                                            + " not found</error>"));
114:                }
115:                return is;
116:            }
117:
118:            /**
119:             * Obtain a DocumentBuilder
120:             * @deprecated use {!link DocumentReader.getDocumentBuilder(boolean, ErrorHandler, EntityResolver)}
121:             */
122:            public static DocumentBuilder getDocumentBuilder(
123:                    boolean validating, ErrorHandler handler) {
124:                return DocumentReader.getDocumentBuilder(validating, handler,
125:                        null);
126:            }
127:
128:            /**
129:             * Obtain a DocumentBuilder
130:             * @deprecated use {!link DocumentReader.getDocumentBuilder(boolean, ErrorHandler, EntityResolver)}
131:             */
132:            public static DocumentBuilder getDocumentBuilder(
133:                    boolean validating, EntityResolver resolver) {
134:                return DocumentReader.getDocumentBuilder(validating, null,
135:                        resolver);
136:            }
137:
138:            /**
139:             * Obtain a DocumentBuilder
140:             * @deprecated use {!link DocumentReader.getDocumentBuilder(boolean, ErrorHandler, EntityResolver)}
141:             */
142:            public static DocumentBuilder getDocumentBuilder(
143:                    boolean validating, ErrorHandler handler,
144:                    EntityResolver resolver) {
145:                return DocumentReader.getDocumentBuilder(validating, handler,
146:                        resolver);
147:            }
148:
149:            /**
150:             * Obtain a DocumentBuilder
151:             * @deprecated use {!link DocumentReader.getDocumentBuilder(boolean, ErrorHandler, EntityResolver)}
152:             */
153:            public static DocumentBuilder getDocumentBuilder(Class refer) {
154:                return DocumentReader.getDocumentBuilder(DocumentReader
155:                        .validate(), null, new XMLEntityResolver(DocumentReader
156:                        .validate(), refer));
157:            }
158:
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.