[jdom-interest] Text class

Brett McLaughlin brett at newInstance.com
Sat May 26 17:48:40 PDT 2001


> 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...

Elliotte, any thoughts here?

-Brett

>
> -Matt
>
>
> -----Original Message-----
> From: Brett McLaughlin
> Sent: Sat 5/26/2001 5:03 PM
> To: jdom-interest at jdom.org
> Cc:
> Subject: [jdom-interest] Text class
>
>
>
> Here's where we're at:
>
> public class Text {
>
>     private StringBuffer value;
>
>     protected Text() { }
>
>     public Text(String stringValue) {
>         value = new StringBuffer(stringValue);
>     }
>
>     public String getValue() {
>         return value.toString();
>     }
>
>     public void setValue(String stringValue) {
>         value = new StringBuffer(stringValue);
>     }
>
>     public void append(String stringValue) {
>         value.append(stringValue);
>     }
>
>     public String toString() {
>         return getValue();
>     }
>
>     public int hashCode() {
>         return value.toString().hashCode();
>     }
>
>     // Leaving out impl for now on below here
>     public boolean equals(Object ob);
>
> }
>
> OK. Now we can discuss. What you think?
>
> -Brett
>
> _______________________________________________
> To control your jdom-interest membership:
>
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@you
> rhost.com
>
>
>




More information about the jdom-interest mailing list