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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

doogie-3
Author: doogie
Date: Wed Jun 24 20:37:23 2009
New Revision: 788175

URL: http://svn.apache.org/viewvc?rev=788175&view=rev
Log:
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;