1. // DefaultHandler2.java - extended DefaultHandler
  2. // http://www.saxproject.org
  3. // Public Domain: no warranty.
  4. // $Id: DefaultHandler2.java,v 1.1.2.1 2004/05/01 08:34:43 jsuttor Exp $
  5. package org.xml.sax.ext;
  6. import java.io.IOException;
  7. import org.xml.sax.InputSource;
  8. import org.xml.sax.SAXException;
  9. import org.xml.sax.helpers.DefaultHandler;
  10. /**
  11. * This class extends the SAX2 base handler class to support the
  12. * SAX2 {@link LexicalHandler}, {@link DeclHandler}, and
  13. * {@link EntityResolver2} extensions. Except for overriding the
  14. * original SAX1 {@link DefaultHandler#resolveEntity resolveEntity()}
  15. * method the added handler methods just return. Subclassers may
  16. * override everything on a method-by-method basis.
  17. *
  18. * <blockquote>
  19. * <em>This module, both source code and documentation, is in the
  20. * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
  21. * </blockquote>
  22. *
  23. * <p> <em>Note:</em> this class might yet learn that the
  24. * <em>ContentHandler.setDocumentLocator()</em> call might be passed a
  25. * {@link Locator2} object, and that the
  26. * <em>ContentHandler.startElement()</em> call might be passed a
  27. * {@link Attributes2} object.
  28. *
  29. * @since SAX 2.0 (extensions 1.1 alpha)
  30. * @author David Brownell
  31. * @version TBS
  32. */
  33. public class DefaultHandler2 extends DefaultHandler
  34. implements LexicalHandler, DeclHandler, EntityResolver2
  35. {
  36. /** Constructs a handler which ignores all parsing events. */
  37. public DefaultHandler2 () { }
  38. // SAX2 ext-1.0 LexicalHandler
  39. public void startCDATA ()
  40. throws SAXException
  41. {}
  42. public void endCDATA ()
  43. throws SAXException
  44. {}
  45. public void startDTD (String name, String publicId, String systemId)
  46. throws SAXException
  47. {}
  48. public void endDTD ()
  49. throws SAXException
  50. {}
  51. public void startEntity (String name)
  52. throws SAXException
  53. {}
  54. public void endEntity (String name)
  55. throws SAXException
  56. {}
  57. public void comment (char ch [], int start, int length)
  58. throws SAXException
  59. { }
  60. // SAX2 ext-1.0 DeclHandler
  61. public void attributeDecl (String eName, String aName,
  62. String type, String mode, String value)
  63. throws SAXException
  64. {}
  65. public void elementDecl (String name, String model)
  66. throws SAXException
  67. {}
  68. public void externalEntityDecl (String name,
  69. String publicId, String systemId)
  70. throws SAXException
  71. {}
  72. public void internalEntityDecl (String name, String value)
  73. throws SAXException
  74. {}
  75. // SAX2 ext-1.1 EntityResolver2
  76. /**
  77. * Tells the parser that if no external subset has been declared
  78. * in the document text, none should be used.
  79. */
  80. public InputSource getExternalSubset (String name, String baseURI)
  81. throws SAXException, IOException
  82. { return null; }
  83. /**
  84. * Tells the parser to resolve the systemId against the baseURI
  85. * and read the entity text from that resulting absolute URI.
  86. * Note that because the older
  87. * {@link DefaultHandler#resolveEntity DefaultHandler.resolveEntity()},
  88. * method is overridden to call this one, this method may sometimes
  89. * be invoked with null <em>name</em> and <em>baseURI</em>, and
  90. * with the <em>systemId</em> already absolutized.
  91. */
  92. public InputSource resolveEntity (String name, String publicId,
  93. String baseURI, String systemId)
  94. throws SAXException, IOException
  95. { return null; }
  96. // SAX1 EntityResolver
  97. /**
  98. * Invokes
  99. * {@link EntityResolver2#resolveEntity EntityResolver2.resolveEntity()}
  100. * with null entity name and base URI.
  101. * You only need to override that method to use this class.
  102. */
  103. public InputSource resolveEntity (String publicId, String systemId)
  104. throws SAXException, IOException
  105. { return resolveEntity (null, publicId, null, systemId); }
  106. }