jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r779590 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/c...
Date Thu, 28 May 2009 13:03:46 GMT
Author: stefan
Date: Thu May 28 13:03:45 2009
New Revision: 779590

URL: http://svn.apache.org/viewvc?rev=779590&view=rev
Log:
JCR-1609:  new Property Types (WIP...)



Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValueFactory.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/QValueFactoryLogger.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java
    jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QValueFactory.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/QValueFactoryImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValueFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValueFactory.java?rev=779590&r1=779589&r2=779590&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValueFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValueFactory.java
Thu May 28 13:03:45 2009
@@ -133,6 +133,14 @@
         return InternalValue.create(value);
     }
 
+    public QValue create(URI value) throws RepositoryException {
+        return InternalValue.create(value);
+    }
+
+    public QValue create(BigDecimal value) throws RepositoryException {
+        return InternalValue.create(value);
+    }
+
     public QValue create(byte[] value) throws RepositoryException {
         return InternalValue.create(value);
     }

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/QValueFactoryLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/QValueFactoryLogger.java?rev=779590&r1=779589&r2=779590&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/QValueFactoryLogger.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/QValueFactoryLogger.java
Thu May 28 13:03:45 2009
@@ -20,6 +20,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Calendar;
+import java.net.URI;
+import java.math.BigDecimal;
 
 import javax.jcr.RepositoryException;
 
@@ -102,6 +104,20 @@
             }}, "create(Path)", new Object[]{value});
     }
 
