Hi Rob

----- Original Message -----
From: "Robert J. Lebowitz" <[EMAIL PROTECTED]>
> > However, if the standard clone call is implemented, why add the
> createCopy()
> > method.  Is there a preference of one over the other?
>
> Jim:
>
> I was working on an application last night that I believe is an example
> where .createCopy() is more useful than .clone().
>
> Aside from making a "deep copy" of the object it is "cloning",
.createCopy()
> also "detaches" the object from the rest of the object tree.  I had a
> situation where I wanted to remove all instances of <table> from an xhtml
> document, and write them out to separate files.  .createCopy() simplifies
> this process.  Without the detach(), I wouldn't be able to "add" the table
> elements as the root element to a new document that I write out.
>
> I see it as a convenience method... nice of James to include it in the
API.

Putting my pedantic hat on for a second...

Though either clone() or createCopy() could be used for the same purpose -
they both result in a deep copy which is detached from the original.
createCopy() just avoids the cast & catch of CloneNotSupportedException.

James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to