01: package javanet.staxutils.helpers;
02:
03: import org.xml.sax.SAXException;
04: import org.xml.sax.ext.LexicalHandler;
05: import org.xml.sax.helpers.XMLFilterImpl;
06:
07: /**
08: * Extension to XMLFilterImpl that implements LexicalHandler.
09: *
10: * @author Paul.Sandoz@Sun.Com
11: */
12: public class XMLFilterImplEx extends XMLFilterImpl implements
13: LexicalHandler {
14:
15: protected LexicalHandler lexicalHandler;
16:
17: protected boolean namespacePrefixes;
18:
19: public void setNamespacePrefixes(boolean v) {
20: namespacePrefixes = v;
21: }
22:
23: public boolean getNamespacePrefixes() {
24: return namespacePrefixes;
25: }
26:
27: /**
28: * Set the lexical event handler.
29: *
30: * @param handler the new lexical handler
31: */
32: public void setLexicalHandler(LexicalHandler handler) {
33: lexicalHandler = handler;
34: }
35:
36: /**
37: * Get the lexical event handler.
38: *
39: * @return The current lexical handler, or null if none was set.
40: */
41: public LexicalHandler getLexicalHandler() {
42: return lexicalHandler;
43: }
44:
45: ////////////////////////////////////////////////////////////////////
46: // Implementation of org.xml.sax.ext.LexicalHandler.
47: ////////////////////////////////////////////////////////////////////
48:
49: public void startDTD(String name, String publicId, String systemId)
50: throws SAXException {
51: if (lexicalHandler != null) {
52: lexicalHandler.startDTD(name, publicId, systemId);
53: }
54: }
55:
56: public void endDTD() throws SAXException {
57: if (lexicalHandler != null) {
58: lexicalHandler.endDTD();
59: }
60: }
61:
62: public void startEntity(String name) throws SAXException {
63: if (lexicalHandler != null) {
64: lexicalHandler.startEntity(name);
65: }
66: }
67:
68: public void endEntity(String name) throws SAXException {
69: if (lexicalHandler != null) {
70: lexicalHandler.endEntity(name);
71: }
72: }
73:
74: public void startCDATA() throws SAXException {
75: if (lexicalHandler != null) {
76: lexicalHandler.startCDATA();
77: }
78: }
79:
80: public void endCDATA() throws SAXException {
81: if (lexicalHandler != null) {
82: lexicalHandler.endCDATA();
83: }
84: }
85:
86: public void comment(char ch[], int start, int length)
87: throws SAXException {
88: if (lexicalHandler != null) {
89: lexicalHandler.comment(ch, start, length);
90: }
91: }
92: }
|