1 22 23 package org.xquark.util; 24 25 import org.xml.sax.*; 26 import org.xml.sax.ext.LexicalHandler ; 27 28 32 public class DecoratorFilter extends DefaultXMLFilter { 33 private static final String RCSRevision = "$Revision: 1.4 $"; 34 private static final String RCSName = "$Name: $"; 35 36 protected HandlerDecorator decorator; 37 38 public DecoratorFilter(XMLReader reader, HandlerDecorator decorator) { 39 super(reader); 40 setHandlerDecorator(decorator); 41 } 42 43 public DecoratorFilter(HandlerDecorator decorator) { 44 setHandlerDecorator(decorator); 45 } 46 47 private void setHandlerDecorator(HandlerDecorator decorator) { 48 this.decorator = decorator; 49 super.setContentHandler(decorator); 50 } 51 52 public void setContentHandler(ContentHandler handler) { 53 decorator.setContentHandler(handler); 54 } 55 56 public ContentHandler getContentHandler() { 57 return decorator.getContentHandler(); 58 } 59 60 public void setLexicalHandler(LexicalHandler handler) { 61 decorator.setLexicalHandler(handler); 62 } 63 64 public LexicalHandler getLexicalHandler() { 65 return decorator.getLexicalHandler(); 66 } 67 68 public void setErrorHandler(ErrorHandler handler) { 69 decorator.setErrorHandler(handler); 70 } 71 72 public ErrorHandler getErrorHandler() { 73 return decorator.getPluggedErrorHandler(); 74 } 75 76 public void parse(InputSource source) throws SAXException, java.io.IOException { 77 setupFilter(); 78 super.parse(source); 79 } 80 81 private void setupFilter() { 82 super.setContentHandler(decorator); 83 super.setLexicalHandler(decorator); 84 super.setErrorHandler(decorator); 85 } 86 87 } 88 | Popular Tags |