Callback Interfaces

SAX uses the Observer design pattern to tell client applications what's in a document.[1] Java developers are most familiar with this pattern from the event architecture of the AWT and Swing. In that context, the client programmer implements an interface such as MouseListener that receives events through well-known methods. Then the programmer registers the MouseListener object with a component such as a Button using the setMouseListener() method. When the end user moves or clicks the mouse in the button's area, the button invokes a method in the registered MouseListener object. In this example, the Button class plays the role of the Subject; the MouseListener interface plays the role of the Observer; and the client-defined ...

Get Processing XML with Java™: A Guide to SAX, DOM, JDOM, JAXP, and TrAX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.