001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.renderer.lite;
017:
018: import java.io.IOException;
019:
020: import javax.xml.parsers.ParserConfigurationException;
021:
022: import org.xml.sax.ContentHandler;
023: import org.xml.sax.DTDHandler;
024: import org.xml.sax.EntityResolver;
025: import org.xml.sax.ErrorHandler;
026: import org.xml.sax.InputSource;
027: import org.xml.sax.SAXException;
028: import org.xml.sax.SAXNotRecognizedException;
029: import org.xml.sax.SAXNotSupportedException;
030: import org.xml.sax.XMLReader;
031: import org.xml.sax.helpers.XMLReaderFactory;
032:
033: /**
034: * A wrapper that forwards any request to the default JAXP xml reader.
035: * <p>
036: * By default Batik wants Xerces, but we want to avoid the dependency since a
037: * SAX2 parser is already included in the jre.
038: * <p>
039: * This class is needed because Batik wants the name of a class that implements
040: * XMLReader and has a public default constructor, and default jre parsers do
041: * not have it.
042: *
043: * @author wolf
044: * @since 2.2.1
045: */
046: public class BatikXMLReader implements XMLReader {
047: XMLReader reader;
048:
049: public BatikXMLReader() throws ParserConfigurationException,
050: SAXException {
051: reader = XMLReaderFactory.createXMLReader();
052: }
053:
054: public ContentHandler getContentHandler() {
055: return reader.getContentHandler();
056: }
057:
058: public DTDHandler getDTDHandler() {
059: return reader.getDTDHandler();
060: }
061:
062: public EntityResolver getEntityResolver() {
063: return reader.getEntityResolver();
064: }
065:
066: public ErrorHandler getErrorHandler() {
067: return reader.getErrorHandler();
068: }
069:
070: public boolean getFeature(String name)
071: throws SAXNotRecognizedException, SAXNotSupportedException {
072: return reader.getFeature(name);
073: }
074:
075: public Object getProperty(String name)
076: throws SAXNotRecognizedException, SAXNotSupportedException {
077: return reader.getProperty(name);
078: }
079:
080: public void parse(InputSource input) throws IOException,
081: SAXException {
082: reader.parse(input);
083: }
084:
085: public void parse(String systemId) throws IOException, SAXException {
086: reader.parse(systemId);
087: }
088:
089: public void setContentHandler(ContentHandler handler) {
090: reader.setContentHandler(handler);
091: }
092:
093: public void setDTDHandler(DTDHandler handler) {
094: reader.setDTDHandler(handler);
095: }
096:
097: public void setEntityResolver(EntityResolver resolver) {
098: reader.setEntityResolver(resolver);
099: }
100:
101: public void setErrorHandler(ErrorHandler handler) {
102: reader.setErrorHandler(handler);
103: }
104:
105: public void setFeature(String name, boolean value)
106: throws SAXNotRecognizedException, SAXNotSupportedException {
107: reader.setFeature(name, value);
108: }
109:
110: public void setProperty(String name, Object value)
111: throws SAXNotRecognizedException, SAXNotSupportedException {
112: reader.setProperty(name, value);
113: }
114: }
|