You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2008/08/05 23:57:18 UTC

svn commit: r682984 - /incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrPropertyMap.java

Author: fmeschbe
Date: Tue Aug  5 14:57:18 2008
New Revision: 682984

URL: http://svn.apache.org/viewvc?rev=682984&view=rev
Log:
SLING-600 Fix value conversion in case of default values of
an implementation of Calendar and Value

Modified:
    incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrPropertyMap.java

Modified: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrPropertyMap.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrPropertyMap.java?rev=682984&r1=682983&r2=682984&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrPropertyMap.java (original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrPropertyMap.java Tue Aug  5 14:57:18 2008
@@ -72,7 +72,16 @@
             return (T) get(name);
         }
 
-        T value = get(name, (Class<T>) defaultValue.getClass());
+        // special handling in case the default value implements one
+        // of the interface types supported by the convertToType method
+        Class<T> type = (Class<T>) defaultValue.getClass();
+        if (Calendar.class.isAssignableFrom(type)) {
+            type = (Class<T>) Calendar.class;
+        } else if (Value.class.isAssignableFrom(type)) {
+            type = (Class<T>) Value.class;
+        }
+
+        T value = get(name, type);
         if (value == null) {
             value = defaultValue;
         }
@@ -137,6 +146,7 @@
             return "";
         }
     }
+
     // ---------- Helpers to access the node's property ------------------------
 
     private Object read(String key) {