Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] QName flyweights

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Wolfgang Hoschek <whoschek AT lbl.gov>
  • To: norwoods <norwoods AT gbronline.com>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] QName flyweights
  • Date: Thu, 9 Jun 2005 13:01:50 -0700


hashcodes do not map 1 to 1 to objects; more than one object may have any given hashcode.

Sure.

you need a strategy to deal with the possible conflict.
this could violate the first xom Design Goal, Absolutely correct.

Where's the problem? the hashCode() and equals() impl work exactly as intended, hash business as usual. There's no bug.


one could also have flyweight namespaces, uri and prefix; and flyweight qnames, flyweight namespace and local name.

Sure, doing it on (prefix, localName, URI) gives the largest scope for memory footprint reduction.


setPrefix, setURI, setName, setLocalName are all complicated by flyweight qnames.

They are not significantly more complicated, IMHO. It's always the same simple pattern (and it's commonality can be factored out).


what is the garbage collection strategy? the qnames will remain in the hashmap even after all other references have disappeared.

Yep they remain in there, but only the most recently used 256 qnames since the map is bounded. One might better use 128, but in any case it does not appear to be a problem.





Archive powered by MHonArc 2.6.24.

Top of Page