001 package fi.iki.hsivonen.xml; 002 003 import org.xml.sax.Attributes; 004 import org.xml.sax.ContentHandler; 005 import org.xml.sax.ErrorHandler; 006 import org.xml.sax.Locator; 007 import org.xml.sax.SAXException; 008 import org.xml.sax.SAXParseException; 009 010 /** 011 * @version $Id: ContentHandlerFilter.java,v 1.1 2005/08/13 12:18:42 hsivonen Exp $ 012 * @author hsivonen 013 */ 014 public class ContentHandlerFilter implements ContentHandler { 015 016 protected ContentHandler contentHandler; 017 018 protected ErrorHandler errorHandler; 019 020 protected Locator locator; 021 022 /** 023 * @param chars 024 * @param start 025 * @param length 026 * @throws org.xml.sax.SAXException 027 */ 028 public void characters(char[] chars, int start, int length) throws SAXException { 029 contentHandler.characters(chars, start, length); 030 } 031 /** 032 * @throws org.xml.sax.SAXException 033 */ 034 public void endDocument() throws SAXException { 035 contentHandler.endDocument(); 036 } 037 /** 038 * @param uri 039 * @param local 040 * @param qName 041 * @throws org.xml.sax.SAXException 042 */ 043 public void endElement(String uri, String local, String qName) 044 throws SAXException { 045 contentHandler.endElement(uri, local, qName); 046 } 047 /** 048 * @param arg0 049 * @throws org.xml.sax.SAXException 050 */ 051 public void endPrefixMapping(String arg0) throws SAXException { 052 contentHandler.endPrefixMapping(arg0); 053 } 054 /** 055 * @param arg0 056 * @param arg1 057 * @param arg2 058 * @throws org.xml.sax.SAXException 059 */ 060 public void ignorableWhitespace(char[] arg0, int arg1, int arg2) 061 throws SAXException { 062 contentHandler.ignorableWhitespace(arg0, arg1, arg2); 063 } 064 /** 065 * @param arg0 066 * @param arg1 067 * @throws org.xml.sax.SAXException 068 */ 069 public void processingInstruction(String arg0, String arg1) 070 throws SAXException { 071 contentHandler.processingInstruction(arg0, arg1); 072 } 073 /** 074 * @param locator 075 */ 076 public void setDocumentLocator(Locator locator) { 077 this.locator = locator; 078 contentHandler.setDocumentLocator(locator); 079 } 080 /** 081 * @param arg0 082 * @throws org.xml.sax.SAXException 083 */ 084 public void skippedEntity(String arg0) throws SAXException { 085 contentHandler.skippedEntity(arg0); 086 } 087 /** 088 * @throws org.xml.sax.SAXException 089 */ 090 public void startDocument() throws SAXException { 091 contentHandler.startDocument(); 092 } 093 /** 094 * @param uri 095 * @param local 096 * @param qName 097 * @param attrs 098 * @throws org.xml.sax.SAXException 099 */ 100 public void startElement(String uri, String local, String qName, 101 Attributes attrs) throws SAXException { 102 contentHandler.startElement(uri, local, qName, attrs); 103 } 104 /** 105 * @param arg0 106 * @param arg1 107 * @throws org.xml.sax.SAXException 108 */ 109 public void startPrefixMapping(String arg0, String arg1) 110 throws SAXException { 111 contentHandler.startPrefixMapping(arg0, arg1); 112 } 113 protected void fatal(String message) throws SAXException { 114 SAXParseException spe = new SAXParseException(message, locator); 115 errorHandler.fatalError(spe); 116 throw spe; 117 } 118 protected void err(String message) throws SAXException { 119 SAXParseException spe = new SAXParseException(message, locator); 120 errorHandler.error(spe); 121 } 122 /** 123 * Returns the contentHandler. 124 * 125 * @return the contentHandler 126 */ 127 public ContentHandler getContentHandler() { 128 return contentHandler; 129 } 130 /** 131 * Sets the contentHandler. 132 * 133 * @param contentHandler the contentHandler to set 134 */ 135 public void setContentHandler(ContentHandler contentHandler) { 136 this.contentHandler = contentHandler; 137 } 138 /** 139 * Returns the errorHandler. 140 * 141 * @return the errorHandler 142 */ 143 public ErrorHandler getErrorHandler() { 144 return errorHandler; 145 } 146 /** 147 * Sets the errorHandler. 148 * 149 * @param errorHandler the errorHandler to set 150 */ 151 public void setErrorHandler(ErrorHandler errorHandler) { 152 this.errorHandler = errorHandler; 153 } 154 }