[jdom-interest] Text class (Modified)

Brett McLaughlin brett at newInstance.com
Sun May 27 14:42:12 PDT 2001


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




More information about the jdom-interest mailing list