Package com.puppycrawl.tools.checkstyle
Class XmlLoader
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- com.puppycrawl.tools.checkstyle.XmlLoader
-
- All Implemented Interfaces:
org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.EntityResolver,org.xml.sax.ErrorHandler
- Direct Known Subclasses:
ConfigurationLoader.InternalLoader,ImportControlLoader,PackageNamesLoader,SuppressionsLoader
public class XmlLoader extends org.xml.sax.helpers.DefaultHandler
Contains the common implementation of a loader, for loading a configuration from an XML file.The error handling policy can be described as being austere, dead set, disciplinary, dour, draconian, exacting, firm, forbidding, grim, hard, hard- boiled, harsh, harsh, in line, iron-fisted, no-nonsense, oppressive, persnickety, picky, prudish, punctilious, puritanical, rigid, rigorous, scrupulous, set, severe, square, stern, stickler, straight, strait-laced, stringent, stuffy, stuffy, tough, unpermissive, unsparing and uptight.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classXmlLoader.LoadExternalDtdFeatureProviderUsed for setting specific for secure java installations features to SAXParserFactory.
-
Field Summary
Fields Modifier and Type Field Description private org.xml.sax.XMLReaderparserParser to read XML files.private java.util.Map<java.lang.String,java.lang.String>publicIdToResourceNameMapMaps public id to resolve to resource name for the DTD.
-
Constructor Summary
Constructors Modifier Constructor Description protectedXmlLoader(java.util.Map<java.lang.String,java.lang.String> publicIdToResourceNameMap)Creates a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static org.xml.sax.XMLReadercreateXmlReader(org.xml.sax.helpers.DefaultHandler handler)Helper method to createXMLReader.voiderror(org.xml.sax.SAXParseException exception)voidparseInputSource(org.xml.sax.InputSource inputSource)Parses the specified input source.org.xml.sax.InputSourceresolveEntity(java.lang.String publicId, java.lang.String systemId)-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
-
-
-
-
Field Detail
-
publicIdToResourceNameMap
private final java.util.Map<java.lang.String,java.lang.String> publicIdToResourceNameMap
Maps public id to resolve to resource name for the DTD.
-
parser
private final org.xml.sax.XMLReader parser
Parser to read XML files.
-
-
Constructor Detail
-
XmlLoader
protected XmlLoader(java.util.Map<java.lang.String,java.lang.String> publicIdToResourceNameMap) throws org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException
Creates a new instance.- Parameters:
publicIdToResourceNameMap- maps public IDs to DTD resource names- Throws:
org.xml.sax.SAXException- if an error occursjavax.xml.parsers.ParserConfigurationException- if an error occurs
-
-
Method Detail
-
parseInputSource
public void parseInputSource(org.xml.sax.InputSource inputSource) throws java.io.IOException, org.xml.sax.SAXException
Parses the specified input source.- Parameters:
inputSource- the input source to parse.- Throws:
java.io.IOException- if an error occursorg.xml.sax.SAXException- in an error occurs
-
resolveEntity
public org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException, java.io.IOException
- Specified by:
resolveEntityin interfaceorg.xml.sax.EntityResolver- Overrides:
resolveEntityin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
error
public void error(org.xml.sax.SAXParseException exception) throws org.xml.sax.SAXException
- Specified by:
errorin interfaceorg.xml.sax.ErrorHandler- Overrides:
errorin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
createXmlReader
private static org.xml.sax.XMLReader createXmlReader(org.xml.sax.helpers.DefaultHandler handler) throws org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException
Helper method to createXMLReader.- Parameters:
handler- the content handler- Returns:
- new XMLReader instance
- Throws:
javax.xml.parsers.ParserConfigurationException- if a parser cannot be createdorg.xml.sax.SAXException- for SAX errors
-
-