jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r554984 - in /jackrabbit/trunk/contrib/spi: commons/src/main/java/org/apache/jackrabbit/value/ jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/
Date Tue, 10 Jul 2007 15:42:22 GMT
Author: mreutegg
Date: Tue Jul 10 08:42:22 2007
New Revision: 554984

URL: http://svn.apache.org/viewvc?view=rev&rev=554984
Log:
JCR-1018: introduce QValue.getCalendar()

Modified:
    jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/value/QValueFactoryImpl.java
    jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/value/ValueFormat.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ValueConstraint.java

Modified: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/value/QValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/value/QValueFactoryImpl.java?view=diff&rev=554984&r1=554983&r2=554984
==============================================================================
--- jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/value/QValueFactoryImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/value/QValueFactoryImpl.java
Tue Jul 10 08:42:22 2007
@@ -94,7 +94,8 @@
         if (value == null) {
             throw new IllegalArgumentException("Cannot create QValue from null value.");
         }
-        return new QValueImpl(value);
+        // Calendar is not constant, must create a clone
+        return new QValueImpl((Calendar) value.clone());
     }
 
     /**
@@ -181,7 +182,7 @@
         }
 
         private QValueImpl(Calendar value) {
-            val = ISO8601.format(value);
+            val = value;
             type = PropertyType.DATE;
         }
 
@@ -219,7 +220,11 @@
          * @see QValue#getString()
          */
         public String getString() throws RepositoryException {
-            return val.toString();
+            if (type == PropertyType.DATE) {
+                return ISO8601.format((Calendar) val);
+            } else {
+                return val.toString();
+            }
         }
 
         /**
@@ -249,7 +254,11 @@
          * @see QValue#getCalendar()
          */
         public Calendar getCalendar() throws RepositoryException {
-            throw new RuntimeException("implementation missing");
+            if (type == PropertyType.DATE) {
+                return (Calendar) ((Calendar) val).clone();
+            } else {
+                return ISO8601.parse(getString());
+            }
         }
 
         /**

Modified: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/value/ValueFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/value/ValueFormat.java?view=diff&rev=554984&r1=554983&r2=554984
==============================================================================
--- jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/value/ValueFormat.java
(original)
+++ jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/value/ValueFormat.java
Tue Jul 10 08:42:22 2007
@@ -58,6 +58,8 @@
             } catch (IOException e) {
                 throw new RepositoryException(e);
             }
+        } else if (jcrValue.getType() == PropertyType.DATE) {
+            return factory.create(jcrValue.getDate());
         } else {
             return getQValue(jcrValue.getString(), jcrValue.getType(), nsResolver, factory);
         }
@@ -146,7 +148,6 @@
         switch (propertyType) {
             case PropertyType.STRING:
             case PropertyType.BOOLEAN:
-            case PropertyType.DATE:
             case PropertyType.DOUBLE:
             case PropertyType.LONG:
             case PropertyType.REFERENCE:
@@ -172,6 +173,9 @@
                 break;
             case PropertyType.BINARY:
                 jcrValue = factory.createValue(qualifiedValue.getStream());
+                break;
+            case PropertyType.DATE:
+                jcrValue = factory.createValue(qualifiedValue.getCalendar());
                 break;
             default:
                 throw new RepositoryException("illegal internal value type");

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ValueConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ValueConstraint.java?view=diff&rev=554984&r1=554983&r2=554984
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ValueConstraint.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ValueConstraint.java
Tue Jul 10 08:42:22 2007
@@ -605,7 +605,7 @@
         }
         switch (value.getType()) {
             case PropertyType.DATE:
-                check(ISO8601.parse(value.getString()));
+                check(value.getCalendar());
                 return;
 
             default:



Mime
View raw message