jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r776687 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ j...
Date Wed, 20 May 2009 13:08:10 GMT
Author: stefan
Date: Wed May 20 13:08:09 2009
New Revision: 776687

URL: http://svn.apache.org/viewvc?rev=776687&view=rev
Log:
JCR-1609:  new Property Types (WIP...)
JCR-2061: References and Dereferencing of Property Values (WIP...)


Added:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DecimalValue.java
      - copied, changed from r775860, jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DoubleValue.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/URIValue.java
      - copied, changed from r775860, jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/PathValue.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/WeakReferenceValue.java
      - copied, changed from r775860, jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ReferenceValue.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ValueConstraint.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValueFactory.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BaseValue.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueFactoryImpl.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.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/src/main/java/org/apache/jackrabbit/spi/QValue.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=776687&r1=776686&r2=776687&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java Wed May 20 13:08:09 2009
@@ -47,6 +47,8 @@
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
 import javax.jcr.lock.Lock;
 import javax.jcr.lock.LockException;
 import javax.jcr.lock.LockManager;
@@ -1692,16 +1694,6 @@
         return prop;
     }
 
-    public Property setProperty(String name, BigDecimal value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
-        // TODO
-        throw new RuntimeException("Not implemented yet, see JCR-1609");
-    }
-
-    public Property setProperty(String name, Binary value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
-        // TODO
-        throw new RuntimeException("Not implemented yet, see JCR-1609");
-    }
-
     /**
      * @see ItemImpl#getQName()
      */
@@ -4536,16 +4528,14 @@
 
     //--------------------------------------------------< new JSR 283 methods >
     /**
-     * @see javax.jcr.Node#getIdentifier()
-     * @since JCR 2.0
+     * {@inheritDoc}
      */
     public String getIdentifier() throws RepositoryException {
         return ((NodeId) id).toString();
     }
 
     /**
-     * @see javax.jcr.Node#getReferences(String)
-     * @since JCR 2.0
+     * {@inheritDoc}
      */
     public PropertyIterator getReferences(String name)
             throws RepositoryException {
@@ -4587,26 +4577,55 @@
     }
 
     /**
-     * @see javax.jcr.Node#getWeakReferences()
-     * @since JCR 2.0
+     * {@inheritDoc}
      */
     public PropertyIterator getWeakReferences() throws RepositoryException {
-        // TODO
-        throw new RuntimeException("Not implemented yet, see JCR-2061");
+        return getWeakReferences(null);
     }
 
     /**
-     * @see javax.jcr.Node#getWeakReferences(String)
-     * @since JCR 2.0
+     * {@inheritDoc}
      */
     public PropertyIterator getWeakReferences(String name) throws RepositoryException {
-        // TODO
-        throw new RuntimeException("Not implemented yet, see JCR-2061");
+        // check state of this instance
+        sanityCheck();
+
+        try {
+            Query q = session.getWorkspace().getQueryManager().createQuery(
+                    "//*[jcr:contains[., '" + data.getId() + "']",
+                    Query.XPATH);
+            QueryResult result = q.execute();
+            ArrayList l = new ArrayList<Property>();
+            for (NodeIterator nit = result.getNodes(); nit.hasNext(); ) {
+                Node n = nit.nextNode();
+                for (PropertyIterator pit = n.getProperties(); pit.hasNext(); ) {
+                    Property p = pit.nextProperty();
+                    if (p.getType() == PropertyType.WEAKREFERENCE
+                            && p.getString().equals(getIdentifier())) {
+                        if (name != null) {
+                            if (name.equals(p.getName())) {
+                                l.add(p);
+                            }
+                        } else {
+                            l.add(p);
+                        }
+                    }
+                }
+            }
+            if (l.isEmpty()) {
+                return PropertyIteratorAdapter.EMPTY;
+            } else {
+                return new PropertyIteratorAdapter(l);
+            }
+        } catch (RepositoryException e) {
+            String msg = "Unable to retrieve WEAKREFERENCE properties that refer to " + id;
+            log.debug(msg);
+            throw new RepositoryException(msg, e);
+        }
     }
 
     /**
-     * @see javax.jcr.Node#getNodes(String[])
-     * @since JCR 2.0
+     * {@inheritDoc}
      */
     public NodeIterator getNodes(String[] nameGlobs)
             throws RepositoryException {
@@ -4620,8 +4639,7 @@
     }
 
     /**
-     * @see javax.jcr.Node#getProperties(String[])
-     * @since JCR 2.0
+     * {@inheritDoc}
      */
     // TODO rename method to 'getProperties' once JCR 2.0 api has been fixed
     public PropertyIterator getProperty(String[]
@@ -4637,8 +4655,7 @@
     }
 
     /**
-     * @see javax.jcr.Node#setPrimaryType(String) 
-     * @since JCR 2.0
+     * {@inheritDoc}
      */
     public void setPrimaryType(String nodeTypeName)
             throws NoSuchNodeTypeException, VersionException,
