Source Code Cross Referenced for XMLReaderBase.java in  » J2EE » enhydra » sax » 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 » enhydra » sax 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*-- 
0002:
0003:         Copyright (C) 2000 Brett McLaughlin & Jason Hunter.
0004:         All rights reserved.
0005:         
0006:         Redistribution and use in source and binary forms, with or without
0007:         modification, are permitted provided that the following conditions
0008:         are met:
0009:         
0010:         1. Redistributions of source code must retain the above copyright
0011:            notice, this list of conditions, and the following disclaimer.
0012:         
0013:         2. Redistributions in binary form must reproduce the above copyright
0014:            notice, this list of conditions, and the disclaimer that follows 
0015:            these conditions in the documentation and/or other materials 
0016:            provided with the distribution.
0017:
0018:         3. The name "JDOM" must not be used to endorse or promote products
0019:            derived from this software without prior written permission.  For
0020:            written permission, please contact license@jdom.org.
0021:         
0022:         4. Products derived from this software may not be called "JDOM", nor
0023:            may "JDOM" appear in their name, without prior written permission
0024:            from the JDOM Project Management (pm@jdom.org).
0025:         
0026:         In addition, we request (but do not require) that you include in the 
0027:         end-user documentation provided with the redistribution and/or in the 
0028:         software itself an acknowledgement equivalent to the following:
0029:             "This product includes software developed by the
0030:              JDOM Project (http://www.jdom.org/)."
0031:         Alternatively, the acknowledgment may be graphical using the logos 
0032:         available at http://www.jdom.org/images/logos.
0033:
0034:         THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
0035:         WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0036:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
0037:         DISCLAIMED.  IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT
0038:         CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0039:         SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0040:         LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
0041:         USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
0042:         ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
0043:         OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
0044:         OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
0045:         SUCH DAMAGE.
0046:
0047:         This software consists of voluntary contributions made by many 
0048:         individuals on behalf of the JDOM Project and was originally 
0049:         created by Brett McLaughlin <brett@jdom.org> and 
0050:         Jason Hunter <jhunter@jdom.org>.  For more information on the 
0051:         JDOM Project, please see <http://www.jdom.org/>.
0052:         
0053:         */
0054:        package sax;
0055:
0056:        import java.io.IOException;
0057:
0058:        import org.xml.sax.Attributes;
0059:        import org.xml.sax.ContentHandler;
0060:        import org.xml.sax.DTDHandler;
0061:        import org.xml.sax.EntityResolver;
0062:        import org.xml.sax.ErrorHandler;
0063:        import org.xml.sax.InputSource;
0064:        import org.xml.sax.Locator;
0065:        import org.xml.sax.SAXException;
0066:        import org.xml.sax.SAXParseException;
0067:        import org.xml.sax.SAXNotSupportedException;
0068:        import org.xml.sax.SAXNotRecognizedException;
0069:        import org.xml.sax.XMLReader;
0070:        import org.xml.sax.ext.LexicalHandler;
0071:        import org.xml.sax.helpers.AttributesImpl;
0072:        import org.xml.sax.helpers.DefaultHandler;
0073:
0074:        /**
0075:         * Base class for implementing an XML reader.
0076:         *
0077:         * Adapted from David Megginson's XMLFilterImpl and XMLFilterBase.
0078:         */
0079:        public abstract class XMLReaderBase extends DefaultHandler implements 
0080:                LexicalHandler, XMLReader {
0081:
0082:            ////////////////////////////////////////////////////////////////////
0083:            // Constructors.
0084:            ////////////////////////////////////////////////////////////////////
0085:
0086:            /**
0087:             * Creates new XMLReaderBase.
0088:             */
0089:            public XMLReaderBase() {
0090:            }
0091:
0092:            ////////////////////////////////////////////////////////////////////
0093:            // Convenience methods.
0094:            ////////////////////////////////////////////////////////////////////
0095:
0096:            /**
0097:             * Start a new element without a qname or attributes.
0098:             *
0099:             * <p>This method will provide a default empty attribute
0100:             * list and an empty string for the qualified name. It invokes
0101:             * {@link #startElement(String, String, String, Attributes)}
0102:             * directly.</p>
0103:             *
0104:             * @param uri The element's Namespace URI.
0105:             * @param localName The element's local name.
0106:             * @exception org.xml.sax.SAXException If a filter
0107:             *            further down the chain raises an exception.
0108:             * @see org.xml.sax.ContentHandler#startElement
0109:             */
0110:            public void startElement(String uri, String localName)
0111:                    throws SAXException {
0112:                startElement(uri, localName, "", EMPTY_ATTS);
0113:            }
0114:
0115:            /**
0116:             * Start a new element without a Namespace URI or qname.
0117:             *
0118:             * <p>This method will provide an empty string for the
0119:             * Namespace URI, and empty string for the qualified name.
0120:             * It invokes
0121:             * {@link #startElement(String, String, String, Attributes)}
0122:             * directly.</p>
0123:             *
0124:             * @param localName The element's local name.
0125:             * @param atts The element's attribute list.
0126:             * @exception org.xml.sax.SAXException If a filter
0127:             *            further down the chain raises an exception.
0128:             * @see org.xml.sax.ContentHandler#startElement
0129:             */
0130:            public void startElement(String localName, Attributes atts)
0131:                    throws SAXException {
0132:                startElement("", localName, "", atts);
0133:            }
0134:
0135:            /**
0136:             * Start a new element without a Namespace URI, qname, or attributes.
0137:             *
0138:             * <p>This method will provide an empty string for the
0139:             * Namespace URI, and empty string for the qualified name,
0140:             * and a default empty attribute list. It invokes
0141:             * {@link #startElement(String, String, String, Attributes)}
0142:             * directly.</p>
0143:             *
0144:             * @param localName The element's local name.
0145:             * @exception org.xml.sax.SAXException If a filter
0146:             *            further down the chain raises an exception.
0147:             * @see org.xml.sax.ContentHandler#startElement
0148:             */
0149:            public void startElement(String localName) throws SAXException {
0150:                startElement("", localName, "", EMPTY_ATTS);
0151:            }
0152:
0153:            /**
0154:             * End an element without a qname.
0155:             *
0156:             * <p>This method will supply an empty string for the qName.
0157:             * It invokes {@link #endElement(String, String, String)}
0158:             * directly.</p>
0159:             *
0160:             * @param uri The element's Namespace URI.
0161:             * @param localName The element's local name.
0162:             * @exception org.xml.sax.SAXException If a filter
0163:             *            further down the chain raises an exception.
0164:             * @see org.xml.sax.ContentHandler#endElement
0165:             */
0166:            public void endElement(String uri, String localName)
0167:                    throws SAXException {
0168:                endElement(uri, localName, "");
0169:            }
0170:
0171:            /**
0172:             * End an element without a Namespace URI or qname.
0173:             *
0174:             * <p>This method will supply an empty string for the qName
0175:             * and an empty string for the Namespace URI.
0176:             * It invokes {@link #endElement(String, String, String)}
0177:             * directly.</p>
0178:             *
0179:             * @param localName The element's local name.
0180:             * @exception org.xml.sax.SAXException If a filter
0181:             *            further down the chain raises an exception.
0182:             * @see org.xml.sax.ContentHandler#endElement
0183:             */
0184:            public void endElement(String localName) throws SAXException {
0185:                endElement("", localName, "");
0186:            }
0187:
0188:            /**
0189:             * Add an empty element.
0190:             *
0191:             * Both a {@link #startElement startElement} and an
0192:             * {@link #endElement endElement} event will be passed on down
0193:             * the filter chain.
0194:             *
0195:             * @param uri The element's Namespace URI, or the empty string
0196:             *        if the element has no Namespace or if Namespace
0197:             *        processing is not being performed.
0198:             * @param localName The element's local name (without prefix).  This
0199:             *        parameter must be provided.
0200:             * @param qName The element's qualified name (with prefix), or
0201:             *        the empty string if none is available.  This parameter
0202:             *        is strictly advisory: the writer may or may not use
0203:             *        the prefix attached.
0204:             * @param atts The element's attribute list.
0205:             * @exception org.xml.sax.SAXException If a filter
0206:             *            further down the chain raises an exception.
0207:             * @see org.xml.sax.ContentHandler#startElement
0208:             * @see org.xml.sax.ContentHandler#endElement
0209:             */
0210:            public void emptyElement(String uri, String localName,
0211:                    String qName, Attributes atts) throws SAXException {
0212:                startElement(uri, localName, qName, atts);
0213:                endElement(uri, localName, qName);
0214:            }
0215:
0216:            /**
0217:             * Add an empty element without a qname or attributes.
0218:             *
0219:             * <p>This method will supply an empty string for the qname
0220:             * and an empty attribute list.  It invokes
0221:             * {@link #emptyElement(String, String, String, Attributes)}
0222:             * directly.</p>
0223:             *
0224:             * @param uri The element's Namespace URI.
0225:             * @param localName The element's local name.
0226:             * @exception org.xml.sax.SAXException If a filter
0227:             *            further down the chain raises an exception.
0228:             * @see #emptyElement(String, String, String, Attributes)
0229:             */
0230:            public void emptyElement(String uri, String localName)
0231:                    throws SAXException {
0232:                emptyElement(uri, localName, "", EMPTY_ATTS);
0233:            }
0234:
0235:            /**
0236:             * Add an empty element without a Namespace URI or qname.
0237:             *
0238:             * <p>This method will provide an empty string for the
0239:             * Namespace URI, and empty string for the qualified name.
0240:             * It invokes
0241:             * {@link #emptyElement(String, String, String, Attributes)}
0242:             * directly.</p>
0243:             *
0244:             * @param localName The element's local name.
0245:             * @param atts The element's attribute list.
0246:             * @exception org.xml.sax.SAXException If a filter
0247:             *            further down the chain raises an exception.
0248:             * @see org.xml.sax.ContentHandler#startElement
0249:             */
0250:            public void emptyElement(String localName, Attributes atts)
0251:                    throws SAXException {
0252:                emptyElement("", localName, "", atts);
0253:            }
0254:
0255:            /**
0256:             * Add an empty element without a Namespace URI, qname or attributes.
0257:             *
0258:             * <p>This method will supply an empty string for the qname,
0259:             * and empty string for the Namespace URI, and an empty
0260:             * attribute list.  It invokes
0261:             * {@link #emptyElement(String, String, String, Attributes)}
0262:             * directly.</p>
0263:             *
0264:             * @param localName The element's local name.
0265:             * @exception org.xml.sax.SAXException If a filter
0266:             *            further down the chain raises an exception.
0267:             * @see #emptyElement(String, String, String, Attributes)
0268:             */
0269:            public void emptyElement(String localName) throws SAXException {
0270:                emptyElement("", localName, "", EMPTY_ATTS);
0271:            }
0272:
0273:            /**
0274:             * Add an element with character data content.
0275:             *
0276:             * <p>This is a convenience method to add a complete element
0277:             * with character data content, including the start tag
0278:             * and end tag.</p>
0279:             *
0280:             * <p>This method invokes
0281:             * {@link @see org.xml.sax.ContentHandler#startElement},
0282:             * followed by
0283:             * {@link #characters(String)}, followed by
0284:             * {@link @see org.xml.sax.ContentHandler#endElement}.</p>
0285:             *
0286:             * @param uri The element's Namespace URI.
0287:             * @param localName The element's local name.
0288:             * @param qName The element's default qualified name.
0289:             * @param atts The element's attributes.
0290:             * @param content The character data content.
0291:             * @exception org.xml.sax.SAXException If a filter
0292:             *            further down the chain raises an exception.
0293:             * @see org.xml.sax.ContentHandler#startElement
0294:             * @see #characters(String)
0295:             * @see org.xml.sax.ContentHandler#endElement
0296:             */
0297:            public void dataElement(String uri, String localName, String qName,
0298:                    Attributes atts, String content) throws SAXException {
0299:                startElement(uri, localName, qName, atts);
0300:                characters(content);
0301:                endElement(uri, localName, qName);
0302:            }
0303:
0304:            /**
0305:             * Add an element with character data content but no qname or attributes.
0306:             *
0307:             * <p>This is a convenience method to add a complete element
0308:             * with character data content, including the start tag
0309:             * and end tag.  This method provides an empty string
0310:             * for the qname and an empty attribute list. It invokes
0311:             * {@link #dataElement(String, String, String, Attributes, String)}}
0312:             * directly.</p>
0313:             *
0314:             * @param uri The element's Namespace URI.
0315:             * @param localName The element's local name.
0316:             * @param content The character data content.
0317:             * @exception org.xml.sax.SAXException If a filter
0318:             *            further down the chain raises an exception.
0319:             * @see org.xml.sax.ContentHandler#startElement
0320:             * @see #characters(String)
0321:             * @see org.xml.sax.ContentHandler#endElement
0322:             */
0323:            public void dataElement(String uri, String localName, String content)
0324:                    throws SAXException {
0325:                dataElement(uri, localName, "", EMPTY_ATTS, content);
0326:            }
0327:
0328:            /**
0329:             * Add an element with character data content but no Namespace URI or qname.
0330:             *
0331:             * <p>This is a convenience method to add a complete element
0332:             * with character data content, including the start tag
0333:             * and end tag.  The method provides an empty string for the
0334:             * Namespace URI, and empty string for the qualified name. It invokes
0335:             * {@link #dataElement(String, String, String, Attributes, String)}}
0336:             * directly.</p>
0337:             *
0338:             * @param localName The element's local name.
0339:             * @param atts The element's attributes.
0340:             * @param content The character data content.
0341:             * @exception org.xml.sax.SAXException If a filter
0342:             *            further down the chain raises an exception.
0343:             * @see org.xml.sax.ContentHandler#startElement
0344:             * @see #characters(String)
0345:             * @see org.xml.sax.ContentHandler#endElement
0346:             */
0347:            public void dataElement(String localName, Attributes atts,
0348:                    String content) throws SAXException {
0349:                dataElement("", localName, "", atts, content);
0350:            }
0351:
0352:            /**
0353:             * Add an element with character data content but no attributes
0354:             * or Namespace URI.
0355:             *
0356:             * <p>This is a convenience method to add a complete element
0357:             * with character data content, including the start tag
0358:             * and end tag.  The method provides an empty string for the
0359:             * Namespace URI, and empty string for the qualified name,
0360:             * and an empty attribute list. It invokes
0361:             * {@link #dataElement(String, String, String, Attributes, String)}}
0362:             * directly.</p>
0363:             *
0364:             * @param localName The element's local name.
0365:             * @param content The character data content.
0366:             * @exception org.xml.sax.SAXException If a filter
0367:             *            further down the chain raises an exception.
0368:             * @see org.xml.sax.ContentHandler#startElement
0369:             * @see #characters(String)
0370:             * @see org.xml.sax.ContentHandler#endElement
0371:             */
0372:            public void dataElement(String localName, String content)
0373:                    throws SAXException {
0374:                dataElement("", localName, "", EMPTY_ATTS, content);
0375:            }
0376:
0377:            /**
0378:             * Add a string of character data, with XML escaping.
0379:             *
0380:             * <p>This is a convenience method that takes an XML
0381:             * String, converts it to a character array, then invokes
0382:             * {@link @see org.xml.sax.ContentHandler#characters}.</p>
0383:             *
0384:             * @param data The character data.
0385:             * @exception org.xml.sax.SAXException If a filter
0386:             *            further down the chain raises an exception.
0387:             * @see @see org.xml.sax.ContentHandler#characters
0388:             */
0389:            public void characters(String data) throws SAXException {
0390:                char ch[] = data.toCharArray();
0391:                characters(ch, 0, ch.length);
0392:            }
0393:
0394:            ////////////////////////////////////////////////////////////////////
0395:            // Implementation of org.xml.sax.XMLReader.
0396:            ////////////////////////////////////////////////////////////////////
0397:
0398:            /**
0399:             * Set the state of a feature.
0400:             *
0401:             * <p>This will always fail.</p>
0402:             *
0403:             * @param name The feature name.
0404:             * @param state The requested feature state.
0405:             * @exception org.xml.sax.SAXNotRecognizedException When the
0406:             *            XMLReader does not recognize the feature name.
0407:             * @exception org.xml.sax.SAXNotSupportedException When the
0408:             *            XMLReader recognizes the feature name but
0409:             *            cannot set the requested value.
0410:             * @see org.xml.sax.XMLReader#setFeature
0411:             */
0412:            public void setFeature(String name, boolean state)
0413:                    throws SAXNotRecognizedException, SAXNotSupportedException {
0414:                throw new SAXNotRecognizedException("Feature: " + name);
0415:            }
0416:
0417:            /**
0418:             * Look up the state of a feature.
0419:             *
0420:             * <p>This will always fail.</p>
0421:             *
0422:             * @param name The feature name.
0423:             * @return The current state of the feature.
0424:             * @exception org.xml.sax.SAXNotRecognizedException When the
0425:             *            XMLReader does not recognize the feature name.
0426:             * @exception org.xml.sax.SAXNotSupportedException When the
0427:             *            XMLReader recognizes the feature name but
0428:             *            cannot determine its state at this time.
0429:             * @see org.xml.sax.XMLReader#getFeature
0430:             */
0431:            public boolean getFeature(String name)
0432:                    throws SAXNotRecognizedException, SAXNotSupportedException {
0433:                throw new SAXNotRecognizedException("Feature: " + name);
0434:            }
0435:
0436:            /**
0437:             * Set the value of a property.
0438:             *
0439:             * <p>Only lexical-handler properties are recognized.</p>
0440:             *
0441:             * @param name The property name.
0442:             * @param state The requested property value.
0443:             * @exception org.xml.sax.SAXNotRecognizedException When the
0444:             *            XMLReader does not recognize the property name.
0445:             * @exception org.xml.sax.SAXNotSupportedException When the
0446:             *            XMLReader recognizes the property name but
0447:             *            cannot set the requested value.
0448:             * @see org.xml.sax.XMLReader#setProperty
0449:             */
0450:            public void setProperty(String name, Object value)
0451:                    throws SAXNotRecognizedException, SAXNotSupportedException {
0452:                for (int i = 0; i < LEXICAL_HANDLER_NAMES.length; i++) {
0453:                    if (LEXICAL_HANDLER_NAMES[i].equals(name)) {
0454:                        setLexicalHandler((LexicalHandler) value);
0455:                        return;
0456:                    }
0457:                }
0458:                throw new SAXNotRecognizedException("Property: " + name);
0459:            }
0460:
0461:            /**
0462:             * Look up the value of a property.
0463:             *
0464:             * <p>Only lexical-handler properties are recognized.</p>
0465:             *
0466:             * @param name The property name.
0467:             * @return The current value of the property.
0468:             * @exception org.xml.sax.SAXNotRecognizedException When the
0469:             *            XMLReader does not recognize the feature name.
0470:             * @exception org.xml.sax.SAXNotSupportedException When the
0471:             *            XMLReader recognizes the property name but
0472:             *            cannot determine its value at this time.
0473:             * @see org.xml.sax.XMLReader#setFeature
0474:             */
0475:            public Object getProperty(String name)
0476:                    throws SAXNotRecognizedException, SAXNotSupportedException {
0477:                for (int i = 0; i < LEXICAL_HANDLER_NAMES.length; i++) {
0478:                    if (LEXICAL_HANDLER_NAMES[i].equals(name)) {
0479:                        return getLexicalHandler();
0480:                    }
0481:                }
0482:                throw new SAXNotRecognizedException("Property: " + name);
0483:            }
0484:
0485:            /**
0486:             * Parse a document. Subclass must implement.
0487:             *
0488:             * @param input The input source for the document entity.
0489:             * @exception org.xml.sax.SAXException Any SAX exception, possibly
0490:             *            wrapping another exception.
0491:             * @exception java.io.IOException An IO exception from the parser,
0492:             *            possibly from a byte stream or character stream
0493:             *            supplied by the application.
0494:             * @see org.xml.sax.XMLReader#parse(org.xml.sax.InputSource)
0495:             */
0496:            public abstract void parse(InputSource input) throws SAXException,
0497:                    IOException;
0498:
0499:            /**
0500:             * Parse a document.
0501:             *
0502:             * @param systemId The system identifier as a fully-qualified URI.
0503:             * @exception org.xml.sax.SAXException Any SAX exception, possibly
0504:             *            wrapping another exception.
0505:             * @exception java.io.IOException An IO exception from the parser,
0506:             *            possibly from a byte stream or character stream
0507:             *            supplied by the application.
0508:             * @see org.xml.sax.XMLReader#parse(java.lang.String)
0509:             */
0510:            public void parse(String systemId) throws SAXException, IOException {
0511:                parse(new InputSource(systemId));
0512:            }
0513:
0514:            /**
0515:             * Set the entity resolver.
0516:             *
0517:             * @param resolver The new entity resolver.
0518:             * @exception java.lang.NullPointerException If the resolver
0519:             *            is null.
0520:             * @see org.xml.sax.XMLReader#setEntityResolver
0521:             */
0522:            public void setEntityResolver(EntityResolver resolver) {
0523:                if (resolver == null) {
0524:                    throw new NullPointerException("Null entity resolver");
0525:                } else {
0526:                    entityResolver = resolver;
0527:                }
0528:            }
0529:
0530:            /**
0531:             * Get the current entity resolver.
0532:             *
0533:             * @return The current entity resolver, or null if none was set.
0534:             * @see org.xml.sax.XMLReader#getEntityResolver
0535:             */
0536:            public EntityResolver getEntityResolver() {
0537:                return entityResolver;
0538:            }
0539:
0540:            /**
0541:             * Set the DTD event handler.
0542:             *
0543:             * @param resolver The new DTD handler.
0544:             * @exception java.lang.NullPointerException If the handler
0545:             *            is null.
0546:             * @see org.xml.sax.XMLReader#setDTDHandler
0547:             */
0548:            public void setDTDHandler(DTDHandler handler) {
0549:                if (handler == null) {
0550:                    throw new NullPointerException("Null DTD handler");
0551:                } else {
0552:                    dtdHandler = handler;
0553:                }
0554:            }
0555:
0556:            /**
0557:             * Get the current DTD event handler.
0558:             *
0559:             * @return The current DTD handler, or null if none was set.
0560:             * @see org.xml.sax.XMLReader#getDTDHandler
0561:             */
0562:            public DTDHandler getDTDHandler() {
0563:                return dtdHandler;
0564:            }
0565:
0566:            /**
0567:             * Set the content event handler.
0568:             *
0569:             * @param resolver The new content handler.
0570:             * @exception java.lang.NullPointerException If the handler
0571:             *            is null.
0572:             * @see org.xml.sax.XMLReader#setContentHandler
0573:             */
0574:            public void setContentHandler(ContentHandler handler) {
0575:                if (handler == null) {
0576:                    throw new NullPointerException("Null content handler");
0577:                } else {
0578:                    contentHandler = handler;
0579:                }
0580:            }
0581:
0582:            /**
0583:             * Get the content event handler.
0584:             *
0585:             * @return The current content handler, or null if none was set.
0586:             * @see org.xml.sax.XMLReader#getContentHandler
0587:             */
0588:            public ContentHandler getContentHandler() {
0589:                return contentHandler;
0590:            }
0591:
0592:            /**
0593:             * Set the error event handler.
0594:             *
0595:             * @param handle The new error handler.
0596:             * @exception java.lang.NullPointerException If the handler
0597:             *            is null.
0598:             * @see org.xml.sax.XMLReader#setErrorHandler
0599:             */
0600:            public void setErrorHandler(ErrorHandler handler) {
0601:                if (handler == null) {
0602:                    throw new NullPointerException("Null error handler");
0603:                } else {
0604:                    errorHandler = handler;
0605:                }
0606:            }
0607:
0608:            /**
0609:             * Get the current error event handler.
0610:             *
0611:             * @return The current error handler, or null if none was set.
0612:             * @see org.xml.sax.XMLReader#getErrorHandler
0613:             */
0614:            public ErrorHandler getErrorHandler() {
0615:                return errorHandler;
0616:            }
0617:
0618:            ////////////////////////////////////////////////////////////////////
0619:            // Registration of org.xml.sax.ext.LexicalHandler.
0620:            ////////////////////////////////////////////////////////////////////
0621:
0622:            /**
0623:             * Set the lexical handler.
0624:             *
0625:             * @param handler The new lexical handler.
0626:             * @exception java.lang.NullPointerException If the handler
0627:             *            is null.
0628:             */
0629:            public void setLexicalHandler(LexicalHandler handler) {
0630:                if (handler == null) {
0631:                    throw new NullPointerException("Null lexical handler");
0632:                } else {
0633:                    lexicalHandler = handler;
0634:                }
0635:            }
0636:
0637:            /**
0638:             * Get the current lexical handler.
0639:             *
0640:             * @return The current lexical handler, or null if none was set.
0641:             */
0642:            public LexicalHandler getLexicalHandler() {
0643:                return lexicalHandler;
0644:            }
0645:
0646:            ////////////////////////////////////////////////////////////////////
0647:            // Implementation of org.xml.sax.EntityResolver.
0648:            ////////////////////////////////////////////////////////////////////
0649:
0650:            /**
0651:             * Resolves an external entity.
0652:             *
0653:             * @param publicId The entity's public identifier, or null.
0654:             * @param systemId The entity's system identifier.
0655:             * @return A new InputSource or null for the default.
0656:             * @exception org.xml.sax.SAXException The client may throw
0657:             *            an exception during processing.
0658:             * @exception java.io.IOException The client may throw an
0659:             *            I/O-related exception while obtaining the
0660:             *            new InputSource.
0661:             * @see org.xml.sax.EntityResolver#resolveEntity
0662:             */
0663:            public InputSource resolveEntity(String publicId, String systemId)
0664:                    throws SAXException /* IOException added in SAX2.01 bugfix release */
0665:            {
0666:                if (entityResolver != null) {
0667:                    try {
0668:                        return entityResolver.resolveEntity(publicId, systemId);
0669:                    } catch (IOException ex) {
0670:                        throw new SAXException(ex);
0671:                    }
0672:                } else {
0673:                    return null;
0674:                }
0675:            }
0676:
0677:            ////////////////////////////////////////////////////////////////////
0678:            // Implementation of org.xml.sax.DTDHandler.
0679:            ////////////////////////////////////////////////////////////////////
0680:
0681:            /**
0682:             * Add notation declaration.
0683:             *
0684:             * @param name The notation name.
0685:             * @param publicId The notation's public identifier, or null.
0686:             * @param systemId The notation's system identifier, or null.
0687:             * @exception org.xml.sax.SAXException The client may throw
0688:             *            an exception during processing.
0689:             * @see org.xml.sax.DTDHandler#notationDecl
0690:             */
0691:            public void notationDecl(String name, String publicId,
0692:                    String systemId) throws SAXException {
0693:                if (dtdHandler != null) {
0694:                    dtdHandler.notationDecl(name, publicId, systemId);
0695:                }
0696:            }
0697:
0698:            /**
0699:             * Add unparsed entity declaration.
0700:             *
0701:             * @param name The entity name.
0702:             * @param publicId The entity's public identifier, or null.
0703:             * @param systemId The entity's system identifier, or null.
0704:             * @param notationName The name of the associated notation.
0705:             * @exception org.xml.sax.SAXException The client may throw
0706:             *            an exception during processing.
0707:             * @see org.xml.sax.DTDHandler#unparsedEntityDecl
0708:             */
0709:            public void unparsedEntityDecl(String name, String publicId,
0710:                    String systemId, String notationName) throws SAXException {
0711:                if (dtdHandler != null) {
0712:                    dtdHandler.unparsedEntityDecl(name, publicId, systemId,
0713:                            notationName);
0714:                }
0715:            }
0716:
0717:            ////////////////////////////////////////////////////////////////////
0718:            // Implementation of org.xml.sax.ContentHandler.
0719:            ////////////////////////////////////////////////////////////////////
0720:
0721:            /**
0722:             * Assigns the document locator.
0723:             *
0724:             * @param locator The document locator.
0725:             * @see org.xml.sax.ContentHandler#setDocumentLocator
0726:             */
0727:            public void setDocumentLocator(Locator locator) {
0728:                this .locator = locator;
0729:                if (contentHandler != null) {
0730:                    contentHandler.setDocumentLocator(locator);
0731:                }
0732:            }
0733:
0734:            /**
0735:             * Send start of document.
0736:             *
0737:             * @exception org.xml.sax.SAXException The client may throw
0738:             *            an exception during processing.
0739:             * @see org.xml.sax.ContentHandler#startDocument
0740:             */
0741:            public void startDocument() throws SAXException {
0742:                if (contentHandler != null) {
0743:                    contentHandler.startDocument();
0744:                }
0745:            }
0746:
0747:            /**
0748:             * Send end of document.
0749:             *
0750:             * @exception org.xml.sax.SAXException The client may throw
0751:             *            an exception during processing.
0752:             * @see org.xml.sax.ContentHandler#endDocument
0753:             */
0754:            public void endDocument() throws SAXException {
0755:                if (contentHandler != null) {
0756:                    contentHandler.endDocument();
0757:                }
0758:            }
0759:
0760:            /**
0761:             * Sends start of namespace prefix mapping.
0762:             *
0763:             * @param prefix The Namespace prefix.
0764:             * @param uri The Namespace URI.
0765:             * @exception org.xml.sax.SAXException The client may throw
0766:             *            an exception during processing.
0767:             * @see org.xml.sax.ContentHandler#startPrefixMapping
0768:             */
0769:            public void startPrefixMapping(String prefix, String uri)
0770:                    throws SAXException {
0771:                if (contentHandler != null) {
0772:                    contentHandler.startPrefixMapping(prefix, uri);
0773:                }
0774:            }
0775:
0776:            /**
0777:             * Sends end of namespace prefix mapping.
0778:             *
0779:             * @param prefix The Namespace prefix.
0780:             * @exception org.xml.sax.SAXException The client may throw
0781:             *            an exception during processing.
0782:             * @see org.xml.sax.ContentHandler#endPrefixMapping
0783:             */
0784:            public void endPrefixMapping(String prefix) throws SAXException {
0785:                if (contentHandler != null) {
0786:                    contentHandler.endPrefixMapping(prefix);
0787:                }
0788:            }
0789:
0790:            /**
0791:             * Sends start of element.
0792:             *
0793:             * @param uri The element's Namespace URI, or the empty string.
0794:             * @param localName The element's local name, or the empty string.
0795:             * @param qName The element's qualified (prefixed) name, or the empty
0796:             *        string.
0797:             * @param atts The element's attributes.
0798:             * @exception org.xml.sax.SAXException The client may throw
0799:             *            an exception during processing.
0800:             * @see org.xml.sax.ContentHandler#startElement
0801:             */
0802:            public void startElement(String uri, String localName,
0803:                    String qName, Attributes atts) throws SAXException {
0804:                if (contentHandler != null) {
0805:                    contentHandler.startElement(uri, localName, qName, atts);
0806:                }
0807:            }
0808:
0809:            /**
0810:             * Sends end of element.
0811:             *
0812:             * @param uri The element's Namespace URI, or the empty string.
0813:             * @param localName The element's local name, or the empty string.
0814:             * @param qName The element's qualified (prefixed) name, or the empty
0815:             *        string.
0816:             * @exception org.xml.sax.SAXException The client may throw
0817:             *            an exception during processing.
0818:             * @see org.xml.sax.ContentHandler#endElement
0819:             */
0820:            public void endElement(String uri, String localName, String qName)
0821:                    throws SAXException {
0822:                if (contentHandler != null) {
0823:                    contentHandler.endElement(uri, localName, qName);
0824:                }
0825:            }
0826:
0827:            /**
0828:             * Sends character data.
0829:             *
0830:             * @param ch An array of characters.
0831:             * @param start The starting position in the array.
0832:             * @param length The number of characters to use from the array.
0833:             * @exception org.xml.sax.SAXException The client may throw
0834:             *            an exception during processing.
0835:             * @see org.xml.sax.ContentHandler#characters
0836:             */
0837:            public void characters(char ch[], int start, int length)
0838:                    throws SAXException {
0839:                if (contentHandler != null) {
0840:                    contentHandler.characters(ch, start, length);
0841:                }
0842:            }
0843:
0844:            /**
0845:             * Sends ignorable whitespace.
0846:             *
0847:             * @param ch An array of characters.
0848:             * @param start The starting position in the array.
0849:             * @param length The number of characters to use from the array.
0850:             * @exception org.xml.sax.SAXException The client may throw
0851:             *            an exception during processing.
0852:             * @see org.xml.sax.ContentHandler#ignorableWhitespace
0853:             */
0854:            public void ignorableWhitespace(char ch[], int start, int length)
0855:                    throws SAXException {
0856:                if (contentHandler != null) {
0857:                    contentHandler.ignorableWhitespace(ch, start, length);
0858:                }
0859:            }
0860:
0861:            /**
0862:             * Sends processing instruction.
0863:             *
0864:             * @param target The processing instruction target.
0865:             * @param data The text following the target.
0866:             * @exception org.xml.sax.SAXException The client may throw
0867:             *            an exception during processing.
0868:             * @see org.xml.sax.ContentHandler#processingInstruction
0869:             */
0870:            public void processingInstruction(String target, String data)
0871:                    throws SAXException {
0872:                if (contentHandler != null) {
0873:                    contentHandler.processingInstruction(target, data);
0874:                }
0875:            }
0876:
0877:            /**
0878:             * Sends skipped entity.
0879:             *
0880:             * @param name The name of the skipped entity.
0881:             * @exception org.xml.sax.SAXException The client may throw
0882:             *            an exception during processing.
0883:             * @see org.xml.sax.ContentHandler#skippedEntity
0884:             */
0885:            public void skippedEntity(String name) throws SAXException {
0886:                if (contentHandler != null) {
0887:                    contentHandler.skippedEntity(name);
0888:                }
0889:            }
0890:
0891:            ////////////////////////////////////////////////////////////////////
0892:            // Implementation of org.xml.sax.ErrorHandler.
0893:            ////////////////////////////////////////////////////////////////////
0894:
0895:            /**
0896:             * Sends warning.
0897:             *
0898:             * @param e The nwarning as an exception.
0899:             * @exception org.xml.sax.SAXException The client may throw
0900:             *            an exception during processing.
0901:             * @see org.xml.sax.ErrorHandler#warning
0902:             */
0903:            public void warning(SAXParseException e) throws SAXException {
0904:                if (errorHandler != null) {
0905:                    errorHandler.warning(e);
0906:                }
0907:            }
0908:
0909:            /**
0910:             * Sends error.
0911:             *
0912:             * @param e The error as an exception.
0913:             * @exception org.xml.sax.SAXException The client may throw
0914:             *            an exception during processing.
0915:             * @see org.xml.sax.ErrorHandler#error
0916:             */
0917:            public void error(SAXParseException e) throws SAXException {
0918:                if (errorHandler != null) {
0919:                    errorHandler.error(e);
0920:                }
0921:            }
0922:
0923:            /**
0924:             * Sends fatal error.
0925:             *
0926:             * @param e The error as an exception.
0927:             * @exception org.xml.sax.SAXException The client may throw
0928:             *            an exception during processing.
0929:             * @see org.xml.sax.ErrorHandler#fatalError
0930:             */
0931:            public void fatalError(SAXParseException e) throws SAXException {
0932:                if (errorHandler != null) {
0933:                    errorHandler.fatalError(e);
0934:                }
0935:            }
0936:
0937:            ////////////////////////////////////////////////////////////////////
0938:            // Implementation of org.xml.sax.ext.LexicalHandler.
0939:            ////////////////////////////////////////////////////////////////////
0940:
0941:            /**
0942:             * Sends start of DTD.
0943:             *
0944:             * @param name The document type name.
0945:             * @param publicId The declared public identifier for the
0946:             *        external DTD subset, or null if none was declared.
0947:             * @param systemId The declared system identifier for the
0948:             *        external DTD subset, or null if none was declared.
0949:             * @exception org.xml.sax.SAXException If a filter
0950:             *            further down the chain raises an exception.
0951:             * @see org.xml.sax.ext.LexicalHandler#startDTD
0952:             */
0953:            public void startDTD(String name, String publicId, String systemId)
0954:                    throws SAXException {
0955:                if (lexicalHandler != null) {
0956:                    lexicalHandler.startDTD(name, publicId, systemId);
0957:                }
0958:            }
0959:
0960:            /**
0961:             * Sends end of DTD.
0962:             *
0963:             * @exception org.xml.sax.SAXException If a filter
0964:             *            further down the chain raises an exception.
0965:             * @see org.xml.sax.ext.LexicalHandler#endDTD
0966:             */
0967:            public void endDTD() throws SAXException {
0968:                if (lexicalHandler != null) {
0969:                    lexicalHandler.endDTD();
0970:                }
0971:            }
0972:
0973:            /*
0974:             * Sends start of entity.
0975:             *
0976:             * @param name The name of the entity.  If it is a parameter
0977:             *        entity, the name will begin with '%', and if it is the
0978:             *        external DTD subset, it will be "[dtd]".
0979:             * @exception org.xml.sax.SAXException If a filter
0980:             *            further down the chain raises an exception.
0981:             * @see org.xml.sax.ext.LexicalHandler#startEntity
0982:             */
0983:            public void startEntity(String name) throws SAXException {
0984:                if (lexicalHandler != null) {
0985:                    lexicalHandler.startEntity(name);
0986:                }
0987:            }
0988:
0989:            /*
0990:             * Sends end of entity.
0991:             *
0992:             * @param name The name of the entity that is ending.
0993:             * @exception org.xml.sax.SAXException If a filter
0994:             *            further down the chain raises an exception.
0995:             * @see org.xml.sax.ext.LexicalHandler#endEntity
0996:             */
0997:            public void endEntity(String name) throws SAXException {
0998:                if (lexicalHandler != null) {
0999:                    lexicalHandler.endEntity(name);
1000:                }
1001:            }
1002:
1003:            /*
1004:             * Sends start of CDATA.
1005:             *
1006:             * @exception org.xml.sax.SAXException If a filter
1007:             *            further down the chain raises an exception.
1008:             * @see org.xml.sax.ext.LexicalHandler#startCDATA
1009:             */
1010:            public void startCDATA() throws SAXException {
1011:                if (lexicalHandler != null) {
1012:                    lexicalHandler.startCDATA();
1013:                }
1014:            }
1015:
1016:            /*
1017:             * Sends end of CDATA.
1018:             *
1019:             * @exception org.xml.sax.SAXException If a filter
1020:             *            further down the chain raises an exception.
1021:             * @see org.xml.sax.ext.LexicalHandler#endCDATA
1022:             */
1023:            public void endCDATA() throws SAXException {
1024:                if (lexicalHandler != null) {
1025:                    lexicalHandler.endCDATA();
1026:                }
1027:            }
1028:
1029:            /*
1030:             * Sends comment.
1031:             *
1032:             * @param ch An array holding the characters in the comment.
1033:             * @param start The starting position in the array.
1034:             * @param length The number of characters to use from the array.
1035:             * @exception org.xml.sax.SAXException If a filter
1036:             *            further down the chain raises an exception.
1037:             * @see org.xml.sax.ext.LexicalHandler#comment
1038:             */
1039:            public void comment(char[] ch, int start, int length)
1040:                    throws SAXException {
1041:                if (lexicalHandler != null) {
1042:                    lexicalHandler.comment(ch, start, length);
1043:                }
1044:            }
1045:
1046:            ////////////////////////////////////////////////////////////////////
1047:            // Internal state.
1048:            ////////////////////////////////////////////////////////////////////
1049:
1050:            private Locator locator = null;
1051:            private EntityResolver entityResolver = null;
1052:            private DTDHandler dtdHandler = null;
1053:            private ContentHandler contentHandler = null;
1054:            private ErrorHandler errorHandler = null;
1055:            private LexicalHandler lexicalHandler = null;
1056:
1057:            ////////////////////////////////////////////////////////////////////
1058:            // Constants.
1059:            ////////////////////////////////////////////////////////////////////
1060:
1061:            protected static final Attributes EMPTY_ATTS = new AttributesImpl();
1062:
1063:            protected static final String[] LEXICAL_HANDLER_NAMES = {
1064:                    "http://xml.org/sax/properties/lexical-handler",
1065:                    "http://xml.org/sax/handlers/LexicalHandler" };
1066:
1067:        }
1068:
1069:        // end of XMLReaderBase.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.