FW: [jdom-interest] & in namespace
Victor Toni
victor.toni at ebuconnect.de
Wed May 3 16:42:59 PDT 2006
Jason Hunter wrote:
> I'll do a release candidate first, so when that happens you'll know
> it's close.
>
Would you please consider the attached changes for
Element.setAttribute(), too?
Victor
-------------- next part --------------
--- jdom-1.0/org/jdom/Element.java 2004-09-02 23:35:40.000000000 +0200
+++ jdom-attribute/org/jdom/Element.java 2006-05-04 01:36:08.000000000 +0200
@@ -1105,8 +1105,14 @@
* illegal character data (as determined by
* {@link org.jdom.Verifier#checkCharacterData}).
*/
- public Element setAttribute(String name, String value) {
- return setAttribute(new Attribute(name, value));
+ public Element setAttribute(final String name, final String value) {
+ final Attribute attribute = getAttribute(name);
+ if (null == attribute) {
+ return setAttribute(new Attribute(name, value));
+ } else {
+ attribute.setValue(value);
+ return this;
+ }
}
/**
@@ -1128,8 +1134,14 @@
* @throws IllegalAddException if the attribute namespace prefix
* collides with another namespace prefix on the element.
*/
- public Element setAttribute(String name, String value, Namespace ns) {
- return setAttribute(new Attribute(name, value, ns));
+ public Element setAttribute(final String name, final String value, final Namespace ns) {
+ final Attribute attribute = getAttribute(name, ns);
+ if (null == attribute) {
+ return setAttribute(new Attribute(name, value, ns));
+ } else {
+ attribute.setValue(value);
+ return this;
+ }
}
/**
More information about the jdom-interest
mailing list