DocumentHandlerState should be static. Automatically throw exception if no TagHandler returned.

This commit is contained in:
Michael Jumper
2012-12-24 13:19:13 -08:00
parent 4b45564835
commit baa982daf1

View File

@@ -106,6 +106,10 @@ public class DocumentHandler extends DefaultHandler {
handler = parent_handler.childElement(localName, attributes); handler = parent_handler.childElement(localName, attributes);
} }
// If no handler returned, the element was not expected
if (handler == null)
throw new SAXException("Unexpected element: '" + localName + "'");
// Append new element state to stack // Append new element state to stack
stack.addLast(new DocumentHandlerState(handler)); stack.addLast(new DocumentHandlerState(handler));
@@ -136,7 +140,7 @@ public class DocumentHandler extends DefaultHandler {
/** /**
* The current state of the DocumentHandler. * The current state of the DocumentHandler.
*/ */
private class DocumentHandlerState { private static class DocumentHandlerState {
/** /**
* The current text content of the current element being parsed. * The current text content of the current element being parsed.