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);
and
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
P.S. OAOO: http://c2.com/cgi/wiki?OnceAndOnlyOnce
--
Alex Chaffee mailto:alex@jguru.com
Purple Technology - Code and Consulting http://www.purpletech.com/
jGuru - Java News and FAQs http://www.jguru.com/alex/
Gamelan - the Original Java site http://www.gamelan.com/
Stinky - Art and Angst http://www.stinky.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
|