jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r587899 - in /jackrabbit/trunk: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/value/ jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/
Date Wed, 24 Oct 2007 14:39:16 GMT
Author: reschke
Date: Wed Oct 24 07:39:14 2007
New Revision: 587899

URL: http://svn.apache.org/viewvc?rev=587899&view=rev
Log:
JCR-1151: add QValue.getLong()/getDouble() and matching factory methods in QValueFactory.

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

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ValueConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ValueConstraint.java?rev=587899&r1=587898&r2=587899&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ValueConstraint.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ValueConstraint.java
Wed Oct 24 07:39:14 2007
@@ -463,11 +463,11 @@
         }
         switch (value.getType()) {
             case PropertyType.LONG:
-                check(Long.parseLong(value.getString()));
+                check(value.getLong());
                 return;
 
             case PropertyType.DOUBLE:
-                check(Double.parseDouble(value.getString()));
+                check(value.getDouble());
                 return;
 
             case PropertyType.BINARY:

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/value/QValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/value/QValueFactoryImpl.java?rev=587899&r1=587898&r2=587899&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/value/QValueFactoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/value/QValueFactoryImpl.java
Wed Oct 24 07:39:14 2007
@@ -106,6 +106,20 @@
     }
 
     /**
+     * @see QValueFactory#create(double)
+     */
+    public QValue create(double value) {
+        return new QValueImpl(Double.valueOf(value));
+    }
+
+    /**
+     * @see QValueFactory#create(long)
+     */
+    public QValue create(long value) {
+        return new QValueImpl(Long.valueOf(value));
+    }
+
+    /**
      * @see QValueFactory#create(Name)
      */
     public QValue create(Name value) {
@@ -265,6 +279,28 @@
         }
 
         /**
+         * @see QValue#getDouble()
+         */
+        public double getDouble() throws RepositoryException {
+            if (type == PropertyType.DOUBLE) {
+                return ((Double) val).doubleValue();
+            } else {
+                return Double.parseDouble(getString());
+            }
+        }
+
+        /**
+         * @see QValue#getLong()
+         */
+        public long getLong() throws RepositoryException {
+            if (type == PropertyType.LONG) {
+                return ((Long) val).longValue();
+            } else {
+                return Long.parseLong(getString());
+            }
+        }
+
+        /**
          * @see QValue#getPath()
          */
         public Path getPath() throws RepositoryException {
@@ -610,6 +646,20 @@
          */
         public Calendar getCalendar() throws RepositoryException {
            throw new UnsupportedOperationException();
+        }
+
+        /**
+         * @see QValue#getDouble()
+         */
+        public double getDouble() throws RepositoryException {
+            return Double.parseDouble(getString());
+        }
+
+        /**
+         * @see QValue#getLong()
+         */
+        public long getLong() throws RepositoryException {
+            return Long.parseLong(getString());
         }
 
         /**

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/value/ValueFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/value/ValueFormat.java?rev=587899&r1=587898&r2=587899&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/value/ValueFormat.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/value/ValueFormat.java
Wed Oct 24 07:39:14 2007
@@ -57,6 +57,10 @@
             }
         } else if (jcrValue.getType() == PropertyType.DATE) {
             return factory.create(jcrValue.getDate());
+        } else if (jcrValue.getType() == PropertyType.DOUBLE) {
+            return factory.create(jcrValue.getDouble());
+        } else if (jcrValue.getType() == PropertyType.LONG) {
+            return factory.create(jcrValue.getLong());
         } else {
             return getQValue(jcrValue.getString(), jcrValue.getType(), resolver, factory);
         }
@@ -146,8 +150,6 @@
         switch (propertyType) {
             case PropertyType.STRING:
             case PropertyType.BOOLEAN:
-            case PropertyType.DOUBLE:
-            case PropertyType.LONG:
             case PropertyType.REFERENCE:
                 jcrValue = factory.createValue(qualifiedValue.getString(), propertyType);
                 break;
@@ -164,6 +166,12 @@
                 break;
             case PropertyType.DATE:
                 jcrValue = factory.createValue(qualifiedValue.getCalendar());
+                break;
+            case PropertyType.DOUBLE:
+              jcrValue = factory.createValue(qualifiedValue.getDouble());
+              break;
+            case PropertyType.LONG:
+                jcrValue = factory.createValue(qualifiedValue.getLong());
                 break;
             default:
                 throw new RepositoryException("illegal internal value type");

Modified: jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QValue.java?rev=587899&r1=587898&r2=587899&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QValue.java (original)
+++ jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QValue.java Wed
Oct 24 07:39:14 2007
@@ -83,20 +83,36 @@
     public InputStream getStream() throws RepositoryException;
 
     /**
-     * Returns a <code>Name</code> representation of this value.
+     * Returns a <code>Calendar</code> representation of this value.
      *
-     * @return A <code>Name</code> representation of this value.
+     * @return A <code>Calendar</code> representation of this value.
      * @throws RepositoryException if an error occurs.
      */
-    public Name getName() throws RepositoryException;
+    public Calendar getCalendar() throws RepositoryException;
 
     /**
-     * Returns a <code>Calendar</code> representation of this value.
+     * Returns a <code>double</code> representation of this value.
      *
-     * @return A <code>Calendar</code> representation of this value.
+     * @return A <code>double</code> representation of this value.
      * @throws RepositoryException if an error occurs.
      */
-    public Calendar getCalendar() throws RepositoryException;
+    public double getDouble() throws RepositoryException;
+
+    /**
+     * Returns a <code>long</code> representation of this value.
+     *
+     * @return A <code>long</code> representation of this value.
+     * @throws RepositoryException if an error occurs.
+     */
+    public long getLong() throws RepositoryException;
+
+    /**
+     * Returns a <code>Name</code> representation of this value.
+     *
+     * @return A <code>Name</code> representation of this value.
+     * @throws RepositoryException if an error occurs.
+     */
+    public Name getName() throws RepositoryException;
 
     /**
      * Returns a <code>Path</code> representation of this value.

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=587899&r1=587898&r2=587899&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
Wed Oct 24 07:39:14 2007
@@ -51,6 +51,24 @@
     public QValue create(Calendar value);
 
     /**
+     * Create a new <code>QValue</code> with type {@link javax.jcr.PropertyType#DOUBLE}.
+     *
+     * @param value A <code>double</code> containing the value
+     * of the new <code>QValue</code>.
+     * @return a new <code>QValue</code>.
+     */
+    public QValue create(double value);
+
+    /**
+     * Create a new <code>QValue</code> with type {@link javax.jcr.PropertyType#LONG}.
+     *
+     * @param value A <code>long</code> containing the value
+     * of the new <code>QValue</code>.
+     * @return a new <code>QValue</code>.
+     */
+    public QValue create(long value);
+
+    /**
      * Create a new <code>QValue</code> with type {@link javax.jcr.PropertyType#NAME}.
      *
      * @param value A non-null <code>Name</code>.



Mime
View raw message