AltSAXParser as standalone class
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 08 Jun 2014 09:57:33 +0200
changeset 3703f940508c72
parent 36 ad36a104623f
child 38 3de77c1ac95e
AltSAXParser as standalone class
java/alt2xml-lib-input/src/cz/frantovo/alt2xml/AltSAXParser.java
java/alt2xml-lib-input/src/cz/frantovo/alt2xml/ParserFactory.java
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/java/alt2xml-lib-input/src/cz/frantovo/alt2xml/AltSAXParser.java	Sun Jun 08 09:57:33 2014 +0200
     1.3 @@ -0,0 +1,69 @@
     1.4 +/**
     1.5 + * Alt2XML
     1.6 + * Copyright © 2014 František Kučera (frantovo.cz)
     1.7 + *
     1.8 + * This program is free software: you can redistribute it and/or modify
     1.9 + * it under the terms of the GNU General Public License as published by
    1.10 + * the Free Software Foundation, either version 3 of the License, or
    1.11 + * (at your option) any later version.
    1.12 + *
    1.13 + * This program is distributed in the hope that it will be useful,
    1.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    1.16 + * GNU General Public License for more details.
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License
    1.19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
    1.20 + */
    1.21 +package cz.frantovo.alt2xml;
    1.22 +
    1.23 +import javax.xml.parsers.SAXParser;
    1.24 +import org.xml.sax.Parser;
    1.25 +import org.xml.sax.SAXException;
    1.26 +import org.xml.sax.SAXNotRecognizedException;
    1.27 +import org.xml.sax.SAXNotSupportedException;
    1.28 +import org.xml.sax.XMLReader;
    1.29 +
    1.30 +/**
    1.31 + *
    1.32 + * @author Ing. František Kučera (frantovo.cz)
    1.33 + */
    1.34 +public class AltSAXParser extends SAXParser {
    1.35 +
    1.36 +	private final XMLReader xmlReader;
    1.37 +
    1.38 +	public AltSAXParser(XMLReader xmlReader) {
    1.39 +		this.xmlReader = xmlReader;
    1.40 +	}
    1.41 +
    1.42 +	@Override
    1.43 +	@Deprecated
    1.44 +	public Parser getParser() throws SAXException {
    1.45 +		throw new SAXException("Není podporováno.");
    1.46 +	}
    1.47 +
    1.48 +	@Override
    1.49 +	public XMLReader getXMLReader() throws SAXException {
    1.50 +		return xmlReader;
    1.51 +	}
    1.52 +
    1.53 +	@Override
    1.54 +	public boolean isNamespaceAware() {
    1.55 +		return true;
    1.56 +	}
    1.57 +
    1.58 +	@Override
    1.59 +	public boolean isValidating() {
    1.60 +		return false;
    1.61 +	}
    1.62 +
    1.63 +	@Override
    1.64 +	public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
    1.65 +		xmlReader.setProperty(name, value);
    1.66 +	}
    1.67 +
    1.68 +	@Override
    1.69 +	public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
    1.70 +		return xmlReader.getProperty(name);
    1.71 +	}
    1.72 +}
     2.1 --- a/java/alt2xml-lib-input/src/cz/frantovo/alt2xml/ParserFactory.java	Sun Jun 08 09:53:51 2014 +0200
     2.2 +++ b/java/alt2xml-lib-input/src/cz/frantovo/alt2xml/ParserFactory.java	Sun Jun 08 09:57:33 2014 +0200
     2.3 @@ -24,7 +24,6 @@
     2.4  import javax.xml.parsers.ParserConfigurationException;
     2.5  import javax.xml.parsers.SAXParser;
     2.6  import javax.xml.parsers.SAXParserFactory;
     2.7 -import org.xml.sax.Parser;
     2.8  import org.xml.sax.SAXException;
     2.9  import org.xml.sax.SAXNotRecognizedException;
    2.10  import org.xml.sax.SAXNotSupportedException;
    2.11 @@ -116,11 +115,11 @@
    2.12  		return new AltSAXParser(new SuperReader(this));
    2.13  	}
    2.14  
    2.15 -	/**
    2.16 -	 * TODO: feature for disabling default SAXParserFactory
    2.17 -	 */
    2.18  	@Override
    2.19  	public void setFeature(String name, boolean value) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException {
    2.20 +		/**
    2.21 +		 * TODO: feature for disabling default SAXParserFactory
    2.22 +		 */
    2.23  		throw new SAXNotSupportedException("Zatím není podporováno.");
    2.24  	}
    2.25  
    2.26 @@ -128,44 +127,4 @@
    2.27  	public boolean getFeature(String name) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException {
    2.28  		throw new SAXNotSupportedException("Zatím není podporováno.");
    2.29  	}
    2.30 -
    2.31 -	private static class AltSAXParser extends SAXParser {
    2.32 -
    2.33 -		private final XMLReader xmlReader;
    2.34 -
    2.35 -		public AltSAXParser(XMLReader xmlReader) {
    2.36 -			this.xmlReader = xmlReader;
    2.37 -		}
    2.38 -
    2.39 -		@Override
    2.40 -		@Deprecated
    2.41 -		public Parser getParser() throws SAXException {
    2.42 -			throw new SAXException("Není podporováno.");
    2.43 -		}
    2.44 -
    2.45 -		@Override
    2.46 -		public XMLReader getXMLReader() throws SAXException {
    2.47 -			return xmlReader;
    2.48 -		}
    2.49 -
    2.50 -		@Override
    2.51 -		public boolean isNamespaceAware() {
    2.52 -			return true;
    2.53 -		}
    2.54 -
    2.55 -		@Override
    2.56 -		public boolean isValidating() {
    2.57 -			return false;
    2.58 -		}
    2.59 -
    2.60 -		@Override
    2.61 -		public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
    2.62 -			xmlReader.setProperty(name, value);
    2.63 -		}
    2.64 -
    2.65 -		@Override
    2.66 -		public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
    2.67 -			return xmlReader.getProperty(name);
    2.68 -		}
    2.69 -	}
    2.70  }