[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [xml-dev] Achieving object model independence
Jim Wissner wrote:
[snip]
> 2. Create my own set of basic interfaces that mirror common object model
> components (Document, Element, Attribute), subclass the implementation
> classes of the corresponding dom4j/JDOM/DOM classes, set the appropriate
> factory methods to create instances of the subclasses that implement my
> common interfaces, and return those common interfaces to the rest of my
> library.
>
> I currently use this method with Xerces in order to implement undo/redo
> of DOM mutations, and it is quite effective. Nevertheless this approach
> makes me uneasy because it is dependent on utilizing "nonpublic"
> components (that is, having to subclass the default implementation
> classes which, though often public in the sense of Java scoping, are
> sometimes left out of documentation and presumably more subject to
> change than the rest of the APIs. Is this true, or am I being overly
> worrisome?)
>
Not related to the original subject, but:
To implement undo when using Xerces, you could as well use the DOM
mutation events, which Xerces supports. Just register event listeners on
the document node for all mutation events. Then it is easy to record all
changes so that they can be undone later.
--
Bruno Dumon