[jdom-interest] Text class (Modified)

Matthew Mackenzie matt at xmlglobal.com
Sun May 27 19:13:33 PDT 2001


Actually, toString() should return something like:

[Value: foo; Parent: Mom]


So...

public String toString() {
	return "[Value: " + getValue() + "; Parent: " +
getParent().getName() + "]";
} 

-----Original Message-----
From: skeens [mailto:skeens at mobile.rogers.com] 
Sent: Sunday, May 27, 2001 6:49 PM
To: brett at newInstance.com; jdom-interest at jdom.org
Subject: Re: [jdom-interest] Text class (Modified)


I'm thinking that getValue() is useless. Isn't toString() enough?  They
both do exactly the same thing.  If you decide that it here to stay then
I question whether toString() should be calling getValue() or vice
versa.  I have the feeling that most people will be calling toString()
instead of getValue() to get its internal String value.

--
Steven D. Keens.     mailto:skeens at planetfred.com
Planetfred Inc.        http://www.planetfred.com/ 
-----Original Message-----
From: "Brett McLaughlin" <brett at newInstance.com>
Date: Sun, 27 May 2001 16:42:12 -0500
To: <jdom-interest at jdom.org>
Subject: [jdom-interest] Text class (Modified)

OK. So now we're at:

public class Text {

    private StringBuffer value;
    private Element parent;

    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 Element getParent() {
        return parent;
    }

    protected void setParent(Element parent) {
        this.parent = parent;
    }

    public String toString() {
        return getValue();
    }

    public int hashCode() {
        return value.toString().hashCode();
    }

    public Object clone() {
        Text newText = new Text(value);
        newText.setParent(parent);
    }

    public boolean equals(Object ob) {
        if (ob instanceof Text) {
            if (((Text)ob).value.equals(value)) {
                return true;
            }
        }
        return false;
    }
}

Anything else?

-Brett

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@you
rhost.com
_______________________________________________
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