boolean setAttribute(String name, String value) {
        if (value == null) {
            return attributes.add(new Attribute(name));
        }
        for (Attribute attribute : attributes) {
            if (attribute.getName().equals(name)) {
                attribute.setValue(value); // update with new value
                return true;
            }
        }
        return attributes.add(new Attribute(name, value));
    }
boolean setAttribute(String name, String value) {
        if (value == null) {
            return attributes.add(new Attribute(name));
        }
        for (Attribute attribute : attributes) {
            if (attribute.getName().equals(name)) {
                attribute.setValue(value); 
                return true;
            }
        }
        return attributes.add(new Attribute(name, value));
    }
boolean setAttribute ( String name , String value ) { if ( value == null ) { return attributes . add ( new Attribute ( name ) ) ; } for ( Attribute attribute : attributes ) { if ( attribute . getName ( ) . equals ( name ) ) { attribute . setValue ( value ) ; // update with new value return true ; } } return attributes . add ( new Attribute ( name , value ) ) ; }
Sets an attribute on an element

@param name  the attribute
@param value the attribute value
Sets an attribute on an element