Re: question about Tidy

Chunbo Shao wrote:
> 
> Hello, Gary
> 
> I hope you still remember me. I still work on JTidy a lot. I have
> question.
> 
> There is "Node" interface in dom package, and there is "DOMNodeImpl" class
> to implement this interface.
> In the example file attached (which comes from the jtidy help html), I see
> the code of "node.getNodeName()",
> where node is an instance of dom.Node. I know there is implementation of
> getNodeName() method inside of
> "DOMNodeImpl" class which is in the tidy package. BUT i really cannot see
> how this method can be invoked by the above call:
> "node.getNodeName()". PLease help me.
> 
> Great thanks. If any of my description is not clear, please tell me as
> soon as possible.
> 
> Looking forward to kind reply.

Hi, Major --

Nice to hear from you.  I think your questions is "How does the
DOMNodeImpl.getNodeName() method get invoked from the sample code?"

As you said, DOMNodeImpl implements the org.w3c.dom.Node interface. 
org.w3c.dom.Node is an interface specified by the w3c as part of their
DOM project:
See
http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-1950641247

In the sample code, node is a Node that is passed in to the print()
method.  The print() method, in turn, is initially invoked from the
main() method in the statement

  t.print(tidy.parseDOM(in, null));

The tidy.parseDOM method actually returns a DOMNodeImpl which is also
considered a Node since DOMNodeImpl implements the Node interface.

This whole concept requires a good understanding of how interfaces work
and interact with the classes that implement them.  You may want to
review some of the material on the java site in this regard.

I hope this answers your question.  If you need further clarification,
please let me know.

Gary

Received on Monday, 12 February 2001 18:04:32 UTC