jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r397933 - /jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/xml/DomUtil.java
Date Fri, 28 Apr 2006 15:51:38 GMT
Author: angela
Date: Fri Apr 28 08:51:36 2006
New Revision: 397933

URL: http://svn.apache.org/viewcvs?rev=397933&view=rev
Log:
DomUtil: add variant of getText that returns a given default value if the specified element
contains no text.

Modified:
    jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/xml/DomUtil.java

Modified: jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/xml/DomUtil.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/xml/DomUtil.java?rev=397933&r1=397932&r2=397933&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/xml/DomUtil.java
(original)
+++ jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/xml/DomUtil.java
Fri Apr 28 08:51:36 2006
@@ -99,6 +99,19 @@
     }
 
     /**
+     * Same as {@link #getText(Element)} except that 'defaultValue' is returned
+     * instead of <code>null</code>, if the element does not contain any text.
+     *
+     * @param element
+     * @param defaultValue
+     * @return
+     */
+    public static String getText(Element element, String defaultValue) {
+        String txt = getText(element);
+        return (txt == null) ? defaultValue : txt;
+    }
+
+    /**
      * Removes leading and trailing whitespace after calling {@link #getText(Element).
      *
      * @param element
@@ -569,7 +582,9 @@
      * @see Document#createElementNS(String, String)
      */
     public static String getPrefixedName(String localName, Namespace namespace) {
-        if (namespace == null || namespace.equals(Namespace.EMPTY_NAMESPACE) || "".equals(namespace.getPrefix()))
{
+        if (namespace == null
+            || Namespace.EMPTY_NAMESPACE.equals(namespace) 
+            || Namespace.EMPTY_NAMESPACE.getPrefix().equals(namespace.getPrefix())) {
             return localName;
         }
         StringBuffer buf = new StringBuffer(namespace.getPrefix());



Mime
View raw message