Package org.codehaus.mojo.xml.format
Class IndentCheckSaxHandler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.codehaus.mojo.xml.format.IndentCheckSaxHandler
-
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
public class IndentCheckSaxHandler extends DefaultHandler
ADefaultHandler
implementation that detects formatting violations and reports them to the suppliedXmlFormatViolationHandler
.- Author:
- Peter Palaga
-
-
Constructor Summary
Constructors Constructor Description IndentCheckSaxHandler(File file, int indentSize, XmlFormatViolationHandler violationHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
characters(char[] ch, int start, int length)
Stores the passed characters into a character buffer.void
endElement(String uri, String localName, String qName)
Checks indentation for an end element.void
ignorableWhitespace(char[] chars, int start, int length)
Just delegates tocharacters(char[], int, int)
, since this method is not called in all situations where it could be naively expected.InputSource
resolveEntity(String publicId, String systemId)
Always returns an emptyInputSource
to avoid loading of any DTDs.void
setDocumentLocator(Locator locator)
void
startElement(String uri, String localName, String qName, Attributes attributes)
Checks indentation for a start element.-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, notationDecl, processingInstruction, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
-
-
-
-
Constructor Detail
-
IndentCheckSaxHandler
public IndentCheckSaxHandler(File file, int indentSize, XmlFormatViolationHandler violationHandler)
-
-
Method Detail
-
characters
public void characters(char[] ch, int start, int length) throws SAXException
Stores the passed characters into a character buffer.- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
- Throws:
SAXException
- See Also:
DefaultHandler.characters(char[], int, int)
-
endElement
public void endElement(String uri, String localName, String qName) throws SAXException
Checks indentation for an end element.- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
- See Also:
DefaultHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
-
ignorableWhitespace
public void ignorableWhitespace(char[] chars, int start, int length) throws SAXException
Just delegates tocharacters(char[], int, int)
, since this method is not called in all situations where it could be naively expected.- Specified by:
ignorableWhitespace
in interfaceContentHandler
- Overrides:
ignorableWhitespace
in classDefaultHandler
- Throws:
SAXException
- See Also:
DefaultHandler.ignorableWhitespace(char[], int, int)
-
resolveEntity
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
Always returns an emptyInputSource
to avoid loading of any DTDs.- Specified by:
resolveEntity
in interfaceEntityResolver
- Overrides:
resolveEntity
in classDefaultHandler
- Throws:
SAXException
IOException
- See Also:
DefaultHandler.resolveEntity(java.lang.String, java.lang.String)
-
setDocumentLocator
public void setDocumentLocator(Locator locator)
- Specified by:
setDocumentLocator
in interfaceContentHandler
- Overrides:
setDocumentLocator
in classDefaultHandler
- See Also:
DefaultHandler.setDocumentLocator(org.xml.sax.Locator)
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
Checks indentation for a start element.- Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
- See Also:
DefaultHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
-
-