I saw that afterI sent the email.

However, if the standard clone call is implemented, why add the createCopy()
method.  Is there a preference of one over the other?

Jim


Jim Brain, [EMAIL PROTECTED]
"Researching tomorrow's decisions today."
(319) 369-2070 (work)
SYSTEMS ARCHITECT, INDIVIDUAL ITS, LIFE INVESTORS INSURANCE COMPANY OF
AMERICA

 -----Original Message-----
From:   James Strachan [mailto:[EMAIL PROTECTED]] 
Sent:   Saturday, December 01, 2001 4:17 AM
To:     Brain, Jim; DOM4J Mailing List (E-mail)
Subject:        Re: [dom4j-user] Found the problem with my issue

You can call clone() if you wish.

Element e1 = ...;
Element e2 = (Element) e1.clone();

Node implements Cloneable. If you look at the Interface Hierarchy this might
make more sense...

http://dom4j.org/apidocs/org/dom4j/package-tree.html

James
----- Original Message -----
From: "Brain, Jim" <[EMAIL PROTECTED]>
To: "DOM4J Mailing List (E-mail)" <[EMAIL PROTECTED]>
Sent: Friday, November 30, 2001 7:49 PM
Subject: [dom4j-user] Found the problem with my issue


> Re:  the issue I was having with returning an element from a class through
a
> classloader, etc.
>
> As James surmised, the classloader was not the issue.
>
> The issue was:
>
> I created a class T:
>
> Class T
> Element _e;
>
> Element getE()
> { return _e; }
>
> void setE(Element e) {
> _e=e;
> }
> }
>
> That did not work when I called getE to get the element, so I changed the
> setE to be:
>
> return e.detach();
>
> that worked until I invoked the Class.forName to load the T class... I
> thought.
>
> So, I changed getE to be:
>
> Document d=DocumentHelper.newDocument();
> d.setRootElement(_e);
> return d.getRootElement().detach()
>
> which looked like it worked.
>
> In any case, the classloader was just hiding the issue.  The real issue
was
> that I was calling T.getE() in my test code, and the second call failed,
> because _e had been attached to a document in the first part of my test.
I
> changed the code to be:
>
> Element getE()
> { return e.createCopy("Name"); }
>
> void setE(Element e)
> { _e=e.createCopy("name); }
>
> Now, all works.  Yay!
>
> However, this brings up a couple of questions:
>
> Since element subs fom Object, can't I use use clone()?  Or, since there
is
> obviously a new API, why wasn;t clone overridden?
> As well, is there a method on Element that is createCopy()?  I want the
same
> localname (I think).  Why do I need to give a new name?
>
> Jim
>
>
>
>
>
> Jim Brain, [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> "Researching tomorrow's decisions today."
> (319) 369-2070 (work)
> Systems Architect, Individual ITS, Life Investors Insurance Company of
> America
>
>
> _______________________________________________
> dom4j-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>


_________________________________________________________
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