11/* 
2-  * Copyright 2002-2012  the original author or authors. 
2+  * Copyright 2002-2016  the original author or authors. 
33 * 
44 * Licensed under the Apache License, Version 2.0 (the "License"); 
55 * you may not use this file except in compliance with the License. 
2626import  org .xml .sax .ext .LexicalHandler ;
2727
2828/** 
29-  * Abstract base class for SAX {@code XMLReader} implementations. Contains properties as defined in {@link  
30-  * XMLReader}, and does not recognize any features. 
29+  * Abstract base class for SAX {@code XMLReader} implementations. 
30+  * Contains properties as defined in {@link  XMLReader}, and does not recognize any features. 
3131 * 
3232 * @author Arjen Poutsma 
33+  * @author Juergen Hoeller 
34+  * @since 3.0 
3335 * @see #setContentHandler(org.xml.sax.ContentHandler) 
3436 * @see #setDTDHandler(org.xml.sax.DTDHandler) 
3537 * @see #setEntityResolver(org.xml.sax.EntityResolver) 
3638 * @see #setErrorHandler(org.xml.sax.ErrorHandler) 
37-  * @since 3.0 
3839 */ 
3940abstract  class  AbstractXMLReader  implements  XMLReader  {
4041
@@ -48,29 +49,25 @@ abstract class AbstractXMLReader implements XMLReader {
4849
4950	private  LexicalHandler  lexicalHandler ;
5051
51- 	@ Override 
52- 	public  ContentHandler  getContentHandler () {
53- 		return  contentHandler ;
54- 	}
5552
5653	@ Override 
5754	public  void  setContentHandler (ContentHandler  contentHandler ) {
5855		this .contentHandler  = contentHandler ;
5956	}
6057
6158	@ Override 
62- 	public  void   setDTDHandler ( DTDHandler   dtdHandler ) {
63- 		this .dtdHandler  =  dtdHandler ;
59+ 	public  ContentHandler   getContentHandler ( ) {
60+ 		return   this .contentHandler ;
6461	}
6562
6663	@ Override 
67- 	public  DTDHandler   getDTDHandler ( ) {
68- 		return  dtdHandler ;
64+ 	public  void   setDTDHandler ( DTDHandler   dtdHandler ) {
65+ 		this . dtdHandler  =  dtdHandler ;
6966	}
7067
7168	@ Override 
72- 	public  EntityResolver   getEntityResolver () {
73- 		return  entityResolver ;
69+ 	public  DTDHandler   getDTDHandler () {
70+ 		return  this . dtdHandler ;
7471	}
7572
7673	@ Override 
@@ -79,38 +76,55 @@ public void setEntityResolver(EntityResolver entityResolver) {
7976	}
8077
8178	@ Override 
82- 	public  ErrorHandler   getErrorHandler () {
83- 		return  errorHandler ;
79+ 	public  EntityResolver   getEntityResolver () {
80+ 		return  this . entityResolver ;
8481	}
8582
8683	@ Override 
8784	public  void  setErrorHandler (ErrorHandler  errorHandler ) {
8885		this .errorHandler  = errorHandler ;
8986	}
9087
88+ 	@ Override 
89+ 	public  ErrorHandler  getErrorHandler () {
90+ 		return  this .errorHandler ;
91+ 	}
92+ 
9193	protected  LexicalHandler  getLexicalHandler () {
92- 		return  lexicalHandler ;
94+ 		return  this . lexicalHandler ;
9395	}
9496
97+ 
9598	/** 
96- 	 * Throws a {@code SAXNotRecognizedException} exception. 
97- 	 * 
98- 	 * @throws org.xml.sax.SAXNotRecognizedException 
99- 	 *          always 
99+ 	 * This implementation throws a {@code SAXNotRecognizedException} exception 
100+ 	 * for any feature outside of the "http://xml.org/sax/features/" namespace 
101+ 	 * and returns {@code false} for any feature within. 
100102	 */ 
101103	@ Override 
102104	public  boolean  getFeature (String  name ) throws  SAXNotRecognizedException , SAXNotSupportedException  {
103- 		throw  new  SAXNotRecognizedException (name );
105+ 		if  (name .startsWith ("http://xml.org/sax/features/" )) {
106+ 			return  false ;
107+ 		}
108+ 		else  {
109+ 			throw  new  SAXNotRecognizedException (name );
110+ 		}
104111	}
105112
106113	/** 
107- 	 * Throws  a {@code SAXNotRecognizedException} exception.  
108- 	 * 
109- 	 * @throws SAXNotRecognizedException always  
114+ 	 * This implementation throws  a {@code SAXNotRecognizedException} exception 
115+ 	 * for any feature outside of the "http://xml.org/sax/features/" namespace  
116+ 	 * and accepts a {@code false} value for any feature within.  
110117	 */ 
111118	@ Override 
112119	public  void  setFeature (String  name , boolean  value ) throws  SAXNotRecognizedException , SAXNotSupportedException  {
113- 		throw  new  SAXNotRecognizedException (name );
120+ 		if  (name .startsWith ("http://xml.org/sax/features/" )) {
121+ 			if  (value ) {
122+ 				throw  new  SAXNotSupportedException (name );
123+ 			}
124+ 		}
125+ 		else  {
126+ 			throw  new  SAXNotRecognizedException (name );
127+ 		}
114128	}
115129
116130	/** 
@@ -120,7 +134,7 @@ public void setFeature(String name, boolean value) throws SAXNotRecognizedExcept
120134	@ Override 
121135	public  Object  getProperty (String  name ) throws  SAXNotRecognizedException , SAXNotSupportedException  {
122136		if  ("http://xml.org/sax/properties/lexical-handler" .equals (name )) {
123- 			return  lexicalHandler ;
137+ 			return  this . lexicalHandler ;
124138		}
125139		else  {
126140			throw  new  SAXNotRecognizedException (name );
@@ -134,10 +148,11 @@ public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotS
134148	@ Override 
135149	public  void  setProperty (String  name , Object  value ) throws  SAXNotRecognizedException , SAXNotSupportedException  {
136150		if  ("http://xml.org/sax/properties/lexical-handler" .equals (name )) {
137- 			lexicalHandler  = (LexicalHandler ) value ;
151+ 			this . lexicalHandler  = (LexicalHandler ) value ;
138152		}
139153		else  {
140154			throw  new  SAXNotRecognizedException (name );
141155		}
142156	}
157+ 
143158}
0 commit comments