[jdom-commits] CVS update: jdom/src/java/org/jdom

jhunter at cvs.jdom.org jhunter at cvs.jdom.org
Fri Dec 15 20:04:43 PST 2000


Date:	Saturday December 16, 2000 @ 4:04
Author:	jhunter

Update of /home/cvspublic/jdom/src/java/org/jdom
In directory www.nmemonix.com:/tmp/cvs-serv3455

Modified Files:
	Attribute.java CDATA.java Comment.java Document.java 
	Element.java Entity.java IllegalAddException.java 
	ProcessingInstruction.java Verifier.java 
Log Message:
Big change...

Added parentage for Attribute, Comment, Element, Entity, and PI!
They all now have getParent() methods.  All but Attribute have
getDocument() methods also (perhaps Attribute should have it too?).

The addContent() and addAttribute() methods now check parentage and
don't allow an item to be added if it's already held by another.  This
may break existing programs that use the same item in multiple places
in the tree.  That's really a good thing tho because we now avoid the
weird side effects where an item can exist in multiple places and 
changing one item value can accidentally change multiple item values.

Testing shows no noticeable speed loss.  A couple extra gets and
sets on each add aren't significant compared to the other work being 
performed.  (OptimizeIt is a great tool.)  We are eating extra bytes
to hold parentage for Attribute, Comment, Entity, and PI, but we can
make sure it's only one variable pointer by using the same object for
the containing (Element or Document) object (an optimization for later).

Note the PartialList impl does *not* yet check parentage.  I left it 
alone  because it's on the slate to be rewritten soon.  The rewrite 
will do the checking.

FWIW, I did try a test using a ThreadLocal variable set in SAXBuilder to 
say "don't bother with sanity checking parentage or XML names" (mostly to
save the time doing XML name checking cuz parentage is so fast it doesn't
even show up in the OptimizeIt list).  But turns out it took more time 
to access the ThreadLocal variable than to sanity check!  Parentage 
checking is essentially free, and XML name checking is still relatively
cheap.

Another thing, I removed the deprecated add methods leftover from beta5.  
With this new model I didn't want to mix the old model.

And I removed CDATA.setText().  I wasn't sure about adding parentage
to CDATA sections (seems weird since we don't have it for String).  And
so if we don't manage parentage it should be immutable, lest people 
get strange bugs with changing one item changing many.

I tried various approaches with a Node interface, but XML is so damn
quirky that it's hard for Node to be useful.  For example, I want to
use Node to say this.getParent().removeContent(this) to remove an element 
and have it work if the "parent" was either an elt or doc.  But the sad
news is that a document can't have a removeContent(Element) because a doc
must always have exactly one root to be well-formed.  So then Node
really shouldn't have a removeContent(Element) either, and that really
limits its generic usefulness.  Gotta think more about this.

-jh-


===================================================================
File: Attribute.java   	Status: Up-to-date

   Working revision:	1.18	Sat Dec 16 04:04:37 2000
   Repository revision:	1.18	/home/cvspublic/jdom/src/java/org/jdom/Attribute.java,v

   Existing Tags:
	start                    	(revision: 1.1.1.1)
	jdom                     	(branch: 1.1.1)

===================================================================
File: CDATA.java       	Status: Up-to-date

   Working revision:	1.4	Sat Dec 16 04:04:37 2000
   Repository revision:	1.4	/home/cvspublic/jdom/src/java/org/jdom/CDATA.java,v

   Existing Tags:
	No Tags Exist

===================================================================
File: Comment.java     	Status: Up-to-date

   Working revision:	1.10	Sat Dec 16 04:04:38 2000
   Repository revision:	1.10	/home/cvspublic/jdom/src/java/org/jdom/Comment.java,v

   Existing Tags:
	start                    	(revision: 1.1.1.1)
	jdom                     	(branch: 1.1.1)

===================================================================
File: Document.java    	Status: Up-to-date

   Working revision:	1.25	Sat Dec 16 04:04:38 2000
   Repository revision:	1.25	/home/cvspublic/jdom/src/java/org/jdom/Document.java,v

   Existing Tags:
	start                    	(revision: 1.1.1.1)
	jdom                     	(branch: 1.1.1)

===================================================================
File: Element.java     	Status: Up-to-date

   Working revision:	1.49	Sat Dec 16 04:04:39 2000
   Repository revision:	1.49	/home/cvspublic/jdom/src/java/org/jdom/Element.java,v

   Existing Tags:
	start                    	(revision: 1.1.1.1)
	jdom                     	(branch: 1.1.1)

===================================================================
File: Entity.java      	Status: Up-to-date

   Working revision:	1.8	Sat Dec 16 04:04:40 2000
   Repository revision:	1.8	/home/cvspublic/jdom/src/java/org/jdom/Entity.java,v

   Existing Tags:
	start                    	(revision: 1.1.1.1)
	jdom                     	(branch: 1.1.1)

===================================================================
File: IllegalAddException.java	Status: Up-to-date

   Working revision:	1.7	Sat Dec 16 04:04:40 2000
   Repository revision:	1.7	/home/cvspublic/jdom/src/java/org/jdom/IllegalAddException.java,v

   Existing Tags:
	start                    	(revision: 1.1.1.1)
	jdom                     	(branch: 1.1.1)

===================================================================
File: ProcessingInstruction.java	Status: Up-to-date

   Working revision:	1.8	Sat Dec 16 04:04:40 2000
   Repository revision:	1.8	/home/cvspublic/jdom/src/java/org/jdom/ProcessingInstruction.java,v

   Existing Tags:
	start                    	(revision: 1.1.1.1)
	jdom                     	(branch: 1.1.1)

===================================================================
File: Verifier.java    	Status: Up-to-date

   Working revision:	1.15	Sat Dec 16 04:04:41 2000
   Repository revision:	1.15	/home/cvspublic/jdom/src/java/org/jdom/Verifier.java,v

   Existing Tags:
	start                    	(revision: 1.1.1.1)
	jdom                     	(branch: 1.1.1)




More information about the jdom-commits mailing list