+    public QValue create(final URI value) throws RepositoryException {
+        return (QValue) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return qValueFactory.create(value);
+            }}, "create(URI)", new Object[]{value});
+    }
+
+    public QValue create(final BigDecimal value) throws RepositoryException {
+        return (QValue) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return qValueFactory.create(value);
+            }}, "create(BigDecimal)", new Object[]{value});
+    }
+
     public QValue create(final byte[] value) throws RepositoryException {
         return (QValue) execute(new Callable() {
             public Object call() throws RepositoryException {

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java?rev=779590&r1=779589&r2=779590&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java
Thu May 28 13:03:45 2009
@@ -209,7 +209,7 @@
             return cal;
         } else if (type == PropertyType.LONG) {
             Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+00:00"));
-            cal.setTimeInMillis(((Long) val).longValue());
+            cal.setTimeInMillis((Long) val);
             return cal;
         } else if (type == PropertyType.DECIMAL) {
             Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+00:00"));
@@ -231,6 +231,12 @@
     public BigDecimal getDecimal() throws RepositoryException {
         if (type == PropertyType.DECIMAL) {
             return (BigDecimal) val;
+        } else if (type == PropertyType.DOUBLE) {
+            return new BigDecimal((Double) val);
+        } else if (type == PropertyType.LONG) {
+            return new BigDecimal((Long) val);
+        } else if (type == PropertyType.DATE) {
+            return new BigDecimal(((Calendar) val).getTimeInMillis());
         } else {
             try {
                 return new BigDecimal(getString());
@@ -260,7 +266,9 @@
      */
     public double getDouble() throws RepositoryException {
         if (type == PropertyType.DOUBLE) {
-            return ((Double) val).doubleValue();
+            return (Double) val;
+        } else if (type == PropertyType.LONG) {
+            return ((Long) val).doubleValue();
         } else if (type == PropertyType.DATE) {
             return ((Calendar) val).getTimeInMillis();
         } else if (type == PropertyType.DECIMAL) {
@@ -279,7 +287,7 @@
      */
     public long getLong() throws RepositoryException {
         if (type == PropertyType.LONG) {
-            return ((Long) val).longValue();
+            return (Long) val;
         } else if (type == PropertyType.DOUBLE) {
             return ((Double) val).longValue();
         } else if (type == PropertyType.DECIMAL) {

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java?rev=779590&r1=779589&r2=779590&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java
Thu May 28 13:03:45 2009
@@ -85,12 +85,17 @@
                     return new QValueImpl(Double.valueOf(value));
                 case PropertyType.LONG:
                     return new QValueImpl(Long.valueOf(value));
+                case PropertyType.DECIMAL:
+                    return new QValueImpl(new BigDecimal(value));
+                case PropertyType.URI:
+                    return new QValueImpl(URI.create(value));
                 case PropertyType.PATH:
                     return new QValueImpl(PATH_FACTORY.create(value));
                 case PropertyType.NAME:
                     return new QValueImpl(NAME_FACTORY.create(value));
                 case PropertyType.STRING:
                 case PropertyType.REFERENCE:
+                case PropertyType.WEAKREFERENCE:
                     return new QValueImpl(value, type);
                 case PropertyType.BINARY:
                     return new BinaryQValue(value.getBytes(DEFAULT_ENCODING));
@@ -164,6 +169,26 @@
     }
 
     /**
+     * @see QValueFactory#create(URI)
+     */
+    public QValue create(URI value) {
+        if (value == null) {
+            throw new IllegalArgumentException("Cannot create QValue from null value.");
+        }
+        return new QValueImpl(value);
+    }
+
+    /**
+     * @see QValueFactory#create(URI)
+     */
+    public QValue create(BigDecimal value) {
+        if (value == null) {
+            throw new IllegalArgumentException("Cannot create QValue from null value.");
+        }
+        return new QValueImpl(value);
+    }
+
+    /**
      * @see QValueFactory#create(byte[])
      */
     public QValue create(byte[] value) {
@@ -222,6 +247,10 @@
             super(value);
         }
 
+        private QValueImpl(BigDecimal value) {
+            super(value);
+        }
+
         private QValueImpl(Boolean value) {
             super(value);
         }
@@ -234,6 +263,10 @@
             super(value);
         }
 
+        private QValueImpl(URI value) {
+            super(value);
+        }
+
         //---------------------------------------------------------< QValue >---
         /**
          * @see QValue#getString()

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java?rev=779590&r1=779589&r2=779590&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java
Thu May 28 13:03:45 2009
@@ -94,8 +94,16 @@
      * @see javax.jcr.Value#getDecimal()
      */
     public BigDecimal getDecimal() throws ValueFormatException, IllegalStateException, RepositoryException
{
-        // TODO
-        throw new RuntimeException("Not implemented yet, see JCR-1609");
+        setValueConsumed();
+        switch (getType()) {
+            case PropertyType.DECIMAL:
+            case PropertyType.DOUBLE:
+            case PropertyType.LONG:
+            case PropertyType.DATE:
+                return qvalue.getDecimal();
+            default:
+                throw new ValueFormatException("incompatible type " + PropertyType.nameFromValue(qvalue.getType()));
+        }
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java?rev=779590&r1=779589&r2=779590&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java
Thu May 28 13:03:45 2009
@@ -165,8 +165,7 @@
      * {@inheritDoc}
      */
     public Value createValue(Node value) throws RepositoryException {
-        QValue qvalue = qfactory.create(value.getUUID(), PropertyType.REFERENCE);
-        return new QValueValue(qvalue, resolver);
+        return createValue(value, false);
     }
 
     /**
@@ -211,12 +210,16 @@
     }
 
     public Value createValue(BigDecimal value) {
-        // TODO
-        throw new RuntimeException("Not implemented yet, see JCR-1609");
+        try {
+            QValue qvalue = qfactory.create(value);
+            return new QValueValue(qvalue, resolver);
+        } catch (RepositoryException ex) {
+            throw new RuntimeException(ex);
+        }
     }
 
     public Value createValue(Node value, boolean weak) throws RepositoryException {
-        // TODO
-        throw new RuntimeException("Not implemented yet, see JCR-1609");
+        QValue qvalue = qfactory.create(value.getUUID(), weak ? PropertyType.WEAKREFERENCE
: PropertyType.REFERENCE);
+        return new QValueValue(qvalue, resolver);
     }
 }

Modified: jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QValueFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QValueFactory.java?rev=779590&r1=779589&r2=779590&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QValueFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QValueFactory.java
Thu May 28 13:03:45 2009
@@ -20,6 +20,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Calendar;
+import java.math.BigDecimal;
+import java.net.URI;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.ValueFormatException;
@@ -97,6 +99,21 @@
      */
     public QValue create(Path value) throws RepositoryException;
 
+    /**
+     * Create a new <code>QValue</code> with type {@link javax.jcr.PropertyType#DECIMAL}.
+     *
+     * @param value A non-null <code>BigDecimal</code>.
+     * @return a new <code>QValue</code>.
+     */
+    public QValue create(BigDecimal value) throws RepositoryException;
+
+    /**
+     * Create a new <code>QValue</code> with type {@link javax.jcr.PropertyType#URI}.
+     *
+     * @param value A non-null <code>URI</code>.
+     * @return a new <code>QValue</code>.
+     */
+    public QValue create(URI value) throws RepositoryException;
 
     /**
      * Create a new <code>QValue</code> with type {@link javax.jcr.PropertyType#BINARY}.

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/QValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/QValueFactoryImpl.java?rev=779590&r1=779589&r2=779590&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/QValueFactoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/QValueFactoryImpl.java
Thu May 28 13:03:45 2009
@@ -137,9 +137,14 @@
                     return new QValueImpl(NAME_FACTORY.create(value));
                 case PropertyType.STRING:
                 case PropertyType.REFERENCE:
+                case PropertyType.WEAKREFERENCE:
                     return new QValueImpl(value, type);
                 case PropertyType.BINARY:
                     return new BinaryQValue(value.getBytes(DEFAULT_ENCODING));
+                case PropertyType.DECIMAL:
+                case PropertyType.URI:
+                    // TODO implement
+                    throw new UnsupportedOperationException("Not implemented yet, see JCR-1609:
new Property Types");
             }
         } catch (IllegalArgumentException ex) {
             // given String value cannot be converted to Long/Double/Path/Name
@@ -185,6 +190,22 @@
     }
 
     /**
+     * @see QValueFactory#create(URI)
+     */
+    public QValue create(URI value) {
+        // TODO implement
+        throw new UnsupportedOperationException("Not implemented yet, see JCR-1609: new Property
Types");
+    }
+
+    /**
+     * @see QValueFactory#create(BigDecimal)
+     */
+    public QValue create(BigDecimal value) {
+        // TODO implement
+        throw new UnsupportedOperationException("Not implemented yet, see JCR-1609: new Property
Types");
+    }
+
+    /**
      * @see QValueFactory#create(Name)
      */
     public QValue create(Name value) {



Mime
View raw message