You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by md...@apache.org on 2012/10/05 19:10:30 UTC

svn commit: r1394655 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/

Author: mduerig
Date: Fri Oct  5 17:10:29 2012
New Revision: 1394655

URL: http://svn.apache.org/viewvc?rev=1394655&view=rev
Log:
OAK-350: Unify PropertyState and CoreValue
- first shot at new PropertyState implementations

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BinariesPropertyState.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BinaryPropertyState.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BooleanPropertyState.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BooleansPropertyState.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DecimalPropertySate.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DecimalsPropertyState.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DoublePropertyState.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DoublesPropertyState.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/GenericPropertyState.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/GenericsPropertyState.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/LongPropertyState.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/LongsPropertyState.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/SinglePropertyState.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/StringBasedBlob.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/StringPropertyState.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/StringsPropertyState.java   (with props)

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BinariesPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BinariesPropertyState.java?rev=1394655&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BinariesPropertyState.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BinariesPropertyState.java Fri Oct  5 17:10:29 2012
@@ -0,0 +1,70 @@
+/*
+ * 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.util.List;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import org.apache.jackrabbit.oak.api.Blob;
+import org.apache.jackrabbit.oak.api.Type;
+
+import static org.apache.jackrabbit.oak.api.Type.BINARIES;
+
+public class BinariesPropertyState extends MultiPropertyState {
+    private final List<Blob> values;
+
+    protected BinariesPropertyState(String name, List<Blob> values) {
+        super(name);
+        this.values = values;
+    }
+
+    @Override
+    protected Iterable<String> getStrings() {
+        return Iterables.transform(values, new Function<Blob, String>() {
+            @Override
+            public String apply(Blob value) {
+                return "<binary>";
+            }
+        });
+    }
+
+    @Override
+    protected String getString(int index) {
+        return "<binary>";
+    }
+
+    @Override
+    protected Iterable<Blob> getBlobs() {
+        return values;
+    }
+
+    @Override
+    protected Blob getBlob(int index) {
+        return values.get(index);
+    }
+
+    @Override
+    public int count() {
+        return values.size();
+    }
+
+    @Override
+    public Type<?> getType() {
+        return BINARIES;
+    }
+}

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

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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BinaryPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BinaryPropertyState.java?rev=1394655&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BinaryPropertyState.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BinaryPropertyState.java Fri Oct  5 17:10:29 2012
@@ -0,0 +1,49 @@
+/*
+ * 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 org.apache.jackrabbit.oak.api.Blob;
+import org.apache.jackrabbit.oak.api.Type;
+
+public class BinaryPropertyState extends SinglePropertyState {
+    private final Blob value;
+
+    protected BinaryPropertyState(String name, Blob value) {
+        super(name);
+        this.value = value;
+    }
+
+    @Override
+    public String getString() {
+        return "<binary>";
+    }
+
+    @Override
+    protected Blob getBlob() {
+        return value;
+    }
+
+    @Override
+    public long size() {
+        return value.length();
+    }
+
+    @Override
+    public Type<?> getType() {
+        return Type.BINARY;
+    }
+}

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

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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BooleanPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BooleanPropertyState.java?rev=1394655&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BooleanPropertyState.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BooleanPropertyState.java Fri Oct  5 17:10:29 2012
@@ -0,0 +1,47 @@
+/*
+ * 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 org.apache.jackrabbit.oak.api.Type;
+
+import static org.apache.jackrabbit.oak.api.Type.*;
+
+public class BooleanPropertyState extends SinglePropertyState {
+    private final boolean value;
+
+    protected BooleanPropertyState(String name, boolean value) {
+        super(name);
+        this.value = value;
+    }
+
+    @Override
+    protected String getString() {
+        return Boolean.toString(value);
+    }
+
+    @Override
+    protected boolean getBoolean() {
+        return value;
+    }
+
+    @Override
+    public Type<?> getType() {
+        return BOOLEAN;
+    }
+}

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

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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BooleansPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BooleansPropertyState.java?rev=1394655&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BooleansPropertyState.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/BooleansPropertyState.java Fri Oct  5 17:10:29 2012
@@ -0,0 +1,69 @@
+/*
+ * 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.util.List;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import org.apache.jackrabbit.oak.api.Type;
+
+import static org.apache.jackrabbit.oak.api.Type.BOOLEANS;
+
+public class BooleansPropertyState extends MultiPropertyState {
+    private final List<Boolean> values;
+
+    protected BooleansPropertyState(String name, List<Boolean> values) {
+        super(name);
+        this.values = values;
+    }
+
+    @Override
+    protected Iterable<String> getStrings() {
+        return Iterables.transform(values, new Function<Boolean, String>() {
+            @Override
+            public String apply(Boolean value) {
+                return Boolean.toString(value);
+            }
+        });
+    }
+
+    @Override
+    protected String getString(int index) {
+        return Boolean.toString(values.get(index));
+    }
+
+    @Override
+    protected Iterable<Boolean> getBooleans() {
+        return values;
+    }
+
+    @Override
+    protected boolean getBoolean(int index) {
+        return values.get(index);
+    }
+
+    @Override
+    public int count() {
+        return values.size();
+    }
+
+    @Override
+    public Type<?> getType() {
+        return BOOLEANS;
+    }
+}

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

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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DecimalPropertySate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DecimalPropertySate.java?rev=1394655&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DecimalPropertySate.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DecimalPropertySate.java Fri Oct  5 17:10:29 2012
@@ -0,0 +1,57 @@
+/*
+ * 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.math.BigDecimal;
+
+import org.apache.jackrabbit.oak.api.Type;
+
+import static org.apache.jackrabbit.oak.api.Type.*;
+
+public class DecimalPropertySate extends SinglePropertyState {
+    private final BigDecimal value;
+
+    protected DecimalPropertySate(String name, BigDecimal value) {
+        super(name);
+        this.value = value;
+    }
+
+    @Override
+    public BigDecimal getDecimal() {
+        return value;
+    }
+
+    @Override
+    public double getDouble() {
+        return value.doubleValue();
+    }
+
+    @Override
+    public long getLong() {
+        return value.longValue();
+    }
+
+    @Override
+    public String getString() {
+        return value.toString();
+    }
+
+    @Override
+    public Type<?> getType() {
+        return DECIMAL;
+    }
+}

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

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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DecimalsPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DecimalsPropertyState.java?rev=1394655&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DecimalsPropertyState.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DecimalsPropertyState.java Fri Oct  5 17:10:29 2012
@@ -0,0 +1,100 @@
+/*
+ * 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.math.BigDecimal;
+import java.util.List;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import org.apache.jackrabbit.oak.api.Type;
+
+import static org.apache.jackrabbit.oak.api.Type.DECIMALS;
+
+public class DecimalsPropertyState extends MultiPropertyState {
+    private final List<BigDecimal> values;
+
+    protected DecimalsPropertyState(String name, List<BigDecimal> values) {
+        super(name);
+        this.values = values;
+    }
+
+    @Override
+    protected Iterable<BigDecimal> getDecimals() {
+        return values;
+    }
+
+    @Override
+    protected BigDecimal getDecimal(int index) {
+        return values.get(index);
+    }
+
+    @Override
+    protected Iterable<Double> getDoubles() {
+        return Iterables.transform(values, new Function<BigDecimal, Double>() {
+            @Override
+            public Double apply(BigDecimal value) {
+                return value.doubleValue();
+            }
+        });
+    }
+
+    @Override
+    protected double getDouble(int index) {
+        return values.get(index).doubleValue();
+    }
+
+    @Override
+    protected Iterable<Long> getLongs() {
+        return Iterables.transform(values, new Function<BigDecimal, Long>() {
+            @Override
+            public Long apply(BigDecimal value) {
+                return value.longValue();
+            }
+        });
+    }
+
+    @Override
+    protected long getLong(int index) {
+        return values.get(index).longValue();
+    }
+
+    @Override
+    protected Iterable<String> getStrings() {
+        return Iterables.transform(values, new Function<BigDecimal, String>() {
+            @Override
+            public String apply(BigDecimal value) {
+                return value.toString();
+            }
+        });
+    }
+
+    @Override
+    protected String getString(int index) {
+        return values.get(index).toString();
+    }
+
+    @Override
+    public int count() {
+        return values.size();
+    }
+
+    @Override
+    public Type<?> getType() {
+        return DECIMALS;
+    }
+}

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

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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DoublePropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DoublePropertyState.java?rev=1394655&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DoublePropertyState.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DoublePropertyState.java Fri Oct  5 17:10:29 2012
@@ -0,0 +1,59 @@
+/*
+ * 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.math.BigDecimal;
+
+import org.apache.jackrabbit.oak.api.Type;
+
+import static org.apache.jackrabbit.oak.api.Type.*;
+
+public class DoublePropertyState extends SinglePropertyState {
+    private final double value;
+
+    protected DoublePropertyState(String name, double value) {
+        super(name);
+        this.value = value;
+    }
+
+    @Override
+    public BigDecimal getDecimal() {
+        return new BigDecimal(value);
+    }
+
+    @Override
+    public double getDouble() {
+        return value;
+    }
+
+    @Override
+    public long getLong() {
+        return (long) value;
+    }
+
+    @Override
+    public String getString() {
+        return String.valueOf(value);
+    }
+
+    @Override
+    public Type<?> getType() {
+        return DOUBLE;
+    }
+}

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

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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DoublesPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DoublesPropertyState.java?rev=1394655&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DoublesPropertyState.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/DoublesPropertyState.java Fri Oct  5 17:10:29 2012
@@ -0,0 +1,102 @@
+/*
+ * 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.math.BigDecimal;
+import java.util.List;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import org.apache.jackrabbit.oak.api.Type;
+
+import static org.apache.jackrabbit.oak.api.Type.DOUBLES;
+
+public class DoublesPropertyState extends MultiPropertyState {
+    private final List<Double> values;
+
+    protected DoublesPropertyState(String name, List<Double>values) {
+        super(name);
+        this.values = values;
+    }
+
+    @Override
+    protected Iterable<BigDecimal> getDecimals() {
+        return Iterables.transform(values, new Function<Double, BigDecimal>() {
+            @Override
+            public BigDecimal apply(Double value) {
+                return new BigDecimal(value);
+            }
+        });
+    }
+
+    @Override
+    protected BigDecimal getDecimal(int index) {
+        return new BigDecimal(values.get(index));
+    }
+
+    @Override
+    protected Iterable<Double> getDoubles() {
+        return values;
+    }
+
+    @Override
+    protected double getDouble(int index) {
+        return values.get(index);
+    }
+
+    @Override
+    protected Iterable<Long> getLongs() {
+        return Iterables.transform(values, new Function<Double, Long>() {
+            @Override
+            public Long apply(Double value) {
+                return value.longValue();
+            }
+        });
+    }
+
+    @Override
+    protected long getLong(int index) {
+        return values.get(index).longValue();
+    }
+
+    @Override
+    protected Iterable<String> getStrings() {
+        return Iterables.transform(values, new Function<Double, String>() {
+            @Override
+            public String apply(Double value) {
+                return String.valueOf(value);
+            }
+        });
+    }
+
+    @Override
+    protected String getString(int index) {
+        return String.valueOf(values.get(index));
+    }
+
+    @Override
+    public int count() {
+        return values.size();
+    }
+
+    @Override
+    public Type<?> getType() {
+        return DOUBLES;
+    }
+}

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

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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java?rev=1394655&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java Fri Oct  5 17:10:29 2012
@@ -0,0 +1,135 @@
+/*
+ * 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.util.Collections;
+
+import javax.annotation.Nonnull;
+
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Type;
+
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+import static org.apache.jackrabbit.oak.api.Type.STRINGS;
+
+abstract class EmptyPropertyState implements PropertyState {
+    private final String name;
+
+    protected EmptyPropertyState(String name) {
+        this.name = name;
+    }
+
+    @Nonnull
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public boolean isArray() {
+        return true;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Nonnull
+    @Override
+    public <T> T getValue(Type<T> type) {
+        if (type.isArray()) {
+            return (T) Collections.emptyList();
+        }
+        else {
+            throw new IllegalStateException("Not a single valued property");
+        }
+    }
+
+    @Nonnull
+    @Override
+    public <T> T getValue(Type<T> type, int index) {
+        throw new IndexOutOfBoundsException(String.valueOf(index));
+    }
+
+    @Override
+    public long size() {
+        throw new IllegalStateException("Not a single valued property");
+    }
+
+    @Override
+    public long size(int index) {
+        throw new IndexOutOfBoundsException(String.valueOf(index));
+    }
+
+    @Override
+    public int count() {
+        return 0;
+    }
+
+    //------------------------------------------------------------< Object >--
+
+    /**
+     * Checks whether the given object is equal to this one. Two property
+     * states are considered equal if their names and types match and
+     * their string representation of their values are equal.
+     * Subclasses may override this method with a more efficient
+     * equality check if one is available.
+     *
+     * @param other target of the comparison
+     * @return {@code true} if the objects are equal, {@code false} otherwise
+     */
+    @Override
+    public boolean equals(Object other) {
+        if (this == other) {
+            return true;
+        }
+        else if (other instanceof PropertyState) {
+            PropertyState that = (PropertyState) other;
+            return getName().equals(that.getName())
+                    && isArray() == that.isArray()
+                    && getType().equals(that.getType())
+                    && getValue(STRINGS).equals(that.getValue(STRINGS));
+        }
+        else {
+            return false;
+        }
+    }
+
+    /**
+     * Returns a hash code that's compatible with how the
+     * {@link #equals(Object)} method is implemented. The current
+     * implementation simply returns the hash code of the property name
+     * since {@link PropertyState} instances are not intended for use as
+     * hash keys.
+     *
+     * @return hash code
+     */
+    @Override
+    public int hashCode() {
+        return name.hashCode();
+    }
+
+    @Override
+    public String toString() {
+        if (isArray()) {
+            return getName() + '=' + getValue(STRINGS);
+        }
+        else {
+            return getName() + '=' + getValue(STRING);
+        }
+    }
+
+}

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

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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/GenericPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/GenericPropertyState.java?rev=1394655&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/GenericPropertyState.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/GenericPropertyState.java Fri Oct  5 17:10:29 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 org.apache.jackrabbit.oak.api.Type;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+public class GenericPropertyState extends SinglePropertyState {
+    private final String value;
+    private final Type<?> type;
+
+    protected GenericPropertyState(String name, String value, Type<?> type) {
+        super(name);
+        checkArgument(!type.isArray());
+        this.value = value;
+        this.type = type;
+    }
+
+    @Override
+    protected String getString() {
+        return value;
+    }
+
+    @Override
+    public Type<?> getType() {
+        return type;
+    }
+}

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

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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/GenericsPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/GenericsPropertyState.java?rev=1394655&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/GenericsPropertyState.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/GenericsPropertyState.java Fri Oct  5 17:10:29 2012
@@ -0,0 +1,57 @@
+/*
+ * 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.util.List;
+
+import org.apache.jackrabbit.oak.api.Type;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+public class GenericsPropertyState extends MultiPropertyState {
+    private final List<String> values;
+    private final Type<?> type;
+
+    protected GenericsPropertyState(String name, List<String> values, Type<?> type) {
+        super(name);
+        checkArgument(type.isArray());
+        this.values = values;
+        this.type = type;
+    }
+
+    @Override
+    protected Iterable<String> getStrings() {
+        return values;
+    }
+
+    @Override
+    protected String getString(int index) {
+        return values.get(index);
+    }
+
+    @Override
+    public int count() {
+        return values.size();
+    }
+
+    @Override
+    public Type<?> getType() {
+        return type;
+    }
+}

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

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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/LongPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/LongPropertyState.java?rev=1394655&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/LongPropertyState.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/LongPropertyState.java Fri Oct  5 17:10:29 2012
@@ -0,0 +1,59 @@
+/*
+ * 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.math.BigDecimal;
+
+import org.apache.jackrabbit.oak.api.Type;
+
+import static org.apache.jackrabbit.oak.api.Type.*;
+
+public class LongPropertyState extends SinglePropertyState {
+    private final long value;
+
+    protected LongPropertyState(String name, long value) {
+        super(name);
+        this.value = value;
+    }
+
+    @Override
+    public BigDecimal getDecimal() {
+        return new BigDecimal(value);
+    }
+
+    @Override
+    public double getDouble() {
+        return value;
+    }
+
+    @Override
+    public long getLong() {
+        return value;
+    }
+
+    @Override
+    public String getString() {
+        return String.valueOf(value);
+    }
+
+    @Override
+    public Type<?> getType() {
+        return LONG;
+    }
+}

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

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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/LongsPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/LongsPropertyState.java?rev=1394655&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/LongsPropertyState.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/LongsPropertyState.java Fri Oct  5 17:10:29 2012
@@ -0,0 +1,102 @@
+/*
+ * 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.math.BigDecimal;
+import java.util.List;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import org.apache.jackrabbit.oak.api.Type;
+
+import static org.apache.jackrabbit.oak.api.Type.LONGS;
+
+public class LongsPropertyState extends MultiPropertyState {
+    private final List<Long> values;
+
+    protected LongsPropertyState(String name, List<Long> values) {
+        super(name);
+        this.values = values;
+    }
+
+    @Override
+    protected Iterable<BigDecimal> getDecimals() {
+        return Iterables.transform(values, new Function<Long, BigDecimal>() {
+            @Override
+            public BigDecimal apply(Long value) {
+                return new BigDecimal(value);
+            }
+        });
+    }
+
+    @Override
+    protected BigDecimal getDecimal(int index) {
+        return new BigDecimal(values.get(index));
+    }
+
+    @Override
+    protected Iterable<Double> getDoubles() {
+        return Iterables.transform(values, new Function<Long, Double>() {
+            @Override
+            public Double apply(Long value) {
+                return value.doubleValue();
+            }
+        });
+    }
+
+    @Override
+    protected double getDouble(int index) {
+        return values.get(index);
+    }
+
+    @Override
+    protected Iterable<Long> getLongs() {
+        return values;
+    }
+
+    @Override
+    protected long getLong(int index) {
+        return values.get(index);
+    }
+
+    @Override
+    protected Iterable<String> getStrings() {
+        return Iterables.transform(values, new Function<Long, String>() {
+            @Override
+            public String apply(Long value) {
+                return String.valueOf(value);
+            }
+        });
+    }
+
+    @Override
+    protected String getString(int index) {
+        return String.valueOf(values.get(index));
+    }
+
+    @Override
+    public int count() {
+        return values.size();
+    }
+
+    @Override
+    public Type<?> getType() {
+        return LONGS;
+    }
+}

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

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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java?rev=1394655&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java Fri Oct  5 17:10:29 2012
@@ -0,0 +1,157 @@
+/*
+ * 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.math.BigDecimal;
+
+import javax.annotation.Nonnull;
+import javax.jcr.PropertyType;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import org.apache.jackrabbit.oak.api.Blob;
+import org.apache.jackrabbit.oak.api.Type;
+
+abstract class MultiPropertyState extends EmptyPropertyState {
+    protected MultiPropertyState(String name) {
+        super(name);
+    }
+
+    protected abstract Iterable<String> getStrings();
+    protected abstract String getString(int index);
+
+    protected Iterable<Blob> getBlobs() {
+        return Iterables.transform(getStrings(), new Function<String, Blob>() {
+            @Override
+            public Blob apply(String value) {
+                return new StringBasedBlob(value);
+            }
+        });
+    }
+
+    protected Iterable<Long> getLongs() {
+        return Iterables.transform(getStrings(), new Function<String, Long>() {
+            @Override
+            public Long apply(String value) {
+                return Long.parseLong(value);
+            }
+        });
+    }
+
+    protected Iterable<Double> getDoubles() {
+        return Iterables.transform(getStrings(), new Function<String, Double>() {
+            @Override
+            public Double apply(String value) {
+                return Double.parseDouble(value);
+            }
+        });
+    }
+
+    protected Iterable<Boolean> getBooleans() {
+        throw new UnsupportedOperationException("Unsupported conversion.");
+    }
+
+    protected Iterable<BigDecimal> getDecimals() {
+        return Iterables.transform(getStrings(), new Function<String, BigDecimal>() {
+            @Override
+            public BigDecimal apply(String value) {
+                return new BigDecimal(value);
+            }
+        });
+    }
+
+    protected Blob getBlob(int index) {
+        return new StringBasedBlob(getString(index));
+    }
+
+    protected long getLong(int index) {
+        return Long.parseLong(getString(index));
+    }
+
+    protected double getDouble(int index) {
+        return Double.parseDouble(getString(index));
+    }
+
+    protected boolean getBoolean(int index) {
+        throw new UnsupportedOperationException("Unsupported conversion.");
+    }
+
+    protected BigDecimal getDecimal(int index) {
+        return new BigDecimal(getString(index));
+    }
+
+    @SuppressWarnings("unchecked")
+    @Nonnull
+    @Override
+    public <T> T getValue(Type<T> type) {
+        if (!type.isArray()) {
+            throw new IllegalStateException("Not a single valued property");
+        }
+
+        switch (type.tag()) {
+            case PropertyType.STRING: return (T) getStrings();
+            case PropertyType.BINARY: return (T) getBlobs();
+            case PropertyType.LONG: return (T) getLongs();
+            case PropertyType.DOUBLE: return (T) getDoubles();
+            case PropertyType.DATE: return (T) getStrings();
+            case PropertyType.BOOLEAN: return (T) getBooleans();
+            case PropertyType.NAME: return (T) getStrings();
+            case PropertyType.PATH: return (T) getStrings();
+            case PropertyType.REFERENCE: return (T) getStrings();
+            case PropertyType.WEAKREFERENCE: return (T) getStrings();
+            case PropertyType.URI: return (T) getStrings();
+            case PropertyType.DECIMAL: return (T) getDecimals();
+            default: throw new IllegalArgumentException("Invalid type:" + type);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    @Nonnull
+    @Override
+    public <T> T getValue(Type<T> type, int index) {
+        if (type.isArray()) {
+            throw new IllegalArgumentException("Nested arrays not supported");
+        }
+        if (index >= count()) {
+            throw new IndexOutOfBoundsException(String.valueOf(index));
+        }
+
+        switch (type.tag()) {
+            case PropertyType.STRING: return (T) getString(index);
+            case PropertyType.BINARY: return (T) getBlob(index);
+            case PropertyType.LONG: return (T) (Long) getLong(index);
+            case PropertyType.DOUBLE: return (T) (Double) getDouble(index);
+            case PropertyType.DATE: return (T) getString(index);
+            case PropertyType.BOOLEAN: return (T) (Boolean) getBoolean(index);
+            case PropertyType.NAME: return (T) getString(index);
+            case PropertyType.PATH: return (T) getString(index);
+            case PropertyType.REFERENCE: return (T) getString(index);
+            case PropertyType.WEAKREFERENCE: return (T) getString(index);
+            case PropertyType.URI: return (T) getString(index);
+            case PropertyType.DECIMAL: return (T) getString(index);
+            default: throw new IllegalArgumentException("Invalid type:" + type);
+        }
+    }
+
+    @Override
+    public long size(int index) {
+        return getString(index).length();
+    }
+
+}

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

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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/SinglePropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/SinglePropertyState.java?rev=1394655&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/SinglePropertyState.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/SinglePropertyState.java Fri Oct  5 17:10:29 2012
@@ -0,0 +1,134 @@
+/*
+ * 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.math.BigDecimal;
+
+import javax.annotation.Nonnull;
+import javax.jcr.PropertyType;
+
+import org.apache.jackrabbit.oak.api.Blob;
+import org.apache.jackrabbit.oak.api.Type;
+
+import static java.util.Collections.singleton;
+
+abstract class SinglePropertyState extends EmptyPropertyState {
+
+    protected SinglePropertyState(String name) {
+        super(name);
+    }
+
+    protected abstract String getString();
+
+    protected Blob getBlob() {
+        return new StringBasedBlob(getString());
+    }
+
+    protected long getLong() {
+        return Long.parseLong(getString());
+    }
+
+    protected double getDouble() {
+        return Double.parseDouble(getString());
+    }
+
+    protected boolean getBoolean() {
+        throw new UnsupportedOperationException("Unsupported conversion.");
+    }
+
+    protected BigDecimal getDecimal() {
+        return new BigDecimal(getString());
+    }
+
+    @Override
+    public boolean isArray() {
+        return false;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Nonnull
+    @Override
+    public <T> T getValue(Type<T> type) {
+        if (type.isArray()) {
+            switch (type.tag()) {
+                case PropertyType.STRING: return (T) singleton(getString());
+                case PropertyType.BINARY: return (T) singleton(getBlob());
+                case PropertyType.LONG: return (T) singleton(getLong());
+                case PropertyType.DOUBLE: return (T) singleton(getDouble());
+                case PropertyType.DATE: return (T) singleton(getString());
+                case PropertyType.BOOLEAN: return (T) singleton(getBoolean());
+                case PropertyType.NAME: return (T) singleton(getString());
+                case PropertyType.PATH: return (T) singleton(getString());
+                case PropertyType.REFERENCE: return (T) singleton(getString());
+                case PropertyType.WEAKREFERENCE: return (T) singleton(getString());
+                case PropertyType.URI: return (T) singleton(getString());
+                case PropertyType.DECIMAL: return (T) singleton(getDecimal());
+                default: throw new IllegalArgumentException("Invalid primitive type:" + type);
+            }
+        }
+        else {
+            switch (type.tag()) {
+                case PropertyType.STRING: return (T) getString();
+                case PropertyType.BINARY: return (T) getBlob();
+                case PropertyType.LONG: return (T) (Long) getLong();
+                case PropertyType.DOUBLE: return (T) (Double) getDouble();
+                case PropertyType.DATE: return (T) getString();
+                case PropertyType.BOOLEAN: return (T) (Boolean) getBoolean();
+                case PropertyType.NAME: return (T) getString();
+                case PropertyType.PATH: return (T) getString();
+                case PropertyType.REFERENCE: return (T) getString();
+                case PropertyType.WEAKREFERENCE: return (T) getString();
+                case PropertyType.URI: return (T) getString();
+                case PropertyType.DECIMAL: return (T) getDecimal();
+                default: throw new IllegalArgumentException("Invalid array type:" + type);
+            }
+        }
+    }
+
+    @Nonnull
+    @Override
+    public <T> T getValue(Type<T> type, int index) {
+        if (type.isArray()) {
+            throw new IllegalArgumentException("Nested arrows not supported");
+        }
+        if (index != 0) {
+            throw new IndexOutOfBoundsException(String.valueOf(index));
+        }
+        return getValue(type);
+    }
+
+    @Override
+    public long size() {
+        return getString().length();
+    }
+
+    @Override
+    public long size(int index) {
+        if (index != 0) {
+            throw new IndexOutOfBoundsException(String.valueOf(index));
+        }
+        return size();
+    }
+
+    @Override
+    public int count() {
+        return 1;
+    }
+
+}

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

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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/StringBasedBlob.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/StringBasedBlob.java?rev=1394655&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/StringBasedBlob.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/StringBasedBlob.java Fri Oct  5 17:10:29 2012
@@ -0,0 +1,54 @@
+/*
+ * 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 java.io.UnsupportedEncodingException;
+
+import javax.annotation.Nonnull;
+
+public class StringBasedBlob extends AbstractBlob {
+    private final String value;
+
+    public StringBasedBlob(String value) {
+        this.value = value;
+    }
+
+    @Nonnull
+    @Override
+    public InputStream getNewStream() {
+        try {
+            return new ByteArrayInputStream(value.getBytes("UTF-8"));
+        }
+        catch (UnsupportedEncodingException e) {
+            throw new IllegalStateException("UTF-8 is not supported", e);
+        }
+    }
+
+    @Override
+    public long length() {
+        try {
+            return value.getBytes("UTF-8").length;
+        }
+        catch (UnsupportedEncodingException e) {
+            throw new IllegalStateException("UTF-8 is not supported", e);
+        }
+    }
+}

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

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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/StringPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/StringPropertyState.java?rev=1394655&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/StringPropertyState.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/StringPropertyState.java Fri Oct  5 17:10:29 2012
@@ -0,0 +1,48 @@
+/*
+ * 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 org.apache.jackrabbit.oak.api.Type;
+
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+
+public class StringPropertyState extends SinglePropertyState {
+    private final String value;
+
+    protected StringPropertyState(String name, String value) {
+        super(name);
+        this.value = value;
+    }
+
+    @Override
+    protected String getString() {
+        return value;
+    }
+
+    @Override
+    protected boolean getBoolean() {
+        return Boolean.parseBoolean(value);
+    }
+
+    @Override
+    public Type<?> getType() {
+        return STRING;
+    }
+
+}

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

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

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/StringsPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/StringsPropertyState.java?rev=1394655&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/StringsPropertyState.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/StringsPropertyState.java Fri Oct  5 17:10:29 2012
@@ -0,0 +1,69 @@
+/*
+ * 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.util.List;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import org.apache.jackrabbit.oak.api.Type;
+
+public class StringsPropertyState extends MultiPropertyState {
+    private final List<String> values;
+
+    protected StringsPropertyState(String name, List<String> values) {
+        super(name);
+        this.values = values;
+    }
+
+    @Override
+    protected Iterable<String> getStrings() {
+        return values;
+    }
+
+    @Override
+    protected String getString(int index) {
+        return values.get(index);
+    }
+
+    @Override
+    protected Iterable<Boolean> getBooleans() {
+        return Iterables.transform(values, new Function<String, Boolean>() {
+            @Override
+            public Boolean apply(String value) {
+                return Boolean.parseBoolean(value);
+            }
+        });
+    }
+
+    @Override
+    protected boolean getBoolean(int index) {
+        return Boolean.parseBoolean(getString(index));
+    }
+
+    @Override
+    public int count() {
+        return values.size();
+    }
+
+    @Override
+    public Type<?> getType() {
+        return Type.STRINGS;
+    }
+}

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

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