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:37:24 UTC

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

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;