You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2009/06/24 22:39:32 UTC

svn commit: r788176 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java

Author: doogie
Date: Wed Jun 24 20:39:32 2009
New Revision: 788176

URL: http://svn.apache.org/viewvc?rev=788176&view=rev
Log:
Egg on face, need to be more careful with undoing changes that aren't
ready to be commited.  This actually compiles now. :|

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java?rev=788176&r1=788175&r2=788176&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java Wed Jun 24 20:39:32 2009
@@ -721,9 +721,9 @@
     }
 
     public static String elementAttribute(Element element, String attrName, String defaultValue) {
-        if (node == null) return defaultValue;
+        if (element == null) return defaultValue;
         String attrValue = element.getAttribute(attrName);
-        return UtilValidate.isNotEmpty(attrValue) attrValue ? defaultValue;
+        return UtilValidate.isNotEmpty(attrValue) ? attrValue : defaultValue;
     }
 
     public static String checkEmpty(String string) {



Re: svn commit: r788176 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java

Posted by Adrian Crum <ad...@hlmksw.com>.
I didn't know that. Thanks for the info!

-Adrian

Adam Heath wrote:
> Adrian Crum wrote:
>> My preference would be to change the Element parameter to a Node
>> parameter - that would make the method more flexible.
> 
> Node doesn't have getAttribute(String), only getAttributes(), which
> returns a NamedNodeMap.  That, in turn, is a String->Node mapping, so
> you'd have to get the string value out of the AttrNode.
> 
> Even then, the docs for Node say that getAttributes() returns null for
> all nodes, except Element, so that means that this new method below
> makes no sense for anything but Element.
> 
>> -Adrian
>>
>> doogie@apache.org wrote:
>>> Author: doogie
>>> Date: Wed Jun 24 20:39:32 2009
>>> New Revision: 788176
>>>
>>> URL: http://svn.apache.org/viewvc?rev=788176&view=rev
>>> Log:
>>> Egg on face, need to be more careful with undoing changes that aren't
>>> ready to be commited.  This actually compiles now. :|
>>>
>>> Modified:
>>>     ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java
>>>
>>> Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java
>>> URL:
>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java?rev=788176&r1=788175&r2=788176&view=diff
>>>
>>> ==============================================================================
>>>
>>> --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java
>>> (original)
>>> +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java
>>> Wed Jun 24 20:39:32 2009
>>> @@ -721,9 +721,9 @@
>>>      }
>>>  
>>>      public static String elementAttribute(Element element, String
>>> attrName, String defaultValue) {
>>> -        if (node == null) return defaultValue;
>>> +        if (element == null) return defaultValue;
>>>          String attrValue = element.getAttribute(attrName);
>>> -        return UtilValidate.isNotEmpty(attrValue) attrValue ?
>>> defaultValue;
>>> +        return UtilValidate.isNotEmpty(attrValue) ? attrValue :
>>> defaultValue;
>>>      }
>>>  
>>>      public static String checkEmpty(String string) {
>>>
>>>
>>>
> 
> 

Re: svn commit: r788176 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java

Posted by Adam Heath <do...@brainfood.com>.
Adrian Crum wrote:
> My preference would be to change the Element parameter to a Node
> parameter - that would make the method more flexible.

Node doesn't have getAttribute(String), only getAttributes(), which
returns a NamedNodeMap.  That, in turn, is a String->Node mapping, so
you'd have to get the string value out of the AttrNode.

Even then, the docs for Node say that getAttributes() returns null for
all nodes, except Element, so that means that this new method below
makes no sense for anything but Element.

> 
> -Adrian
> 
> doogie@apache.org wrote:
>> Author: doogie
>> Date: Wed Jun 24 20:39:32 2009
>> New Revision: 788176
>>
>> URL: http://svn.apache.org/viewvc?rev=788176&view=rev
>> Log:
>> Egg on face, need to be more careful with undoing changes that aren't
>> ready to be commited.  This actually compiles now. :|
>>
>> Modified:
>>     ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java
>>
>> Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java?rev=788176&r1=788175&r2=788176&view=diff
>>
>> ==============================================================================
>>
>> --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java
>> (original)
>> +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java
>> Wed Jun 24 20:39:32 2009
>> @@ -721,9 +721,9 @@
>>      }
>>  
>>      public static String elementAttribute(Element element, String
>> attrName, String defaultValue) {
>> -        if (node == null) return defaultValue;
>> +        if (element == null) return defaultValue;
>>          String attrValue = element.getAttribute(attrName);
>> -        return UtilValidate.isNotEmpty(attrValue) attrValue ?
>> defaultValue;
>> +        return UtilValidate.isNotEmpty(attrValue) ? attrValue :
>> defaultValue;
>>      }
>>  
>>      public static String checkEmpty(String string) {
>>
>>
>>


Re: svn commit: r788176 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java

Posted by Adrian Crum <ad...@hlmksw.com>.
My preference would be to change the Element parameter to a Node 
parameter - that would make the method more flexible.

-Adrian

doogie@apache.org wrote:
> Author: doogie
> Date: Wed Jun 24 20:39:32 2009
> New Revision: 788176
> 
> URL: http://svn.apache.org/viewvc?rev=788176&view=rev
> Log:
> Egg on face, need to be more careful with undoing changes that aren't
> ready to be commited.  This actually compiles now. :|
> 
> Modified:
>     ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java
> 
> Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java?rev=788176&r1=788175&r2=788176&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java (original)
> +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java Wed Jun 24 20:39:32 2009
> @@ -721,9 +721,9 @@
>      }
>  
>      public static String elementAttribute(Element element, String attrName, String defaultValue) {
> -        if (node == null) return defaultValue;
> +        if (element == null) return defaultValue;
>          String attrValue = element.getAttribute(attrName);
> -        return UtilValidate.isNotEmpty(attrValue) attrValue ? defaultValue;
> +        return UtilValidate.isNotEmpty(attrValue) ? attrValue : defaultValue;
>      }
>  
>      public static String checkEmpty(String string) {
> 
> 
>