[jdom-interest] setAttribute signatures for beta 7

philip.nelson at omniresources.com philip.nelson at omniresources.com
Sun Jun 24 07:20:07 PDT 2001


I would like to see one addition *before* beta 7 is released.  Deprecating
addAttribute is no big deal but having to change all of your addAttribute
calls that were originally defined as 
addAttribute(String, String)
or
addAttribute(String, String, Namespace) 

is a real pain.  We really should have the convienence methods
setAttribute(String name, String value)
and
setAttribute(String name, String value, Namespace ns)

Then changing to setAttribute is a simple search and replace operation.  In
addtition, the api is really better with these methods.  The simple case of
adding an attribute to an element should be no more involved than
specifiying the name and value or optional namespace.

    /**
     * <p>
     * Convienience method to add an attribute to this element 
     * with the given name and value.
     * </p>
     *
     * @param name name of the attribute to add
     * @param value value of the attribute to add
     * @return this element modified
     */
    public Element setAttribute(String name, String value) {
        return setAttribute(new Attribute(name, value));
    }

    /**
     * <p>
     * Convienience method to add an attribute to this element 
     * with the given name, value and namespace.
     * </p>
     *
     * @param name name of the attribute to add
     * @param value value of the attribute to add
     * @param ns Namespace of the attribute to add
     * @return this element modified
     */
    public Element setAttribute(String name, String value, Namespace ns) {
        return setAttribute(new Attribute(name, value, ns));
    }



More information about the jdom-interest mailing list