Author: doogie
Date: Wed Jun 24 20:37:23 2009
New Revision: 788175
URL:
http://svn.apache.org/viewvc?rev=788175&view=revLog:
Helper method for getting an attribute from an element, with default
value processing.
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=788175&r1=788174&r2=788175&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:37:23 2009
@@ -720,6 +720,12 @@
return valueBuffer.toString();
}
+ public static String elementAttribute(Element element, String attrName, String defaultValue) {
+ if (node == null) return defaultValue;
+ String attrValue = element.getAttribute(attrName);
+ return UtilValidate.isNotEmpty(attrValue) attrValue ? defaultValue;
+ }
+
public static String checkEmpty(String string) {
if (string != null && string.length() > 0)
return string;