Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] simple questions

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • To: luca <passani AT eunet.no>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] simple questions
  • Date: Tue, 13 Apr 2004 09:49:11 -0400

At 2:58 PM +0200 4/13/04, luca wrote:
Hallo, I needed to manipulate the OM this time :)

I am using this code to copy an element to be appended somewhere else:

Element new_element = (Element)someElementList.get(k).copy();

I understand that I could use:

Element new_element = new Element(someElementList.get(k));

is there any reason to prefer one over the other performance or semantic-wise?

The second one avoids the cast, but otherwise one just calls the other. However, the copy() method has the option in a subclass to return an instance of the subclass instead of a pure Element. I doubt performance is an issue.


--

Elliotte Rusty Harold
elharo AT metalab.unc.edu
Effective XML (Addison-Wesley, 2003)
http://www.cafeconleche.org/books/effectivexml
http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/cafeaulaitA




Archive powered by MHonArc 2.6.24.

Top of Page