@@ -4845,6 +4862,62 @@
         }
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    public Property setProperty(String name, BigDecimal value)
+            throws ValueFormatException, VersionException, LockException,
+            ConstraintViolationException, RepositoryException {
+        // check state of this instance
+        sanityCheck();
+
+        // check pre-conditions for setting property
+        checkSetProperty();
+
+        BitSet status = new BitSet();
+        PropertyImpl prop = getOrCreateProperty(
+                name, PropertyType.DECIMAL, false, false, status);
+        try {
+            prop.setValue(value);
+        } catch (RepositoryException re) {
+            if (status.get(CREATED)) {
+                // setting value failed, get rid of newly created property
+                removeChildProperty(name);
+            }
+            // rethrow
+            throw re;
+        }
+        return prop;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Property setProperty(String name, Binary value)
+            throws ValueFormatException, VersionException, LockException,
+            ConstraintViolationException, RepositoryException {
+        // check state of this instance
+        sanityCheck();
+
+        // check pre-conditions for setting property
+        checkSetProperty();
+
+        BitSet status = new BitSet();
+        PropertyImpl prop = getOrCreateProperty(
+                name, PropertyType.BINARY, false, false, status);
+        try {
+            prop.setValue(value);
+        } catch (RepositoryException re) {
+            if (status.get(CREATED)) {
+                // setting value failed, get rid of newly created property
+                removeChildProperty(name);
+            }
+            // rethrow
+            throw re;
+        }
+        return prop;
+    }
+
     // TODO: JCR-1565 JSR 283 lifecycle management
     public String[] getAllowedLifecycleTransistions()
             throws RepositoryException {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java?rev=776687&r1=776686&r2=776687&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java Wed May 20 13:08:09 2009
@@ -195,6 +195,9 @@
             case PropertyType.DATE:
             case PropertyType.REFERENCE:
             case PropertyType.BOOLEAN:
+            case PropertyType.DECIMAL:
+            case PropertyType.URI:
+            case PropertyType.WEAKREFERENCE:
                 return value.toString().length();
 
             case PropertyType.NAME:

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ValueConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ValueConstraint.java?rev=776687&r1=776686&r2=776687&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ValueConstraint.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ValueConstraint.java Wed May 20 13:08:09 2009
@@ -87,6 +87,7 @@
         }
         switch (type) {
             case PropertyType.STRING:
+            case PropertyType.URI:
                 return new StringConstraint(definition);
 
             case PropertyType.BOOLEAN:
@@ -100,6 +101,7 @@
 
             case PropertyType.LONG:
             case PropertyType.DOUBLE:
+            case PropertyType.DECIMAL:
                 return new NumericConstraint(definition);
 
             case PropertyType.NAME:
@@ -108,6 +110,7 @@
             case PropertyType.PATH:
                 return new PathConstraint(definition, resolver);
 
+            case PropertyType.WEAKREFERENCE:
             case PropertyType.REFERENCE:
                 return new ReferenceConstraint(definition, resolver);
 
@@ -301,13 +304,13 @@
     void check(double number) throws ConstraintViolationException {
         if (lowerLimit != null) {
             if (lowerInclusive) {
-                if (number < lowerLimit.doubleValue()) {
+                if (number < lowerLimit) {
                     throw new ConstraintViolationException(number
                             + " does not satisfy the constraint '"
                             + definition + "'");
                 }
             } else {
-                if (number <= lowerLimit.doubleValue()) {
+                if (number <= lowerLimit) {
                     throw new ConstraintViolationException(number
                             + " does not satisfy the constraint '"
                             + definition + "'");
@@ -316,13 +319,13 @@
         }
         if (upperLimit != null) {
             if (upperInclusive) {
-                if (number > upperLimit.doubleValue()) {
+                if (number > upperLimit) {
                     throw new ConstraintViolationException(number
                             + " does not satisfy the constraint '"
                             + definition + "'");
                 }
             } else {
-                if (number >= upperLimit.doubleValue()) {
+                if (number >= upperLimit) {
                     throw new ConstraintViolationException(number
                             + " does not satisfy the constraint '"
                             + definition + "'");
@@ -345,6 +348,10 @@
                 check(value.getDouble());
                 return;
 
+            case PropertyType.DECIMAL:
+                check(value.getDouble());
+                return;
+
             case PropertyType.BINARY:
                 BLOBFileValue blob = value.getBLOBFileValue();
                 long length = blob.getLength();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java?rev=776687&r1=776686&r2=776687&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java Wed May 20 13:08:09 2009
@@ -40,6 +40,7 @@
 import java.io.InputStream;
 import java.util.HashSet;
 import java.util.Set;
+import java.math.BigDecimal;
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
@@ -383,6 +384,9 @@
                 case PropertyType.DOUBLE:
                     val = InternalValue.create(in.readDouble());
                     break;
+                case PropertyType.DECIMAL:
+                    val = InternalValue.create(readDecimal(in));
+                    break;
                 case PropertyType.LONG:
                     val = InternalValue.create(in.readLong());
                     break;
@@ -392,6 +396,7 @@
                 case PropertyType.NAME:
                     val = InternalValue.create(readQName(in));
                     break;
+                case PropertyType.WEAKREFERENCE:
                 case PropertyType.REFERENCE:
                     val = InternalValue.create(readUUID(in));
                     break;
@@ -505,6 +510,15 @@
                         return false;
                     }
                     break;
+                case PropertyType.DECIMAL:
+                    try {
+                        BigDecimal d = readDecimal(in);
+                        log.debug("  decimal: " + d);
+                    } catch (IOException e) {
+                        log.error("Error while reading decimal value: " + e);
+                        return false;
+                    }
+                    break;
                 case PropertyType.LONG:
                     try {
                         double l = in.readLong();
@@ -532,6 +546,7 @@
                         return false;
                     }
                     break;
+                case PropertyType.WEAKREFERENCE:
                 case PropertyType.REFERENCE:
                     try {
                         UUID uuid = readUUID(in);
@@ -673,6 +688,14 @@
                         throw new IOException("Unexpected error while writing DOUBLE value.");
                     }
                     break;
+                case PropertyType.DECIMAL:
+                    try {
+                        writeDecimal(out, val.getDecimal());
+                    } catch (RepositoryException e) {
+                        // should never occur
+                        throw new IOException("Unexpected error while writing DECIMAL value.");
+                    }
+                    break;
                 case PropertyType.LONG:
                     try {
                         out.writeLong(val.getLong());
@@ -692,6 +715,7 @@
                 case PropertyType.NAME:
                     writeQName(out, val.getQName());
                     break;
+                case PropertyType.WEAKREFERENCE:
                 case PropertyType.REFERENCE:
                     writeUUID(out, val.getUUID());
                     break;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java?rev=776687&r1=776686&r2=776687&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java Wed May 20 13:08:09 2009
@@ -38,6 +38,7 @@
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
+import java.math.BigDecimal;
 
 /**
  * This Class implements relatively efficient serialization methods for item
@@ -316,6 +317,37 @@
     }
 
     /**
+     * Deserializes a BigDecimal
+     * @param in the input stream
+     * @return the decimal
+     * @throws IOException in an I/O error occurs.
+     */
+    public BigDecimal readDecimal(DataInputStream in) throws IOException {
+        if (in.readBoolean()) {
+            // TODO more efficient serialization format
+            return new BigDecimal(in.readUTF());
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Serializes a BigDecimal
+     * @param out the output stream
+     * @param decimal the decimal number
+     * @throws IOException in an I/O error occurs.
+     */
+    public void writeDecimal(DataOutputStream out, BigDecimal decimal) throws IOException {
+        if (decimal == null) {
+            out.writeBoolean(false);
+        } else {
+            out.writeBoolean(true);
+            // TODO more efficient serialization format
+            out.writeUTF(decimal.toString());
+        }
+    }
+
+    /**
      * Deserializes a NodeID
      * @param in the input stream
      * @return the uuid

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java?rev=776687&r1=776686&r2=776687&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java Wed May 20 13:08:09 2009
@@ -21,6 +21,7 @@
 import java.util.Calendar;
 import java.util.Iterator;
 import java.util.List;
+import java.math.BigDecimal;
 
 import javax.jcr.NamespaceException;
 import javax.jcr.PropertyType;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java?rev=776687&r1=776686&r2=776687&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java Wed May 20 13:08:09 2009
@@ -29,6 +29,7 @@
 import org.apache.jackrabbit.util.ISO8601;
 import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.value.StringValue;
+import org.apache.jackrabbit.value.URIValue;
 import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl;
@@ -49,6 +50,9 @@
 import java.io.SequenceInputStream;
 import java.io.UnsupportedEncodingException;
 import java.util.Calendar;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.math.BigDecimal;
 
 /**
  * <code>InternalValue</code> represents the internal format of a property value.
@@ -64,6 +68,8 @@
  * <tr>BOOLEAN<td></td><td>Boolean</td></tr>
  * <tr>NAME<td></td><td>Name</td></tr>
  * <tr>PATH<td></td><td>Path</td></tr>
+ * <tr>URI<td></td><td>URI</td></tr>
+ * <tr>DECIMAL<td></td><td>BigDecimal</td></tr>
  * <tr>BINARY<td></td><td>BLOBFileValue</td></tr>
  * <tr>REFERENCE<td></td><td>UUID</td></tr>
  * </table>
@@ -152,10 +158,20 @@
                 return create(value.getDate());
             case PropertyType.DOUBLE:
                 return create(value.getDouble());
+            case PropertyType.DECIMAL:
+                return create(value.getDecimal());
             case PropertyType.LONG:
                 return create(value.getLong());
             case PropertyType.REFERENCE:
                 return create(new UUID(value.getString()));
+            case PropertyType.WEAKREFERENCE:
+                return create(new UUID(value.getString()), true);
+            case PropertyType.URI:
+                try {
+                    return create(new URI(value.getString()));
+                } catch (URISyntaxException e) {
+                    throw new ValueFormatException(e.getMessage());
+                }
             case PropertyType.NAME:
                 try {
                     if (value instanceof QValueValue) {
@@ -229,6 +245,22 @@
      * @param value
      * @return the created value
      */
+    public static InternalValue create(BigDecimal value) {
+        return new InternalValue(value);
+    }
+
+    /**
+     * @param value
+     * @return the created value
+     */
+    public static InternalValue create(URI value) {
+        return new InternalValue(value);
+    }
+
+    /**
+     * @param value
+     * @return the created value
+     */
     public static InternalValue create(boolean value) {
         return value ? BOOLEAN_TRUE : BOOLEAN_FALSE;
     }
@@ -376,7 +408,16 @@
      * @return the created value
      */
     public static InternalValue create(UUID value) {
-        return new InternalValue(value);
+        return create(value, false);
+    }
+
+    /**
+     * @param value
+     * @param weak
+     * @return the created value
+     */
+    public static InternalValue create(UUID value, boolean weak) {
+        return new InternalValue(value, weak);
     }
 
     //----------------------------------------------------< conversions, etc. >
@@ -409,8 +450,14 @@
                     return vf.createValue(((Double) val).doubleValue());
                 case PropertyType.LONG:
                     return vf.createValue(((Long) val).longValue());
+                case PropertyType.DECIMAL:
+                    return vf.createValue((BigDecimal) val);
                 case PropertyType.REFERENCE:
                     return vf.createValue(val.toString(), PropertyType.REFERENCE);
+                case PropertyType.WEAKREFERENCE:
+                    return vf.createValue(val.toString(), PropertyType.WEAKREFERENCE);
+                case PropertyType.URI:
+                    return new URIValue((URI) val);
                 case PropertyType.PATH:
                     return vf.createValue(resolver.getJCRPath((Path) val), PropertyType.PATH);
                 case PropertyType.NAME:
@@ -507,12 +554,18 @@
                 return create(Double.parseDouble(s));
             case PropertyType.LONG:
                 return create(Long.parseLong(s));
+            case PropertyType.DECIMAL:
+                return create(new BigDecimal(s));
             case PropertyType.REFERENCE:
                 return create(new UUID(s));
+            case PropertyType.WEAKREFERENCE:
+                return create(new UUID(s), true);
             case PropertyType.PATH:
                 return create(PathFactoryImpl.getInstance().create(s));
             case PropertyType.NAME:
                 return create(NameFactoryImpl.getInstance().create(s));
+            case PropertyType.URI:
+                return create(URI.create(s));
             case PropertyType.STRING:
                 return create(s);
 
@@ -564,6 +617,14 @@
         super(Boolean.valueOf(value));
     }
 
+    private InternalValue(URI value) {
+        super(value, PropertyType.URI);
+    }
+
+    private InternalValue(BigDecimal value) {
+        super(value, PropertyType.DECIMAL);
+    }
+
     private InternalValue(BLOBFileValue value) {
         super(value, PropertyType.BINARY);
     }
@@ -576,6 +637,10 @@
         super(value, PropertyType.REFERENCE);
     }
 
+    private InternalValue(UUID value, boolean weak) {
+        super(value, weak ? PropertyType.WEAKREFERENCE : PropertyType.REFERENCE);
+    }
+
     /**
      * Create a BLOB value from in input stream. Small objects will create an in-memory object,
      * while large objects are stored in the data store or in a temp file (if the store parameter is not set).

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=776687&r1=776686&r2=776687&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 Wed May 20 13:08:09 2009
@@ -37,6 +37,8 @@
 import java.io.UnsupportedEncodingException;
 import java.io.FileInputStream;
 import java.util.Calendar;
+import java.math.BigDecimal;
+import java.net.URI;
 
 /**
  * <code>InternalValueFactory</code>...
@@ -76,18 +78,27 @@
                     return InternalValue.create(Double.parseDouble(value));
                 case PropertyType.LONG:
                     return InternalValue.create(Long.parseLong(value));
+                case PropertyType.DECIMAL:
+                    return InternalValue.create(new BigDecimal(value));
                 case PropertyType.PATH:
                     return InternalValue.create(PathFactoryImpl.getInstance().create(value));
                 case PropertyType.NAME:
                     return InternalValue.create(NameFactoryImpl.getInstance().create(value));
                 case PropertyType.STRING:
                     return InternalValue.create(value);
+                case PropertyType.URI:
+                    return InternalValue.create(URI.create(value));
                 case PropertyType.REFERENCE:
                     return InternalValue.create(new UUID(value));
+                case PropertyType.WEAKREFERENCE:
+                    return InternalValue.create(new UUID(value), true);
                 case PropertyType.BINARY:
                     return InternalValue.create(value.getBytes("UTF-8"));
                 // default: invalid type specified -> see below.
             }
+        } catch (NumberFormatException ex) {
+            // given String value cannot be converted to Decimal
+            throw new ValueFormatException(ex);
         } catch (IllegalArgumentException ex) {
             // given String value cannot be converted to Long/Double/Path/Name
             throw new ValueFormatException(ex);

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BaseValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BaseValue.java?rev=776687&r1=776686&r2=776687&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BaseValue.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BaseValue.java Wed May 20 13:08:09 2009
@@ -37,12 +37,15 @@
  * @see StringValue
  * @see LongValue
  * @see DoubleValue
+ * @see DecimalValue
  * @see BooleanValue
  * @see DateValue
  * @see BinaryValue
  * @see NameValue
  * @see PathValue
+ * @see URIValue
  * @see ReferenceValue
+ * @see WeakReferenceValue
  */
 public abstract class BaseValue implements Value {
 
@@ -187,7 +190,6 @@
         setValueConsumed();
 
         try {
-            // TODO: Is this the correct way to handle BigDecimal conversion
             return new BigDecimal(getInternalString());
         } catch (NumberFormatException e) {
             throw new ValueFormatException("conversion to Decimal failed", e);

Copied: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DecimalValue.java (from r775860, jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DoubleValue.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DecimalValue.java?p2=jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DecimalValue.java&p1=jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DoubleValue.java&r1=775860&r2=776687&rev=776687&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DoubleValue.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DecimalValue.java Wed May 20 13:08:09 2009
@@ -21,52 +21,43 @@
 import javax.jcr.ValueFormatException;
 import java.util.Calendar;
 import java.util.Date;
+import java.math.BigDecimal;
 
 /**
- * A <code>DoubleValue</code> provides an implementation
- * of the <code>Value</code> interface representing a double value.
+ * A <code>DecimalValue</code> provides an implementation
+ * of the <code>Value</code> interface representing a <code>DECIMAL</code> value.
  */
-public class DoubleValue extends BaseValue {
+public class DecimalValue extends BaseValue {
 
-    public static final int TYPE = PropertyType.DOUBLE;
+    public static final int TYPE = PropertyType.DECIMAL;
 
-    private final Double dblNumber;
+    private final BigDecimal number;
 
     /**
-     * Constructs a <code>DoubleValue</code> object representing a double.
+     * Constructs a <code>DecimalValue</code> object representing a decimal.
      *
-     * @param dblNumber the double this <code>DoubleValue</code> should represent
+     * @param number the decimal this <code>DecimalValue</code> should represent
      */
-    public DoubleValue(Double dblNumber) {
+    public DecimalValue(BigDecimal number) {
         super(TYPE);
-        this.dblNumber = dblNumber;
+        this.number = number;
     }
 
     /**
-     * Constructs a <code>DoubleValue</code> object representing a double.
-     *
-     * @param dbl the double this <code>DoubleValue</code> should represent
-     */
-    public DoubleValue(double dbl) {
-        super(TYPE);
-        this.dblNumber = new Double(dbl);
-    }
-
-    /**
-     * Returns a new <code>DoubleValue</code> initialized to the value
+     * Returns a new <code>DecimalValue</code> initialized to the value
      * represented by the specified <code>String</code>.
      *
      * @param s the string to be parsed.
-     * @return a newly constructed <code>DoubleValue</code> representing the
+     * @return a newly constructed <code>DecimalValue</code> representing the
      *         the specified value.
      * @throws javax.jcr.ValueFormatException If the <code>String</code> does not
-     *                                        contain a parsable <code>double</code>.
+     *                                        contain a parsable <code>decimal</code>.
      */
-    public static DoubleValue valueOf(String s) throws ValueFormatException {
+    public static DecimalValue valueOf(String s) throws ValueFormatException {
         try {
-            return new DoubleValue(Double.parseDouble(s));
+            return new DecimalValue(new BigDecimal(s));
         } catch (NumberFormatException e) {
-            throw new ValueFormatException("not a valid double format: " + s, e);
+            throw new ValueFormatException("not a valid decimal format: " + s, e);
         }
     }
 
@@ -74,7 +65,7 @@
      * Indicates whether some other object is "equal to" this one.
      * <p/>
      * The result is <code>true</code> if and only if the argument is not
-     * <code>null</code> and is a <code>DoubleValue</code> object that
+     * <code>null</code> and is a <code>DecimalValue</code> object that
      * represents the same value as this object.
      *
      * @param obj the reference object with which to compare.
@@ -85,12 +76,12 @@
         if (this == obj) {
             return true;
         }
-        if (obj instanceof DoubleValue) {
-            DoubleValue other = (DoubleValue) obj;
-            if (dblNumber == other.dblNumber) {
+        if (obj instanceof DecimalValue) {
+            DecimalValue other = (DecimalValue) obj;
+            if (number == other.number) {
                 return true;
-            } else if (dblNumber != null && other.dblNumber != null) {
-                return dblNumber.equals(other.dblNumber);
+            } else if (number != null && other.number != null) {
+                return number.equals(other.number);
             }
         }
         return false;
@@ -112,8 +103,8 @@
      * {@inheritDoc}
      */
     protected String getInternalString() throws ValueFormatException {
-        if (dblNumber != null) {
-            return dblNumber.toString();
+        if (number != null) {
+            return number.toString();
         } else {
             throw new ValueFormatException("empty value");
         }
@@ -128,10 +119,10 @@
             RepositoryException {
         setValueConsumed();
 
-        if (dblNumber != null) {
+        if (number != null) {
             // loosing timezone information...
             Calendar cal = Calendar.getInstance();
-            cal.setTime(new Date(dblNumber.longValue()));
+            cal.setTime(new Date(number.longValue()));
             return cal;
         } else {
             throw new ValueFormatException("empty value");
@@ -146,8 +137,8 @@
             RepositoryException {
         setValueConsumed();
 
-        if (dblNumber != null) {
-            return dblNumber.longValue();
+        if (number != null) {
+            return number.longValue();
         } else {
             throw new ValueFormatException("empty value");
         }
@@ -172,10 +163,25 @@
             RepositoryException {
         setValueConsumed();
 
-        if (dblNumber != null) {
-            return dblNumber.doubleValue();
+        if (number != null) {
+            return number.doubleValue();
+        } else {
+            throw new ValueFormatException("empty value");
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public BigDecimal getDecimal()
+            throws ValueFormatException, IllegalStateException,
+            RepositoryException {
+        setValueConsumed();
+
+        if (number != null) {
+            return number;
         } else {
             throw new ValueFormatException("empty value");
         }
     }
-}
+}
\ No newline at end of file

Copied: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/URIValue.java (from r775860, jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/PathValue.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/URIValue.java?p2=jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/URIValue.java&p1=jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/PathValue.java&r1=775860&r2=776687&rev=776687&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/PathValue.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/URIValue.java Wed May 20 13:08:09 2009
@@ -16,68 +16,64 @@
  */
 package org.apache.jackrabbit.value;
 
-import org.apache.jackrabbit.name.MalformedPathException;
-import org.apache.jackrabbit.name.PathFormat;
-
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.ValueFormatException;
 import java.util.Calendar;
+import java.net.URI;
+import java.net.URISyntaxException;
 
 /**
- * A <code>PathValue</code> provides an implementation
- * of the <code>Value</code> interface representing a <code>PATH</code> value
+ * A <code>URIValue</code> provides an implementation
+ * of the <code>Value</code> interface representing a <code>URI</code> value
  * (an absolute or relative workspace path).
  */
-public class PathValue extends BaseValue {
+public class URIValue extends BaseValue {
 
-    public static final int TYPE = PropertyType.PATH;
+    public static final int TYPE = PropertyType.URI;
 
-    private final String path;
+    private final URI uri;
 
     /**
-     * Returns a new <code>PathValue</code> initialized to the value
+     * Returns a new <code>URIValue</code> initialized to the value
      * represented by the specified <code>String</code>.
      * <p/>
-     * The specified <code>String</code> must be a valid absolute or relative
-     * path.
+     * The specified <code>String</code> must be a valid URI.
      *
      * @param s the string to be parsed.
-     * @return a newly constructed <code>PathValue</code> representing the
+     * @return a newly constructed <code>URIValue</code> representing the
      *         the specified value.
-     * @throws javax.jcr.ValueFormatException If the <code>String</code> is not a valid
-     *                              absolute or relative path.
+     * @throws javax.jcr.ValueFormatException If the <code>String</code> is not a valid URI.
      */
-    public static PathValue valueOf(String s) throws ValueFormatException {
+    public static URIValue valueOf(String s) throws ValueFormatException {
         if (s != null) {
             try {
-                PathFormat.checkFormat(s);
-            } catch (MalformedPathException mpe) {
-                throw new ValueFormatException(mpe.getMessage());
+                return new URIValue(new URI(s));
+            } catch (URISyntaxException e) {
+                throw new ValueFormatException(e.getMessage());
             }
-            return new PathValue(s);
         } else {
-            throw new ValueFormatException("not a valid path format: " + s);
+            throw new ValueFormatException("not a valid uri format: " + s);
         }
     }
 
     /**
-     * Protected constructor creating a <code>PathValue</code> object
-     * without validating the path.
+     * Returns a new <code>URIValue</code> initialized to the value of the
+     * specified URI.
      *
-     * @param path the path this <code>PathValue</code> should represent
+     * @param uri the path this <code>URIValue</code> should represent
      * @see #valueOf
      */
-    protected PathValue(String path) {
+    public URIValue(URI uri) {
         super(TYPE);
-        this.path = path;
+        this.uri = uri;
     }
 
     /**
      * Indicates whether some other object is "equal to" this one.
      * <p/>
      * The result is <code>true</code> if and only if the argument is not
-     * <code>null</code> and is a <code>PathValue</code> object that
+     * <code>null</code> and is a <code>URIValue</code> object that
      * represents the same value as this object.
      *
      * @param obj the reference object with which to compare.
@@ -88,12 +84,12 @@
         if (this == obj) {
             return true;
         }
-        if (obj instanceof PathValue) {
-            PathValue other = (PathValue) obj;
-            if (path == other.path) {
+        if (obj instanceof URIValue) {
+            URIValue other = (URIValue) obj;
+            if (uri == other.uri) {
                 return true;
-            } else if (path != null && other.path != null) {
-                return path.equals(other.path);
+            } else if (uri != null && other.uri != null) {
+                return uri.equals(other.uri);
             }
         }
         return false;
@@ -115,8 +111,8 @@
      * {@inheritDoc}
      */
     protected String getInternalString() throws ValueFormatException {
-        if (path != null) {
-            return path;
+        if (uri != null) {
+            return uri.toString();
         } else {
             throw new ValueFormatException("empty value");
         }
@@ -166,4 +162,4 @@
 
         throw new ValueFormatException("conversion to double failed: inconvertible types");
     }
-}
+}
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueFactoryImpl.java?rev=776687&r1=776686&r2=776687&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueFactoryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueFactoryImpl.java Wed May 20 13:08:09 2009
@@ -92,7 +92,7 @@
      * {@inheritDoc}
      */
     public Value createValue(Node value) throws RepositoryException {
-        return new ReferenceValue(value);
+        return createValue(value, false);
     }
 
     /**
@@ -121,6 +121,9 @@
             case PropertyType.LONG:
                 val = LongValue.valueOf(value);
                 break;
+            case PropertyType.DECIMAL:
+                val = DecimalValue.valueOf(value);
+                break;
             case PropertyType.DATE:
                 val = DateValue.valueOf(value);
                 break;
@@ -130,9 +133,15 @@
             case PropertyType.PATH:
                 val = PathValue.valueOf(value);
                 break;
+            case PropertyType.URI:
+                val = URIValue.valueOf(value);
+                break;
             case PropertyType.REFERENCE:
                 val = ReferenceValue.valueOf(value);
                 break;
+            case PropertyType.WEAKREFERENCE:
+                val = WeakReferenceValue.valueOf(value);
+                break;
             case PropertyType.BINARY:
                 val = new BinaryValue(value);
                 break;
@@ -150,13 +159,23 @@
         throw new UnsupportedOperationException("JCR-2056");
     }
 
-    public Value createValue(BigDecimal arg0) {
-        throw new UnsupportedOperationException("JCR-1609");
+    /**
+     * {@inheritDoc}
+     */
+    public Value createValue(BigDecimal value) {
+        return new DecimalValue(value);
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public Value createValue(Node node, boolean weak)
             throws RepositoryException {
-        throw new UnsupportedRepositoryOperationException("JCR-1609");
+        if (weak) {
+            return new WeakReferenceValue(node);
+        } else {
+            return new ReferenceValue(node);
+        }
     }
 
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java?rev=776687&r1=776686&r2=776687&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ValueHelper.java Wed May 20 13:08:09 2009
@@ -502,9 +502,15 @@
                     newVal = factory.createValue(srcValue.getLong());
                     break;
 
+                case PropertyType.DECIMAL:
+                    newVal = factory.createValue(srcValue.getDecimal());
+                    break;
+
                 case PropertyType.PATH:
                 case PropertyType.NAME:
                 case PropertyType.REFERENCE:
+                case PropertyType.WEAKREFERENCE:
+                case PropertyType.URI:
                     newVal = factory.createValue(srcValue.getString(), srcValue.getType());
                     break;
 

Copied: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/WeakReferenceValue.java (from r775860, jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ReferenceValue.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/WeakReferenceValue.java?p2=jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/WeakReferenceValue.java&p1=jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ReferenceValue.java&r1=775860&r2=776687&rev=776687&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ReferenceValue.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/WeakReferenceValue.java Wed May 20 13:08:09 2009
@@ -26,13 +26,13 @@
 import java.util.Calendar;
 
 /**
- * A <code>ReferenceValue</code> provides an implementation
- * of the <code>Value</code> interface representing a <code>REFERENCE</code> value
+ * A <code>WeakReferenceValue</code> provides an implementation
+ * of the <code>Value</code> interface representing a <code>WEAKREFERENCE</code> value
  * (a UUID of an existing node).
  */
-public class ReferenceValue extends BaseValue {
+public class WeakReferenceValue extends BaseValue {
 
-    public static final int TYPE = PropertyType.REFERENCE;
+    public static final int TYPE = PropertyType.WEAKREFERENCE;
 
     private final String uuid;
 
@@ -44,7 +44,7 @@
      * @throws IllegalArgumentException If <code>target</code> is nonreferenceable.
      * @throws javax.jcr.RepositoryException      If another error occurs.
      */
-    public ReferenceValue(Node target) throws RepositoryException {
+    public WeakReferenceValue(Node target) throws RepositoryException {
         super(TYPE);
         try {
             this.uuid = target.getUUID();
@@ -66,14 +66,14 @@
      * @throws javax.jcr.ValueFormatException If the <code>String</code> is not a valid
      *                              not a valid UUID format.
      */
-    public static ReferenceValue valueOf(String s) throws ValueFormatException {
+    public static WeakReferenceValue valueOf(String s) throws ValueFormatException {
         if (s != null) {
             try {
                 UUID.fromString(s);
             } catch (IllegalArgumentException iae) {
                 throw new ValueFormatException("not a valid UUID format: " + s);
             }
-            return new ReferenceValue(s);
+            return new WeakReferenceValue(s);
         } else {
             throw new ValueFormatException("not a valid UUID format: " + s);
         }
@@ -86,7 +86,7 @@
      * @param uuid the UUID of the node to be referenced
      * @see #valueOf
      */
-    protected ReferenceValue(String uuid) {
+    protected WeakReferenceValue(String uuid) {
         super(TYPE);
         this.uuid = uuid;
     }
@@ -106,8 +106,8 @@
         if (this == obj) {
             return true;
         }
-        if (obj instanceof ReferenceValue) {
-            ReferenceValue other = (ReferenceValue) obj;
+        if (obj instanceof WeakReferenceValue) {
+            WeakReferenceValue other = (WeakReferenceValue) obj;
             if (uuid == other.uuid) {
                 return true;
             } else if (uuid != null && other.uuid != null) {
@@ -184,4 +184,4 @@
 
         throw new ValueFormatException("conversion to double failed: inconvertible types");
     }
-}
+}
\ No newline at end of file

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=776687&r1=776686&r2=776687&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 Wed May 20 13:08:09 2009
@@ -28,6 +28,8 @@
 import javax.jcr.ValueFormatException;
 import java.util.Calendar;
 import java.util.TimeZone;
+import java.math.BigDecimal;
+import java.net.URI;
 
 /**
  * <code>AbstractQValue</code>...
@@ -143,6 +145,28 @@
         this(value, PropertyType.PATH);
     }
 
+    /**
+     * Create a new <code>AbstractQValue</code>.
+     *
+     * @param value
+     * @throws IllegalArgumentException if the passed <code>value</code>
+     * is <code>null</code>.
+     */
+    protected AbstractQValue(BigDecimal value) {
+        this(value, PropertyType.DECIMAL);
+    }
+
+    /**
+     * Create a new <code>AbstractQValue</code>.
+     *
+     * @param value
+     * @throws IllegalArgumentException if the passed <code>value</code>
+     * is <code>null</code>.
+     */
+    protected AbstractQValue(URI value) {
+        this(value, PropertyType.URI);
+    }
+
     //---------------------------------------------------------< QValue >---
     /**
      * @see QValue#getType()
@@ -187,6 +211,10 @@
             Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+00:00"));
             cal.setTimeInMillis(((Long) val).longValue());
             return cal;
+        } else if (type == PropertyType.DECIMAL) {
+            Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+00:00"));
+            cal.setTimeInMillis(((BigDecimal) val).longValue());
+            return cal;
         } else {
             Calendar cal = ISO8601.parse(getString());
             if (cal == null) {
@@ -198,6 +226,36 @@
     }
 
     /**
+     * @see QValue#getDecimal()
+     */
+    public BigDecimal getDecimal() throws RepositoryException {
+        if (type == PropertyType.DECIMAL) {
+            return (BigDecimal) val;
+        } else {
+            try {
+                return new BigDecimal(getString());
+            } catch (NumberFormatException e) {
+                throw new ValueFormatException("not a valid decimal string: " + getString(), e);
+            }
+        }
+    }
+
+    /**
+     * @see QValue#getURI()
+     */
+    public URI getURI() throws RepositoryException {
+        if (type == PropertyType.URI) {
+            return (URI) val;
+        } else {
+            try {
+                return URI.create(getString());
+            } catch (IllegalArgumentException e) {
+                throw new ValueFormatException("not a valid uri: " + getString(), e);
+            }
+        }
+    }
+
+    /**
      * @see QValue#getDouble()
      */
     public double getDouble() throws RepositoryException {
@@ -205,6 +263,8 @@
             return ((Double) val).doubleValue();
         } else if (type == PropertyType.DATE) {
             return ((Calendar) val).getTimeInMillis();
+        } else if (type == PropertyType.DECIMAL) {
+            return ((BigDecimal) val).doubleValue();
         } else {
             try {
                 return Double.parseDouble(getString());
@@ -222,6 +282,8 @@
             return ((Long) val).longValue();
         } else if (type == PropertyType.DOUBLE) {
             return ((Double) val).longValue();
+        } else if (type == PropertyType.DECIMAL) {
+            return ((BigDecimal) val).longValue();
         } else if (type == PropertyType.DATE) {
             return ((Calendar) val).getTimeInMillis();
         } else {

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=776687&r1=776686&r2=776687&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 Wed May 20 13:08:09 2009
@@ -41,6 +41,9 @@
 import java.io.UnsupportedEncodingException;
 import java.util.Arrays;
 import java.util.Calendar;
+import java.math.BigDecimal;
+import java.net.URI;
+import java.net.URISyntaxException;
 
 /**
  * <code>QValueFactoryImpl</code>...
@@ -583,6 +586,28 @@
         }
 
         /**
+         * @see QValue#getDecimal()
+         */
+        public BigDecimal getDecimal() throws RepositoryException {
+            try {
+                return new BigDecimal(getString());
+            } catch (NumberFormatException ex) {
+                throw new ValueFormatException(ex);
+            }
+        }
+
+        /**
+         * @see QValue#getURI()
+         */
+        public URI getURI() throws RepositoryException {
+            try {
+                return new URI(getString());
+            } catch (URISyntaxException ex) {
+                throw new ValueFormatException(ex);
+            }
+        }
+
+        /**
          * Frees temporarily allocated resources such as temporary file, buffer, etc.
          * If this <code>BinaryQValue</code> is backed by a persistent resource
          * calling this method will have no effect.

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=776687&r1=776686&r2=776687&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 May 20 13:08:09 2009
@@ -18,6 +18,8 @@
 
 import java.io.InputStream;
 import java.util.Calendar;
+import java.math.BigDecimal;
+import java.net.URI;
 
 import javax.jcr.Property;
 import javax.jcr.PropertyType;
@@ -76,7 +78,7 @@
     public String getString() throws RepositoryException;
 
     /**
-     * Returns a <code>InputStream</code> representation of this <code>QValue</code>
+     * Returns an <code>InputStream</code> representation of this <code>QValue</code>
      * object.
      *
      * @return A stream representation of this value.
@@ -93,6 +95,14 @@
     public Calendar getCalendar() throws RepositoryException;
 
     /**
+     * Returns a <code>BigDecimal</code> representation of this value.
+     *
+     * @return A <code>BigDecimal</code> representation of this value.
+     * @throws RepositoryException if an error occurs.
+     */
+    public BigDecimal getDecimal() throws RepositoryException;
+
+    /**
      * Returns a <code>double</code> representation of this value.
      *
      * @return A <code>double</code> representation of this value.
@@ -134,6 +144,14 @@
     public Path getPath() throws RepositoryException;
 
     /**
+     * Returns an <code>URI</code> representation of this value.
+     *
+     * @return A <code>URI</code> representation of this value.
+     * @throws RepositoryException if an error occurs.
+     */
+    public URI getURI() throws RepositoryException;
+
+    /**
      * Frees temporarily allocated resources such as temporary file, buffer, etc.
      */
     public void discard();



Mime
View raw message