Problem:
The class DOMAttrImpl extends DOMNodeImpl
with the special feature that the "adaptee" given to DOMNodeImpl at construction time is null and DOMAttrImpl uses its own "avAdaptee" instead.
As most of the methods of "DOMNodeImpl" dereference "adaptee", methods need to be overriden in "DOMAttrImpl" (actually, this indicates a design problem whereby using a common interface instead of a subclass relationship would be a better choice, but I digress)
Now, DOMNodeImpl has a non-overriden method:
/** * @see org.w3c.dom.Node#hasAttributes */ public boolean hasAttributes() { // contributed by dlp@users.sourceforge.net return this.adaptee.attributes != null; }
So one has to add the following in DOMAttrImpl, otherwise a NullPointerException will occur as soon as one dumps a DOM Tree:
/** * @see org.w3c.dom.Node#hasAttributes */ @Override public boolean hasAttributes() { // Does an attribute implementation have attributes? Guess not return false; }
See attached test case. It crashes if the above is not applied.
Test Case (most is support code of no interest though)