1 22 23 package org.xquark.util; 24 25 import org.xml.sax.*; 26 import org.xml.sax.ext.LexicalHandler ; 27 import org.xml.sax.helpers.XMLFilterImpl ; 28 29 32 public class DefaultXMLFilter extends XMLFilterImpl 33 implements LexicalHandler 34 { 35 private static final String RCSRevision = "$Revision: 1.1 $"; 36 private static final String RCSName = "$Name: $"; 37 private LexicalHandler lexicalHandler = null; 38 39 41 public DefaultXMLFilter() { 42 super(); 43 } 44 45 48 public DefaultXMLFilter(XMLReader reader) { 49 super(reader); 50 } 51 52 public void setProperty(String name, Object value) 56 throws SAXNotRecognizedException, SAXNotSupportedException 57 { 58 if (name.equals("http://xml.org/sax/properties/lexical-handler")) 59 setLexicalHandler((LexicalHandler )value); 60 else 61 super.setProperty(name, value); 62 } 63 64 public Object getProperty(String name) 65 throws SAXNotRecognizedException, SAXNotSupportedException 66 { 67 if (name.equals("http://xml.org/sax/properties/lexical-handler")) 68 return getLexicalHandler(); 69 else 70 return super.getProperty(name); 71 } 72 73 public LexicalHandler getLexicalHandler() { 74 return lexicalHandler; 75 } 76 77 public void setLexicalHandler(LexicalHandler handler) { 78 try { 79 if (getParent() != null) 80 getParent().setProperty("http://xml.org/sax/properties/lexical-handler", this); 81 lexicalHandler = handler; 82 } catch (SAXException ex) { 83 } 85 } 86 87 public void startDTD(String name, String publicId, String systemId) 91 throws SAXException 92 { 93 lexicalHandler.startDTD(name, publicId, systemId); 94 } 95 96 public void endDTD() throws SAXException 97 { 98 lexicalHandler.endDTD(); 99 } 100 101 public void startEntity(String name) throws SAXException 102 { 103 lexicalHandler.startEntity(name); 104 } 105 106 public void endEntity(String name) throws SAXException 107 { 108 lexicalHandler.endEntity(name); 109 } 110 111 public void startCDATA() throws SAXException 112 { 113 lexicalHandler.startCDATA(); 114 } 115 116 public void endCDATA() throws SAXException 117 { 118 lexicalHandler.endCDATA(); 119 } 120 121 public void comment(char ch[], int start, int length) throws SAXException 122 { 123 lexicalHandler.comment(ch, start, length); 124 } 125 } 126 127 | Popular Tags |