@ Override public void endElement ( String uri , String localName , String qName ) throws SAXException { flushCharacters ( ) ; if ( stack . isEmpty ( ) ) { throw new IllegalStateException ( "Stack must not be empty when closing the element " + qName + " around line " + locator . getLineNumber ( ) + " and column " + locator . getColumnNumber ( ) ) ; } IndentCheckSaxHandler . ElementEntry startEntry = stack . pop ( ) ; int indentDiff = lastIndent . size - startEntry . expectedIndent . size ; int expectedIndent = startEntry . expectedIndent . size ; if ( lastIndent . lineNumber != startEntry . foundIndent . lineNumber && indentDiff != 0 ) { /* * diff should be zero unless we are on the same line as start element */ int opValue = expectedIndent - lastIndent . size ; String op = opValue > 0 ? "Insert" : "Delete" ; String units = opValue == 1 ? "space" : "spaces" ; String message = op + " " + Math . abs ( opValue ) + " " + units + ". Expected " + expectedIndent + " found " + lastIndent . size + " spaces before end element </" + qName + ">" ; XmlFormatViolation violation = new XmlFormatViolation ( file , locator . getLineNumber ( ) , locator . getColumnNumber ( ) , message ) ; violationHandler . handle ( violation ) ; } }
Checks indentation for an end element .