[jdom-interest] Code submision: JDOM2 the dual tree implementation...

Jason Hunter jhunter at collab.net
Wed Nov 29 13:39:43 PST 2000

> This kind of stuff might seem a bit wierd or complex from a 
> general case '80/20' kind of outlook.
> However the JDK already has this kind of stuff built in for us 
> in Java 2 Collections because some people need to be able to 
> do this kind of thing - to prevent a large, complex data 
> structure from being mutated by mistake.

How the collections work is they create a subclass of the normal types
that delegates to the original collection object, and the subclass
throws UnsuppOpEx on the mutation methods.  That's still quite possible
in JDOM.  No need to even introduce a new public class.  We just have a
get method that returns a read-only version of a Document.  (It could be
done outside org.jdom without touching org.jdom as well.)

But you don't get the thing you're looking for, which I believe is not
just read-only functionality but the special optimizations enabled by
knowing a doc is read-only.  That's where things get tricky.


More information about the jdom-interest mailing list