001: /*
002: * This file is part of PFIXCORE.
003: *
004: * PFIXCORE is free software; you can redistribute it and/or modify
005: * it under the terms of the GNU Lesser General Public License as published by
006: * the Free Software Foundation; either version 2 of the License, or
007: * (at your option) any later version.
008: *
009: * PFIXCORE is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public License
015: * along with PFIXCORE; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018:
019: package de.schlund.pfixxml.util;
020:
021: import javax.xml.transform.sax.TransformerHandler;
022:
023: import org.xml.sax.Attributes;
024: import org.xml.sax.Locator;
025: import org.xml.sax.SAXException;
026: import org.xml.sax.helpers.DefaultHandler;
027:
028: /**
029: * Wraps a {@link org.xml.sax.helpers.DefaultHandler} around a
030: * {@link javax.xml.transform.sax.TransformerHandler}. This adapter can be
031: * used, when a DefaultHandler is required by a method, but you want to use a
032: * TransformerHandler.
033: *
034: * @author Sebastian Marsching <sebastian.marsching@1und1.de>
035: */
036: public class TransformerHandlerAdapter extends DefaultHandler {
037: private TransformerHandler handler;
038:
039: public TransformerHandlerAdapter(TransformerHandler handler) {
040: this .handler = handler;
041: }
042:
043: /*
044: * (non-Javadoc)
045: *
046: * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
047: */
048: public void characters(char[] ch, int start, int length)
049: throws SAXException {
050: this .handler.characters(ch, start, length);
051: }
052:
053: /*
054: * (non-Javadoc)
055: *
056: * @see org.xml.sax.helpers.DefaultHandler#endDocument()
057: */
058: public void endDocument() throws SAXException {
059: this .handler.endDocument();
060: }
061:
062: /*
063: * (non-Javadoc)
064: *
065: * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String,
066: * java.lang.String, java.lang.String)
067: */
068: public void endElement(String uri, String localName, String qName)
069: throws SAXException {
070: this .handler.endElement(uri, localName, qName);
071: }
072:
073: /*
074: * (non-Javadoc)
075: *
076: * @see org.xml.sax.helpers.DefaultHandler#endPrefixMapping(java.lang.String)
077: */
078: public void endPrefixMapping(String prefix) throws SAXException {
079: this .handler.endPrefixMapping(prefix);
080: }
081:
082: /*
083: * (non-Javadoc)
084: *
085: * @see org.xml.sax.helpers.DefaultHandler#ignorableWhitespace(char[], int,
086: * int)
087: */
088: public void ignorableWhitespace(char[] ch, int start, int length)
089: throws SAXException {
090: this .handler.ignorableWhitespace(ch, start, length);
091: }
092:
093: /*
094: * (non-Javadoc)
095: *
096: * @see org.xml.sax.helpers.DefaultHandler#notationDecl(java.lang.String,
097: * java.lang.String, java.lang.String)
098: */
099: public void notationDecl(String name, String publicId,
100: String systemId) throws SAXException {
101: this .handler.notationDecl(name, publicId, systemId);
102: }
103:
104: /*
105: * (non-Javadoc)
106: *
107: * @see org.xml.sax.helpers.DefaultHandler#processingInstruction(java.lang.String,
108: * java.lang.String)
109: */
110: public void processingInstruction(String target, String data)
111: throws SAXException {
112: this .handler.processingInstruction(target, data);
113: }
114:
115: /*
116: * (non-Javadoc)
117: *
118: * @see org.xml.sax.helpers.DefaultHandler#setDocumentLocator(org.xml.sax.Locator)
119: */
120: public void setDocumentLocator(Locator locator) {
121: this .handler.setDocumentLocator(locator);
122: }
123:
124: /*
125: * (non-Javadoc)
126: *
127: * @see org.xml.sax.helpers.DefaultHandler#skippedEntity(java.lang.String)
128: */
129: public void skippedEntity(String name) throws SAXException {
130: this .handler.skippedEntity(name);
131: }
132:
133: /*
134: * (non-Javadoc)
135: *
136: * @see org.xml.sax.helpers.DefaultHandler#startDocument()
137: */
138: public void startDocument() throws SAXException {
139: this .handler.startDocument();
140: }
141:
142: /*
143: * (non-Javadoc)
144: *
145: * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String,
146: * java.lang.String, java.lang.String, org.xml.sax.Attributes)
147: */
148: public void startElement(String uri, String localName,
149: String qName, Attributes attributes) throws SAXException {
150: this .handler.startElement(uri, localName, qName, attributes);
151: }
152:
153: /*
154: * (non-Javadoc)
155: *
156: * @see org.xml.sax.helpers.DefaultHandler#startPrefixMapping(java.lang.String,
157: * java.lang.String)
158: */
159: public void startPrefixMapping(String prefix, String uri)
160: throws SAXException {
161: this .handler.startPrefixMapping(prefix, uri);
162: }
163:
164: /*
165: * (non-Javadoc)
166: *
167: * @see org.xml.sax.helpers.DefaultHandler#unparsedEntityDecl(java.lang.String,
168: * java.lang.String, java.lang.String, java.lang.String)
169: */
170: public void unparsedEntityDecl(String name, String publicId,
171: String systemId, String notationName) throws SAXException {
172: this.handler.unparsedEntityDecl(name, publicId, systemId,
173: notationName);
174: }
175:
176: }
|