[jdom-interest] minor issue with Comment

philip.nelson at omniresources.com philip.nelson at omniresources.com
Mon Sep 25 20:58:57 PDT 2000


While writing some tests for the test suite I noticed this in Comment.java
which seems a little inconsitent to me.  The constructor for a comment
checks the data for valid data with Verifier but setText doesn't.  Shouldn't
they both do the same thing?

Right now it's

    public Comment(String text) {
        String reason;
        if ((reason = Verifier.checkCommentData(text)) != null) {
            throw new IllegalDataException(text, "comment", reason);
        }

        this.text = text;
    }


    /**
     * <p>
     * This will set the value of the <code>Comment</code>.
     * </p>
     *
     * @param text <code>String</code> text for comment.
     * @return <code>Comment</code> - this Comment modified.
     */
    public Comment setText(String text) {
        this.text = text;
        return this;
    }

But maybe it should be something like ...

    public Comment(String text) {
	setText(text);
    }


    /**
     * <p>
     * This will set the value of the <code>Comment</code>.
     * </p>
     *
     * @param text <code>String</code> text for comment.
     * @return <code>Comment</code> - this Comment modified.
     */
    public Comment setText(String text) {
        String reason;
        if ((reason = Verifier.checkCommentData(text)) != null) {
            throw new IllegalDataException(text, "comment", reason);
        }

        this.text = text;
        return this;
    }

 



More information about the jdom-interest mailing list