[jdom-interest] Text class (Question)

ecky ecky at free.fr
Mon May 28 03:17:17 PDT 2001


Sorry if you receive this mail twice, but the automatic mail management
does not accept messages where only the reply-to adress is correct.

I follow your discussion with interest, but there is a point that
I don't understand:

> > I think it would be neat to extend the StringBuffer class, just add
> > getValue()...
> >
> > package org.jdom;
> > public class Text extends StringBuffer {
> >   public String getValue() {
> >     return super.toString();
> >   }
> > }
> >
> > This way we get append() plus all of the other string manipulation calls
> > with little or no more overhead than simply encapsulating a StringBuffer
> > gives.
> The only reason that I didn't do that was to ensure that we aren't
> "hard-wired" to any character based format. This was something Elliotte
> pointed out, that made sense to me. Like even if String wasn't final, I
> wouldn't extend it for the sake of Unicode and so forth...
If the reason for implementing this class is to abstract from the type of
string (i.e. character based or unicode) that you are using, do you manage
it with this class? It seems to me that it's api still depends on String and
implementation, as the parameter values and the return values are still of
type String. So what does it change? I expected something like an
Inheritance Hirarchy or interface construct:

public abstract interface AnyString {

public class CBString implements AnyString {

public class UCString  implements AnyString {


Just a question to understand more ...


More information about the jdom-interest mailing list