commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Chaffee / Purple Technology <>
Subject Re: [lang] Entity Escaping (HTML/XML)
Date Wed, 09 Apr 2003 23:11:01 GMT
On Wed, Apr 09, 2003 at 06:31:18PM -0400, Gary Gregory wrote:
> I would prefer to see HTML code in an HTML class (HTMLUtils?), with
> subclasses for both HTML versions. HTML is clearly semantically different
> than simple Strings and StringUtils is already a 2000+ lines giant; these
> are new methods, so there is no back/w compatibility issues. IMHO, small
> classes with small methods seem to be a better philosophy in this particular
> case.

Way ahead of you :-)

This is StringEscapeUtils we're talking about, not StringUtils.  This
is part of the StringUtils refactoring you crave.  Yet "html" is too
specific a name; XML and (someday) SQL and other escape types might
live there.

> Having methods with version numbers does not seem very OO.

The version numbers do not refer to versions of the methods.  They
refer to published versions of external specifications.  There's no
other way to refer to HTML 3.2 than "HTML 3.2", so if that's the one
you need, that's what you've got to call it.

My question was really between
	String x = StringEscapeUtils.escapeHtml32(str);
	String x = StringEscapeUtils.escapeHtml(str, Entities.HTML32);

> Furthermore, if I wanted to migrate an app from "no version" HTML to
> 3.2 and then to 4.0, I would have to change call sites all over my
> app. With an HTML set of classes, I would just change one line of
> code with the class name or perhaps put the class name in a
> properties file for even easier configuration.

It's a straightforward refactoring no matter which way you're altering
your code, and there are lots of ways to make the selection (of which
type of escaping to use) happen "OAOO" as the XPerts put it.

But the standard usage pattern would be to call "escapeHtml(String)"
(no version) so the app would migrate transparently once you installed
the version of Lang that supports HTML 5.

Cheers -

 - Alex


Alex Chaffee                     
Purple Technology - Code and Consulting
jGuru - Java News and FAQs       
Gamelan - the Original Java site 
Stinky - Art and Angst           

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message