<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2655.35">
<TITLE>Child-Parent patch - Ideas.</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2 FACE="Arial">I have had a look at the Child/Parent thing.</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Personally, I don't think the Idea has been taken far enough, so I played around with the concept, and "normalised" some of the redundancies.</FONT></P>
<P><FONT SIZE=2 FACE="Arial">Firstly, I converted the Child interface into an Abstract class that deals with ALL Parent/child relationships for the Child role, including detaching, cloning, set/getParent (and holds the parent instance field).</FONT></P>
<P><FONT SIZE=2 FACE="Arial">I also implemented getDocument at the Child Class level (all children have the same mechanism for getting the Document).</FONT></P>
<P><FONT SIZE=2 FACE="Arial">Next, I added the method "getDocument" to the Parent Interface... and parent can getDocument, including the Document class which has "return this;" in the getDocument().</FONT></P>
<P><FONT SIZE=2 FACE="Arial">Finally, I changed the ContentList class substantially. elementData is now called childData, and is of type Child[] instead of Object[]. The ContentList owner is now of type Parent instead of Object. I have added a method canContain to the Parent interface, and thus the actual Parent object determines what content is allowed in the contentlist, so instead of add(int,Text), add(int,Element), add(int,CDATA), add(int,ProcessingInstruction), etc, there is just add(int, Child).</FONT></P>
<P><FONT SIZE=2 FACE="Arial">In doing all of the above, I have cut large amounts of redundant/duplicated code, simplified the relationships, and thrown away "special cases". The only downside I can see in terms of "functionality" is that some of the exceptions are thrown with less specialised messages...</FONT></P>
<P><FONT SIZE=2 FACE="Arial">Please have a look, and comment on the concept. Note, that this is only possible by converting Child to an abstract class instead of an interface.</FONT></P>
<P><FONT SIZE=2 FACE="Arial">Rolf</FONT>
</P>
<BR>
<P><FONT FACE="Arial" SIZE=2 COLOR="#000000"> <<jdom_child.zip>> </FONT>
</P>
</BODY>
</HTML>