Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Text.copy

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Harold <elharo AT metalab.unc.edu>
  • To: Wolfgang Hoschek <whoschek AT lbl.gov>, xom-interest <xom-interest AT lists.ibiblio.org>
  • Cc:
  • Subject: Re: [XOM-interest] Text.copy
  • Date: Thu, 25 Nov 2004 18:02:58 -0500

Wolfgang Hoschek wrote:

How about avoiding verification on copy in Text? It is unnecessary since the text has already been verified before.
It's straightforward:

public Node copy() {
if (isCDATASection()) {
return new CDATASection(this);
}
else {
return build(data);
// return new Text(this);
}
}


OK. I think I can go that one better and avoid the UTF-8 conversion and save a little memory too. How about this:

public Node copy() {

Text copy;
if (this.isCDATASection()) {
copy = new CDATASection();
}
else {
copy = new Text();
}
copy.data = this.data;
return copy;

}

(This also needs the addition of a non-public no-args constructor in CDATASection.)

This would share the data array between the original node and its copy. However, this array is private and is never written to inside the class. It is occasionally replaced, but there's no way to change its contents. (The Text class is like a String in this respect). Thoughts?


--
Elliotte Rusty Harold elharo AT metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim




Archive powered by MHonArc 2.6.24.

Top of Page