jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r781318 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
Date Wed, 03 Jun 2009 09:44:48 GMT
Author: angela
Date: Wed Jun  3 09:44:48 2009
New Revision: 781318

URL: http://svn.apache.org/viewvc?rev=781318&view=rev
Log:
resolve TODO by simplifying Property.getLength(InternalValue)

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java

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=781318&r1=781317&r2=781318&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 Jun  3 09:44:48 2009
@@ -42,7 +42,6 @@
 import org.apache.jackrabbit.core.state.ItemState;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.PropertyState;
-import org.apache.jackrabbit.core.value.BLOBFileValue;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
@@ -186,34 +185,18 @@
      * @see javax.jcr.Property#getLengths()
      */
     protected long getLength(InternalValue value) throws RepositoryException {
-        // TODO maybe move method to InternalValue
+        long length;
         switch (value.getType()) {
-            case PropertyType.STRING:
-            case PropertyType.LONG:
-            case PropertyType.DOUBLE:
-            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:
-                Name name = value.getQName();
-                return session.getJCRName(name).length();
-
             case PropertyType.PATH:
-                Path path = value.getPath();
-                return session.getJCRPath(path).length();
-
-            case PropertyType.BINARY:
-                BLOBFileValue blob = value.getBLOBFileValue();
-                return blob.getLength();
-
+                Value jcrValue = ValueFormat.getJCRValue(value, session, session.getValueFactory());
+                length = jcrValue.getString().length();
+                break;
             default:
-                return -1;
+                length = value.getLength();
+                break;
         }
+        return length;
     }
 
     /**



Mime
View raw message