Source Code Cross Referenced for EntityResolver.java in  » 6.0-JDK-Core » xml » org » xml » sax » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
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
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » xml » org.xml.sax 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 2000-2005 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        // SAX entity resolver.
027        // http://www.saxproject.org
028        // No warranty; no copyright -- use this as you will.
029        // $Id: EntityResolver.java,v 1.2 2004/11/03 22:44:52 jsuttor Exp $
030        package org.xml.sax;
031
032        import java.io.IOException;
033
034        /**
035         * Basic interface for resolving entities.
036         *
037         * <blockquote>
038         * <em>This module, both source code and documentation, is in the
039         * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
040         * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
041         * for further information.
042         * </blockquote>
043         *
044         * <p>If a SAX application needs to implement customized handling
045         * for external entities, it must implement this interface and
046         * register an instance with the SAX driver using the
047         * {@link org.xml.sax.XMLReader#setEntityResolver setEntityResolver}
048         * method.</p>
049         *
050         * <p>The XML reader will then allow the application to intercept any
051         * external entities (including the external DTD subset and external
052         * parameter entities, if any) before including them.</p>
053         *
054         * <p>Many SAX applications will not need to implement this interface,
055         * but it will be especially useful for applications that build
056         * XML documents from databases or other specialised input sources,
057         * or for applications that use URI types other than URLs.</p>
058         *
059         * <p>The following resolver would provide the application
060         * with a special character stream for the entity with the system
061         * identifier "http://www.myhost.com/today":</p>
062         *
063         * <pre>
064         * import org.xml.sax.EntityResolver;
065         * import org.xml.sax.InputSource;
066         *
067         * public class MyResolver implements EntityResolver {
068         *   public InputSource resolveEntity (String publicId, String systemId)
069         *   {
070         *     if (systemId.equals("http://www.myhost.com/today")) {
071         *              // return a special input source
072         *       MyReader reader = new MyReader();
073         *       return new InputSource(reader);
074         *     } else {
075         *              // use the default behaviour
076         *       return null;
077         *     }
078         *   }
079         * }
080         * </pre>
081         *
082         * <p>The application can also use this interface to redirect system
083         * identifiers to local URIs or to look up replacements in a catalog
084         * (possibly by using the public identifier).</p>
085         *
086         * @since SAX 1.0
087         * @author David Megginson
088         * @version 2.0.1 (sax2r2)
089         * @see org.xml.sax.XMLReader#setEntityResolver
090         * @see org.xml.sax.InputSource
091         */
092        public interface EntityResolver {
093
094            /**
095             * Allow the application to resolve external entities.
096             *
097             * <p>The parser will call this method before opening any external
098             * entity except the top-level document entity.  Such entities include
099             * the external DTD subset and external parameter entities referenced
100             * within the DTD (in either case, only if the parser reads external
101             * parameter entities), and external general entities referenced
102             * within the document element (if the parser reads external general
103             * entities).  The application may request that the parser locate
104             * the entity itself, that it use an alternative URI, or that it
105             * use data provided by the application (as a character or byte
106             * input stream).</p>
107             *
108             * <p>Application writers can use this method to redirect external
109             * system identifiers to secure and/or local URIs, to look up
110             * public identifiers in a catalogue, or to read an entity from a
111             * database or other input source (including, for example, a dialog
112             * box).  Neither XML nor SAX specifies a preferred policy for using
113             * public or system IDs to resolve resources.  However, SAX specifies
114             * how to interpret any InputSource returned by this method, and that
115             * if none is returned, then the system ID will be dereferenced as
116             * a URL.  </p>
117             *
118             * <p>If the system identifier is a URL, the SAX parser must
119             * resolve it fully before reporting it to the application.</p>
120             *
121             * @param publicId The public identifier of the external entity
122             *        being referenced, or null if none was supplied.
123             * @param systemId The system identifier of the external entity
124             *        being referenced.
125             * @return An InputSource object describing the new input source,
126             *         or null to request that the parser open a regular
127             *         URI connection to the system identifier.
128             * @exception org.xml.sax.SAXException Any SAX exception, possibly
129             *            wrapping another exception.
130             * @exception java.io.IOException A Java-specific IO exception,
131             *            possibly the result of creating a new InputStream
132             *            or Reader for the InputSource.
133             * @see org.xml.sax.InputSource
134             */
135            public abstract InputSource resolveEntity(String publicId,
136                    String systemId) throws SAXException, IOException;
137
138        }
139
140        // end of EntityResolver.java
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.