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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.