[jdom-commits] CVS Update: jdom/src/java/org/jdom/output

nobody nobody at chimbo.servlets.com
Thu May 1 17:52:58 PDT 2003


****************************************
Date:   Thu May  1, 2003 @18:52:58 MDT
Author: 

Update of /home/cvs/jdom/src/java/org/jdom/output
In directory chimbo:/tmp/cvs-serv26736/output

Modified Files:
XMLOutputter.java
Added Files:
EscapeStrategy.java
Log Message:
Added an EscapeStrategy plug-in interface for XMLOutputter to determine
which chars to escape. A user can set a strategy and go, no need to
subclass.

Also created a DefaultEscapeStrategy which tries to be generally smart.
It quickly says no escaping is necessary for UTF-8 (our default) and UTF-16.
It escapes everything > 255 for ISO-8859-1/Latin1. It escapes everything
> 127 for ASCII.

For the other charsets it tries to use the JDK 1.4 CharsetEncoder to
determine if the char needs escaping. I use reflection for this so
we aren't dependent on JDK 1.4 That means if you run on JDK 1.3 there's
no escaping unless we know about the charset ourselves.

I'm not sure how slow the repeated reflection invoke() is. I'm guessing
it's pretty heavy, but I don't know how else to tackle that problem and
not depend on 1.4. People can always plug-in their own strategy if they
want.

Thanks for Alex and Brad for the ideas behind this. Please guys, double
check my code and if someone wants to do a before/after perf test that'd
be great!

-jh-

===================================================================
File: no file EscapeStrategy.java		Status: Needs Checkout

   Working revision:	1.1	Fri May  2 00:52:58 2003
   Repository revision:	1.1	/home/cvs/jdom/src/java/org/jdom/output/EscapeStrategy.java,v

   Existing Tags:
	No Tags Exist

===================================================================
File: no file XMLOutputter.java		Status: Needs Checkout

   Working revision:	1.94	Fri May  2 00:52:58 2003
   Repository revision:	1.94	/home/cvs/jdom/src/java/org/jdom/output/XMLOutputter.java,v

   Existing Tags:
	jdom_1_0_b9              	(revision: 1.91)
	jdom_1_0_b8              	(revision: 1.76)
	jdom_prefilter           	(revision: 1.66)
	jdom_1_0_b7              	(revision: 1.62)
	jdom_1_0_b6              	(revision: 1.35)
	start                    	(revision: 1.1.1.1)
	jdom                     	(branch: 1.1.1)




More information about the jdom-commits mailing list