jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1401657 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java
Date Wed, 24 Oct 2012 12:49:26 GMT
Author: mduerig
Date: Wed Oct 24 12:49:25 2012
New Revision: 1401657

URL: http://svn.apache.org/viewvc?rev=1401657&view=rev
Log:
Simplify

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java?rev=1401657&r1=1401656&r2=1401657&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java
Wed Oct 24 12:49:25 2012
@@ -183,13 +183,11 @@ public class ValueFactoryImpl implements
         }
 
         try {
-            PropertyState pv;
             switch (type) {
                 case PropertyType.STRING:
                     return createValue(value);
                 case PropertyType.BINARY:
-                    pv = BinaryPropertyState.binaryProperty("", value);
-                    break;
+                    return new ValueImpl(BinaryPropertyState.binaryProperty("", value), namePathMapper);
                 case PropertyType.LONG:
                     return createValue(Conversions.convert(value).toLong());
                 case PropertyType.DOUBLE:
@@ -198,8 +196,7 @@ public class ValueFactoryImpl implements
                     if (ISO8601.parse(value) == null) {
                         throw new ValueFormatException("Invalid date " + value);
                     }
-                    pv = LongPropertyState.createDateProperty("", value);
-                    break;
+                    return new ValueImpl(LongPropertyState.createDateProperty("", value),
namePathMapper);
                 case PropertyType.BOOLEAN:
                     return createValue(Conversions.convert(value).toBoolean());
                 case PropertyType.NAME:
@@ -207,8 +204,7 @@ public class ValueFactoryImpl implements
                     if (oakName == null) {
                         throw new ValueFormatException("Invalid name: " + value);
                     }
-                    pv = GenericPropertyState.nameProperty("", oakName);
-                    break;
+                    return new ValueImpl(GenericPropertyState.nameProperty("", oakName),
namePathMapper);
                 case PropertyType.PATH:
                     String oakValue = value;
                     if (value.startsWith("[") && value.endsWith("]")) {
@@ -219,31 +215,25 @@ public class ValueFactoryImpl implements
                     if (oakValue == null) {
                         throw new ValueFormatException("Invalid path: " + value);
                     }
-                    pv = GenericPropertyState.pathProperty("", oakValue);
-                    break;
+                    return new ValueImpl(GenericPropertyState.pathProperty("", oakValue),
namePathMapper);
                 case PropertyType.REFERENCE:
                     if (!IdentifierManager.isValidUUID(value)) {
                         throw new ValueFormatException("Invalid reference value " + value);
                     }
-                    pv = GenericPropertyState.referenceProperty("", value);
-                    break;
+                    return new ValueImpl(GenericPropertyState.referenceProperty("", value),
namePathMapper);
                 case PropertyType.WEAKREFERENCE:
                     if (!IdentifierManager.isValidUUID(value)) {
                         throw new ValueFormatException("Invalid weak reference value " +
value);
                     }
-                    pv = GenericPropertyState.weakreferenceProperty("", value);
-                    break;
+                    return new ValueImpl(GenericPropertyState.weakreferenceProperty("", value),
namePathMapper);
                 case PropertyType.URI:
                     new URI(value);
-                    pv = GenericPropertyState.uriProperty("", value);
-                    break;
+                    return new ValueImpl(GenericPropertyState.uriProperty("", value), namePathMapper);
                 case PropertyType.DECIMAL:
                     return createValue(Conversions.convert(value).toDecimal());
                 default:
                     throw new ValueFormatException("Invalid type: " + type);
             }
-
-            return new ValueImpl(pv, namePathMapper);
         } catch (NumberFormatException e) {
             throw new ValueFormatException("Invalid value " + value + " for type " + PropertyType.nameFromValue(type),
e);
         } catch (URISyntaxException e) {



Mime
View raw message