My preference would be to change the Element parameter to a Node
parameter - that would make the method more flexible. -Adrian [hidden email] 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) { > > > |
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 > > [hidden email] 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) { >> >> >> |
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 >> >> [hidden email] 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) { >>> >>> >>> > > |
Free forum by Nabble | Edit this page |