jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r385509 - /incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java
Date Mon, 13 Mar 2006 11:04:18 GMT
Author: angela
Date: Mon Mar 13 03:04:16 2006
New Revision: 385509

URL: http://svn.apache.org/viewcvs?rev=385509&view=rev
Log:
fixing javadoc 
minor improvement inside constructor

Modified:
    incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java

Modified: incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java?rev=385509&r1=385508&r2=385509&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java
(original)
+++ incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java
Mon Mar 13 03:04:16 2006
@@ -74,37 +74,41 @@
      * object, consisting of {@link #XML_HREF href} <code>Element</code> entries.
      *
      * @param prop
-     * @throws IllegalArgumentException if the property {@link DavProperty#getValue() value}
-     * is not a <code>List</code>.
      */
     public HrefProperty(DavProperty prop) {
         super(prop.getName(), prop.isProtected());
-        ArrayList hrefList = new ArrayList();
-        Object val = prop.getValue();
-        if (val instanceof List) {
-            Iterator it = ((List)val).iterator();
-            while (it.hasNext()) {
-                Object o = it.next();
-                if (o instanceof Element && XML_HREF.equals(((Element)o).getLocalName()))
{
-                    String href = DomUtil.getText((Element)o);
-                    if (href != null) {
-                        hrefList.add(href);
+        if (prop instanceof HrefProperty) {
+            // already an HrefProperty: no parsing required
+            this.value = ((HrefProperty)prop).value;
+        } else {
+            // assume property has be built from xml
+            ArrayList hrefList = new ArrayList();
+            Object val = prop.getValue();
+            if (val instanceof List) {
+                Iterator it = ((List)val).iterator();
+                while (it.hasNext()) {
+                    Object o = it.next();
+                    if (o instanceof Element && XML_HREF.equals(((Element)o).getLocalName()))
{
+                        String href = DomUtil.getText((Element)o);
+                        if (href != null) {
+                            hrefList.add(href);
+                        } else {
+                            log.warn("Valid DAV:href element expected instead of " + o.toString());
+                        }
                     } else {
-                        log.warn("Valid DAV:href element expected instead of " + o.toString());
+                        log.warn("DAV: href element expected in the content of " + getName().toString());
                     }
+                }
+            } else if (val instanceof Element && XML_HREF.equals(((Element)val).getLocalName()))
{
+                String href = DomUtil.getTextTrim((Element)val);
+                if (href != null) {
+                    hrefList.add(href);
                 } else {
-                    log.warn("DAV: href element expected in the content of " + getName().toString());
+                    log.warn("Valid DAV:href element expected instead of " + val.toString());
                 }
             }
-        } else if (val instanceof Element && XML_HREF.equals(((Element)val).getLocalName()))
{
-            String href = DomUtil.getTextTrim((Element)val);
-            if (href != null) {
-                hrefList.add(href);
-            } else {
-                log.warn("Valid DAV:href element expected instead of " + val.toString());
-            }
+            value = (String[]) hrefList.toArray(new String[hrefList.size()]);
         }
-        value = (String[]) hrefList.toArray(new String[hrefList.size()]);
     }
 
     /**



Mime
View raw message