jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1311723 - /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/util/ValueConverter.java
Date Tue, 10 Apr 2012 13:50:01 GMT
Author: angela
Date: Tue Apr 10 13:50:01 2012
New Revision: 1311723

URL: http://svn.apache.org/viewvc?rev=1311723&view=rev
Log:
add ValueConverter#toScalar(String, type)

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/util/ValueConverter.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/util/ValueConverter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/util/ValueConverter.java?rev=1311723&r1=1311722&r2=1311723&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/util/ValueConverter.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/util/ValueConverter.java
Tue Apr 10 13:50:01 2012
@@ -38,6 +38,37 @@ import java.util.List;
 public final class ValueConverter {
     private ValueConverter() {}
 
+    public static Scalar toScalar(String value, int propertyType) throws RepositoryException
{
+        switch (propertyType) {
+            case PropertyType.STRING: {
+                return ScalarImpl.stringScalar(value);
+            }
+            case PropertyType.DOUBLE: {
+                return ScalarImpl.doubleScalar(Double.parseDouble(value));
+            }
+            case PropertyType.LONG: {
+                return ScalarImpl.longScalar(Long.parseLong(value));
+            }
+            case PropertyType.BOOLEAN: {
+                return ScalarImpl.booleanScalar(Boolean.parseBoolean(value));
+            }
+            case PropertyType.BINARY: {
+                return ScalarImpl.binaryScalar(value);
+            }
+            case PropertyType.DECIMAL:
+            case PropertyType.DATE:
+            case PropertyType.NAME:
+            case PropertyType.PATH:
+            case PropertyType.REFERENCE:
+            case PropertyType.WEAKREFERENCE:
+            case PropertyType.URI:
+            default: {
+                // todo implement toScalar
+                throw new UnsupportedRepositoryOperationException("toScalar");
+            }
+        }
+    }
+
     public static Scalar toScalar(Value value) throws RepositoryException {
         switch (value.getType()) {
             case PropertyType.STRING: {



Mime
View raw message