jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1394658 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory: ArrayBasedBlob.java PropertyStates.java
Date Fri, 05 Oct 2012 17:10:51 GMT
Author: mduerig
Date: Fri Oct  5 17:10:51 2012
New Revision: 1394658

URL: http://svn.apache.org/viewvc?rev=1394658&view=rev
Log:
OAK-350: Unify PropertyState and CoreValue
- replace ValueBased property state implementations with the new PropertyState implementations

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ArrayBasedBlob.java
  (with props)
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/PropertyStates.java

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ArrayBasedBlob.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ArrayBasedBlob.java?rev=1394658&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ArrayBasedBlob.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ArrayBasedBlob.java
Fri Oct  5 17:10:51 2012
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.memory;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import javax.annotation.Nonnull;
+
+public class ArrayBasedBlob extends AbstractBlob {
+    private final byte[] value;
+
+    public ArrayBasedBlob(byte[] value) {
+        this.value = value;
+    }
+
+    @Nonnull
+    @Override
+    public InputStream getNewStream() {
+        return new ByteArrayInputStream(value);
+    }
+
+    @Override
+    public long length() {
+        return value.length;
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ArrayBasedBlob.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ArrayBasedBlob.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/PropertyStates.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/PropertyStates.java?rev=1394658&r1=1394657&r2=1394658&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/PropertyStates.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/PropertyStates.java
Fri Oct  5 17:10:51 2012
@@ -33,6 +33,8 @@ import org.apache.jackrabbit.oak.api.Cor
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
 
+import static org.apache.jackrabbit.oak.api.Type.*;
+
 public final class PropertyStates {
     private PropertyStates() {}
 
@@ -121,60 +123,65 @@ public final class PropertyStates {
         }
     }
 
-    public static PropertyState emptyProperty(String name, Type<?> type) {
-        return new ValueBasedEmptyPropertyState(name, type);
+    public static PropertyState emptyProperty(String name, final Type<?> type) {
+        return new EmptyPropertyState(name) {
+            @Override
+            public Type<?> getType() {
+                return type;
+            }
+        };
     }
 
     public static PropertyState stringProperty(String name, String value) {
-        return new ValueBasedSinglePropertyState(name, new StringValue(value));
+        return new StringPropertyState(name, value);
     }
 
     public static PropertyState binaryProperty(String name, byte[] value) {
-        return new ValueBasedSinglePropertyState(name, new BinaryValue(value));
+        return new BinaryPropertyState(name, new ArrayBasedBlob(value));
     }
 
     public static PropertyState longProperty(String name, long value) {
-        return new ValueBasedSinglePropertyState(name, new LongValue(value));
+        return new LongPropertyState(name, value);
     }
 
     public static PropertyState doubleProperty(String name, double value) {
-        return new ValueBasedSinglePropertyState(name, new DoubleValue(value));
+        return new DoublePropertyState(name, value);
     }
 
     public static PropertyState dateProperty(String name, String value) {
-        return new ValueBasedSinglePropertyState(name, new GenericValue(PropertyType.DATE,
value));
+        return new GenericPropertyState(name, value, DATE);
     }
 
     public static PropertyState booleanProperty(String name, boolean value) {
-        return new ValueBasedSinglePropertyState(name, value ? BooleanValue.TRUE : BooleanValue.FALSE);
+        return new BooleanPropertyState(name, value);
     }
 
     public static PropertyState nameProperty(String name, String value) {
-        return new ValueBasedSinglePropertyState(name, new GenericValue(PropertyType.NAME,
value));
+        return new GenericPropertyState(name, value, NAME);
     }
 
     public static PropertyState pathProperty(String name, String value) {
-        return new ValueBasedSinglePropertyState(name, new GenericValue(PropertyType.PATH,
value));
+        return new GenericPropertyState(name, value, PATH);
     }
 
     public static PropertyState referenceProperty(String name, String value) {
-        return new ValueBasedSinglePropertyState(name, new GenericValue(PropertyType.REFERENCE,
value));
+        return new GenericPropertyState(name, value, REFERENCE);
     }
 
     public static PropertyState weakreferenceProperty(String name, String value) {
-        return new ValueBasedSinglePropertyState(name, new GenericValue(PropertyType.WEAKREFERENCE,
value));
+        return new GenericPropertyState(name, value, WEAKREFERENCE);
     }
 
     public static PropertyState uriProperty(String name, String value) {
-        return new ValueBasedSinglePropertyState(name, new GenericValue(PropertyType.URI,
value));
+        return new GenericPropertyState(name, value, URI);
     }
 
     public static PropertyState decimalProperty(String name, BigDecimal value) {
-        return new ValueBasedSinglePropertyState(name, new DecimalValue(value));
+        return new DecimalPropertySate(name, value);
     }
 
     public static PropertyState binaryProperty(String name, Blob value) {
-        return new ValueBasedSinglePropertyState(name, new BinaryValue(toBytes(value)));
+        return new BinaryPropertyState(name, value);
     }
 
     public static PropertyState stringProperty(String name, Iterable<String> values)
{



Mime
View raw message