Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] XOM 1.0d23 Last Call

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "Bradley S. Huffman" <hip AT cs.okstate.edu>
  • To: jcowan AT reutershealth.com
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] XOM 1.0d23 Last Call
  • Date: Mon, 02 Feb 2004 18:13:24 -0600

Is this just a variation of replaceChild(Node old, Node new) in ParentNode?

Brad

jcowan AT reutershealth.com writes:

> Elliotte Rusty Harold scripsit:
>
> > >1) I think it's worth having a Nodes.put method to complement get. The
> > >on
> ly
> > > way to replace a single Node in the list currently is either to copy
> > > it, which does not preserve object identity, or else to remove and
> > > then insert/append, which involves copying the list anywhere up to
> > > twice internally (if you want to replace the zeroth node), and
> > > requires
> > > getting the insert vs. append choice correct.
> >
> > I'm sorry. I don't think I understand your proposal here. What would
> > be the signature of this method, and what would its behavior be?
>
> Conceptually, it looks like this:
>
> public void put(Node node, int index) {
> if (index < 0 || index >= node.size()) {
> throw new IndexOutOfBoundsException("whatever");
> }
> else if (index == node.size()) {
> remove(index);
> append(node);
> }
> else {
> remove(index);
> insert(node, index);
> }
>
> Of course, you don't implement it that way, because that will involve
> copying
> the nodes around in order to do the remove/insert pair. Instead, you
> just replace the index'th entry of the internal array or whatever.
> The same story applies to Element.putAttribute and element.putChild;
> they conceptually remove and insert the index'th attribute or child,
> but in fact just replace.




Archive powered by MHonArc 2.6.24.

Top of Page