|
/*
|
|
* The Syncro Soft SRL License
|
|
*
|
|
* Copyright (c) 1998-2012 Syncro Soft SRL, Romania. All rights
|
|
* reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
*
|
|
* 1. Redistribution of source or in binary form is allowed only with
|
|
* the prior written permission of Syncro Soft SRL.
|
|
*
|
|
* 2. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
*
|
|
* 3. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in
|
|
* the documentation and/or other materials provided with the
|
|
* distribution.
|
|
*
|
|
* 4. The end-user documentation included with the redistribution,
|
|
* if any, must include the following acknowledgment:
|
|
* "This product includes software developed by the
|
|
* Syncro Soft SRL (http://www.sync.ro/)."
|
|
* Alternately, this acknowledgment may appear in the software itself,
|
|
* if and wherever such third-party acknowledgments normally appear.
|
|
*
|
|
* 5. The names "Oxygen" and "Syncro Soft SRL" must
|
|
* not be used to endorse or promote products derived from this
|
|
* software without prior written permission. For written
|
|
* permission, please contact support@oxygenxml.com.
|
|
*
|
|
* 6. Products derived from this software may not be called "Oxygen",
|
|
* nor may "Oxygen" appear in their name, without prior written
|
|
* permission of the Syncro Soft SRL.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
* DISCLAIMED. IN NO EVENT SHALL THE SYNCRO SOFT SRL OR
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*/
|
|
package ro.sync.exml.test;
|
|
|
|
import java.io.IOException;
|
|
|
|
import javax.xml.parsers.SAXParser;
|
|
import javax.xml.parsers.SAXParserFactory;
|
|
|
|
import org.xml.sax.ContentHandler;
|
|
import org.xml.sax.DTDHandler;
|
|
import org.xml.sax.EntityResolver;
|
|
import org.xml.sax.ErrorHandler;
|
|
import org.xml.sax.InputSource;
|
|
import org.xml.sax.SAXException;
|
|
import org.xml.sax.SAXNotRecognizedException;
|
|
import org.xml.sax.SAXNotSupportedException;
|
|
import org.xml.sax.XMLReader;
|
|
|
|
/**
|
|
* XML reader wrapper.
|
|
*/
|
|
public class XMLReaderWrapper implements XMLReader {
|
|
|
|
/**
|
|
* Wrapped XML reader.
|
|
*/
|
|
private XMLReader xmlReader;
|
|
|
|
/**
|
|
* Parser entity resolver.
|
|
*/
|
|
private EntityResolver entityResolver = new EntityResolver() {
|
|
@Override
|
|
public InputSource resolveEntity(String publicId, String systemId) throws SAXException,
|
|
IOException {
|
|
return null;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Constructor.
|
|
*/
|
|
public XMLReaderWrapper() {
|
|
// Get a new XML parser.
|
|
SAXParserFactory spf = SAXParserFactory.newInstance();
|
|
try {
|
|
SAXParser parser = spf.newSAXParser();
|
|
xmlReader = parser.getXMLReader();
|
|
} catch (Exception ex) {
|
|
ex.printStackTrace();
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* @see org.xml.sax.XMLReader#getFeature(java.lang.String)
|
|
*/
|
|
@Override
|
|
public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
|
|
return xmlReader.getFeature(name);
|
|
}
|
|
|
|
/**
|
|
* @see org.xml.sax.XMLReader#setFeature(java.lang.String, boolean)
|
|
*/
|
|
@Override
|
|
public void setFeature(String name, boolean value) throws SAXNotRecognizedException,
|
|
SAXNotSupportedException {
|
|
xmlReader.setFeature(name, value);
|
|
}
|
|
|
|
/**
|
|
* @see org.xml.sax.XMLReader#getProperty(java.lang.String)
|
|
*/
|
|
@Override
|
|
public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
|
|
return xmlReader.getProperty(name);
|
|
}
|
|
|
|
/**
|
|
* @see org.xml.sax.XMLReader#setProperty(java.lang.String, java.lang.Object)
|
|
*/
|
|
@Override
|
|
public void setProperty(String name, Object value) throws SAXNotRecognizedException,
|
|
SAXNotSupportedException {
|
|
xmlReader.setProperty(name, value);
|
|
}
|
|
|
|
/**
|
|
* @see org.xml.sax.XMLReader#setEntityResolver(org.xml.sax.EntityResolver)
|
|
*/
|
|
@Override
|
|
public void setEntityResolver(EntityResolver resolver) {
|
|
xmlReader.setEntityResolver(resolver);
|
|
}
|
|
|
|
/**
|
|
* @see org.xml.sax.XMLReader#getEntityResolver()
|
|
*/
|
|
@Override
|
|
public EntityResolver getEntityResolver() {
|
|
return entityResolver;
|
|
}
|
|
|
|
/**
|
|
* @see org.xml.sax.XMLReader#setDTDHandler(org.xml.sax.DTDHandler)
|
|
*/
|
|
@Override
|
|
public void setDTDHandler(DTDHandler handler) {
|
|
xmlReader.setDTDHandler(handler);
|
|
}
|
|
|
|
/**
|
|
* @see org.xml.sax.XMLReader#getDTDHandler()
|
|
*/
|
|
@Override
|
|
public DTDHandler getDTDHandler() {
|
|
return xmlReader.getDTDHandler();
|
|
}
|
|
|
|
/**
|
|
* @see org.xml.sax.XMLReader#setContentHandler(org.xml.sax.ContentHandler)
|
|
*/
|
|
@Override
|
|
public void setContentHandler(ContentHandler handler) {
|
|
xmlReader.setContentHandler(handler);
|
|
}
|
|
|
|
/**
|
|
* @see org.xml.sax.XMLReader#getContentHandler()
|
|
*/
|
|
@Override
|
|
public ContentHandler getContentHandler() {
|
|
return xmlReader.getContentHandler();
|
|
}
|
|
|
|
/**
|
|
* @see org.xml.sax.XMLReader#setErrorHandler(org.xml.sax.ErrorHandler)
|
|
*/
|
|
@Override
|
|
public void setErrorHandler(ErrorHandler handler) {
|
|
xmlReader.setErrorHandler(handler);
|
|
}
|
|
|
|
/**
|
|
* @see org.xml.sax.XMLReader#getErrorHandler()
|
|
*/
|
|
@Override
|
|
public ErrorHandler getErrorHandler() {
|
|
return xmlReader.getErrorHandler();
|
|
}
|
|
|
|
/**
|
|
* @see org.xml.sax.XMLReader#parse(org.xml.sax.InputSource)
|
|
*/
|
|
@Override
|
|
public void parse(InputSource input) throws IOException, SAXException {
|
|
xmlReader.parse(input);
|
|
}
|
|
|
|
/**
|
|
* @see org.xml.sax.XMLReader#parse(java.lang.String)
|
|
*/
|
|
@Override
|
|
public void parse(String systemId) throws IOException, SAXException {
|
|
xmlReader.parse(systemId);
|
|
}
|
|
}
|