FW: [jdom-interest] & in namespace
Victor Toni
victor.toni at ebuconnect.de
Thu May 4 02:30:43 PDT 2006
Jason Hunter wrote:
> Sure thing. :) You sent that earlier right? I have a short mail
> folder queue of patches to take.
>
> -jh-
>
As long it's not a LIFO ;-)
Just an update of the previous patch (due to some whitespace issues).
Sorry for the noise.
Victor
> Victor Toni wrote:
>> 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
>>
>>
>> ------------------------------------------------------------------------
>>
>> --- 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;
>> + }
>> }
>>
>> /**
-------------- 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 11:18:17.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