jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1299472 - in /jackrabbit/sandbox/jackrabbit-microkernel: ./ src/main/java/org/apache/jackrabbit/ src/main/java/org/apache/jackrabbit/state/ src/main/java/org/apache/jackrabbit/utils/
Date Sun, 11 Mar 2012 22:38:32 GMT
Author: mduerig
Date: Sun Mar 11 22:38:32 2012
New Revision: 1299472

URL: http://svn.apache.org/viewvc?rev=1299472&view=rev
Log:
Microkernel based prototype of JCR implementation (WIP)
- remove spi-commons dependency 

Added:
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Function1.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Iterators.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Predicate.java
Modified:
    jackrabbit/sandbox/jackrabbit-microkernel/pom.xml
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/NodeImpl.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/EmptyNodeState.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientNodeState.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientSpace.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Predicates.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/RangeIteratorAdapter.java

Modified: jackrabbit/sandbox/jackrabbit-microkernel/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/pom.xml?rev=1299472&r1=1299471&r2=1299472&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/pom.xml (original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/pom.xml Sun Mar 11 22:38:32 2012
@@ -53,11 +53,6 @@
         </dependency>
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
-            <artifactId>jackrabbit-spi-commons</artifactId>
-            <version>2.4-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.jackrabbit</groupId>
             <artifactId>oak-core</artifactId>
             <version>0.1-SNAPSHOT</version>
         </dependency>

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/NodeImpl.java?rev=1299472&r1=1299471&r2=1299472&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/NodeImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/NodeImpl.java
Sun Mar 11 22:38:32 2012
@@ -23,13 +23,13 @@ import org.apache.jackrabbit.SessionImpl
 import org.apache.jackrabbit.json.JsonValue;
 import org.apache.jackrabbit.json.JsonValue.JsonAtom;
 import org.apache.jackrabbit.oak.model.PropertyState;
-import org.apache.jackrabbit.spi.commons.iterator.Iterators;
-import org.apache.jackrabbit.spi.commons.iterator.Predicate;
-import org.apache.jackrabbit.spi.commons.iterator.Transformer;
 import org.apache.jackrabbit.state.PropertyStateImpl;
 import org.apache.jackrabbit.state.TransientNodeState;
+import org.apache.jackrabbit.utils.Function1;
 import org.apache.jackrabbit.utils.ItemNameMatcher;
+import org.apache.jackrabbit.utils.Iterators;
 import org.apache.jackrabbit.utils.NodeIteratorAdapter;
+import org.apache.jackrabbit.utils.Predicate;
 import org.apache.jackrabbit.utils.PropertyIteratorAdapter;
 import org.apache.jackrabbit.utils.ValueConverter;
 
@@ -592,18 +592,18 @@ public class NodeImpl extends ItemImpl i
     }
 
     private Iterator<Node> nodeIterator(Iterator<TransientNodeState> childNodeStates)
{
-        return Iterators.transformIterator(childNodeStates, new Transformer<TransientNodeState,
Node>() {
+        return Iterators.map(childNodeStates, new Function1<TransientNodeState, Node>()
{
             @Override
-            public Node transform(TransientNodeState state) {
+            public Node apply(TransientNodeState state) {
                 return NodeImpl.create(sessionContext, state);
             }
         });
     }
 
     private Iterator<Property> propertyIterator(Iterator<PropertyState> properties)
{
-        return Iterators.transformIterator(properties, new Transformer<PropertyState,
Property>() {
+        return Iterators.map(properties, new Function1<PropertyState, Property>() {
             @Override
-            public Property transform(PropertyState state) { // fixme don't cast
+            public Property apply(PropertyState state) { // fixme don't cast
                 JsonValue value = ((PropertyStateImpl) state).getValue();
                 return PropertyImpl.create(sessionContext, NodeImpl.this.state, state.getName(),
value);
             }

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java?rev=1299472&r1=1299471&r2=1299472&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
Sun Mar 11 22:38:32 2012
@@ -24,9 +24,9 @@ import org.apache.jackrabbit.Path;
 import org.apache.jackrabbit.json.JsonValue;
 import org.apache.jackrabbit.json.JsonValue.JsonAtom;
 import org.apache.jackrabbit.oak.model.PropertyState;
-import org.apache.jackrabbit.spi.commons.iterator.Iterators;
-import org.apache.jackrabbit.spi.commons.iterator.Predicate;
-import org.apache.jackrabbit.spi.commons.iterator.Transformer;
+import org.apache.jackrabbit.utils.Function1;
+import org.apache.jackrabbit.utils.Iterators;
+import org.apache.jackrabbit.utils.Predicate;
 
 import javax.jcr.ItemExistsException;
 import javax.jcr.ItemNotFoundException;
@@ -221,7 +221,7 @@ public class ChangeTree {
          * @return  Iterator of all added nodes
          */
         public Iterator<NodeDelta> getNodes() {
-            return Iterators.filterIterator(childNodes().iterator(), new Predicate<NodeDelta>()
{
+            return Iterators.filter(childNodes().iterator(), new Predicate<NodeDelta>()
{
                 @Override
                 public boolean evaluate(NodeDelta delta) {
                     return delta.isTransient() && !delta.isRemoved();
@@ -261,21 +261,21 @@ public class ChangeTree {
          */
         public Iterator<PropertyState> getPropertyStates() {
             Iterator<Entry<String, JsonValue>> entries =
-                Iterators.filterIterator(properties.entrySet().iterator(),
-                    new Predicate<Entry<String, JsonValue>>() {
+                Iterators.filter(properties.entrySet().iterator(),
+                        new Predicate<Entry<String, JsonValue>>() {
+                            @Override
+                            public boolean evaluate(Entry<String, JsonValue> entry)
{
+                                return entry.getValue() != JsonAtom.NULL;
+                            }
+                        });
+
+            return Iterators.map(entries,
+                    new Function1<Entry<String, JsonValue>, PropertyState>()
{
                         @Override
-                        public boolean evaluate(Entry<String, JsonValue> entry) {
-                            return entry.getValue() != JsonAtom.NULL;
+                        public PropertyState apply(final Entry<String, JsonValue> entry)
{
+                            return new PropertyStateImpl(entry.getKey(), entry.getValue());
                         }
                     });
-
-            return Iterators.transformIterator(entries,
-                new Transformer<Entry<String, JsonValue>, PropertyState>() {
-                    @Override
-                    public PropertyState transform(final Entry<String, JsonValue> entry)
{
-                        return new PropertyStateImpl(entry.getKey(), entry.getValue());
-                    }
-                });
         }
 
         /**

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/EmptyNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/EmptyNodeState.java?rev=1299472&r1=1299471&r2=1299472&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/EmptyNodeState.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/EmptyNodeState.java
Sun Mar 11 22:38:32 2012
@@ -3,7 +3,7 @@ package org.apache.jackrabbit.state;
 import org.apache.jackrabbit.oak.model.AbstractNodeState;
 import org.apache.jackrabbit.oak.model.ChildNodeEntry;
 import org.apache.jackrabbit.oak.model.PropertyState;
-import org.apache.jackrabbit.spi.commons.iterator.Iterators;
+import org.apache.jackrabbit.utils.Iterators;
 
 import java.util.Iterator;
 

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientNodeState.java?rev=1299472&r1=1299471&r2=1299472&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientNodeState.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientNodeState.java
Sun Mar 11 22:38:32 2012
@@ -27,10 +27,10 @@ import org.apache.jackrabbit.mk.api.Micr
 import org.apache.jackrabbit.oak.model.ChildNodeEntry;
 import org.apache.jackrabbit.oak.model.NodeState;
 import org.apache.jackrabbit.oak.model.PropertyState;
-import org.apache.jackrabbit.spi.commons.iterator.Iterators;
-import org.apache.jackrabbit.spi.commons.iterator.Predicate;
-import org.apache.jackrabbit.spi.commons.iterator.Transformer;
 import org.apache.jackrabbit.state.ChangeTree.NodeDelta;
+import org.apache.jackrabbit.utils.Function1;
+import org.apache.jackrabbit.utils.Iterators;
+import org.apache.jackrabbit.utils.Predicate;
 
 import javax.jcr.ItemExistsException;
 import javax.jcr.ItemNotFoundException;
@@ -100,35 +100,35 @@ public class TransientNodeState {
         final NodeDelta delta = getNodeDelta();
 
         // fixme: this is not safe against concurrent modifications. Either copy delta or
make NodeDelta immutable
-        Iterator<ChildNodeEntry> unmodifiedEntries = Iterators.filterIterator(persistedEntries.iterator(),
-            new Predicate<ChildNodeEntry>() {
-                @Override
-                public boolean evaluate(ChildNodeEntry entry) {
-                    return !delta.isNodeModified(entry.getName());
-                }
-            });
+        Iterator<ChildNodeEntry> unmodifiedEntries = Iterators.filter(persistedEntries.iterator(),
+                new Predicate<ChildNodeEntry>() {
+                    @Override
+                    public boolean evaluate(ChildNodeEntry entry) {
+                        return !delta.isNodeModified(entry.getName());
+                    }
+                });
         
-        Iterator<TransientNodeState> unmodifiedStates = Iterators.transformIterator(unmodifiedEntries,

-            new Transformer<ChildNodeEntry, TransientNodeState>() {
-                @Override
-                public TransientNodeState transform(ChildNodeEntry entry) {
-                    return getNodeState(sessionContext, delta.getNode(entry.getName()));
-                }
-        });
-
-        Iterator<TransientNodeState> modifiedStates = Iterators.transformIterator(delta.getNodes(),
-            new Transformer<NodeDelta, TransientNodeState>() {
-                @Override
-                public TransientNodeState transform(NodeDelta delta) {
-                    return getNodeState(sessionContext, delta);
-                }
-            });
+        Iterator<TransientNodeState> unmodifiedStates = Iterators.map(unmodifiedEntries,
+                new Function1<ChildNodeEntry, TransientNodeState>() {
+                    @Override
+                    public TransientNodeState apply(ChildNodeEntry entry) {
+                        return getNodeState(sessionContext, delta.getNode(entry.getName()));
+                    }
+                });
+
+        Iterator<TransientNodeState> modifiedStates = Iterators.map(delta.getNodes(),
+                new Function1<NodeDelta, TransientNodeState>() {
+                    @Override
+                    public TransientNodeState apply(NodeDelta delta) {
+                        return getNodeState(sessionContext, delta);
+                    }
+                });
 
         return Iterators.iteratorChain(unmodifiedStates, modifiedStates);
     }
 
     public Iterator<TransientNodeState> getChildNodeStates(Predicate<TransientNodeState>
condition) {
-        return Iterators.filterIterator(getChildNodeStates(), condition);
+        return Iterators.filter(getChildNodeStates(), condition);
     }
 
     public boolean hasProperties() {
@@ -141,7 +141,7 @@ public class TransientNodeState {
 
         // fixme: this is not safe against concurrent modifications. Either copy delta or
make NodeDelta immutable
         Iterator<PropertyState> propertyEntries =
-            Iterators.filterIterator(propertyStates.iterator(),
+            Iterators.filter(propertyStates.iterator(),
                     new Predicate<PropertyState>() {
                         @Override
                         public boolean evaluate(PropertyState state) {
@@ -153,7 +153,7 @@ public class TransientNodeState {
     }
 
     public Iterator<PropertyState> getProperties(Predicate<PropertyState> condition)
{
-        return Iterators.filterIterator(getProperties(), condition);
+        return Iterators.filter(getProperties(), condition);
     }
 
     public JsonValue getPropertyValue(String name) throws ItemNotFoundException {

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientSpace.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientSpace.java?rev=1299472&r1=1299471&r2=1299472&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientSpace.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientSpace.java
Sun Mar 11 22:38:32 2012
@@ -23,9 +23,9 @@ import org.apache.jackrabbit.Path;
 import org.apache.jackrabbit.json.JsonValue;
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.api.MicroKernelException;
-import org.apache.jackrabbit.spi.commons.iterator.Predicate;
 import org.apache.jackrabbit.state.ChangeTree.Listener;
 import org.apache.jackrabbit.state.ChangeTree.NodeDelta;
+import org.apache.jackrabbit.utils.Predicate;
 
 import javax.jcr.RepositoryException;
 

Added: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Function1.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Function1.java?rev=1299472&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Function1.java
(added)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Function1.java
Sun Mar 11 22:38:32 2012
@@ -0,0 +1,34 @@
+/*
+ * 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.utils;
+
+/**
+ * Type safe counter part of {@link org.apache.commons.collections.Transformer}.
+ *
+ * @param <S>  argument type to transform from
+ * @param <T>  result type to transform to
+ */
+public interface Function1<S, T> {
+
+    /**
+     * Apply this function to its argument.
+     *
+     * @param argument
+     * @return
+     */
+    T apply(S argument);
+}

Added: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Iterators.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Iterators.java?rev=1299472&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Iterators.java
(added)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Iterators.java
Sun Mar 11 22:38:32 2012
@@ -0,0 +1,204 @@
+/*
+ * 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.utils;
+
+import org.apache.commons.collections.iterators.ArrayIterator;
+import org.apache.commons.collections.iterators.EmptyIterator;
+import org.apache.commons.collections.iterators.FilterIterator;
+import org.apache.commons.collections.iterators.IteratorChain;
+import org.apache.commons.collections.iterators.SingletonIterator;
+import org.apache.commons.collections.iterators.TransformIterator;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * Utility class containing type safe adapters for some of the iterators of
+ * commons-collections.
+ */
+public final class Iterators {
+
+    private Iterators() { }
+
+    /**
+     * Returns an iterator containing the single element {@code element} of
+     * type {@code T}.
+     *
+     * @param <T>
+     * @param element
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> Iterator<T> singleton(T element) {
+        return new SingletonIterator(element);
+    }
+
+    /**
+     * Returns an empty iterator of type {@code T}.
+     *
+     * @param <T>
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> Iterator<T> empty() {
+        return EmptyIterator.INSTANCE;
+    }
+
+    /**
+     * Returns an iterator for the concatenation of {@code iterator1} and
+     * {@code iterator2}.
+     *
+     * @param <T>
+     * @param iterator1
+     * @param iterator2
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> Iterator<T> iteratorChain(Iterator<? extends T> iterator1,
Iterator<? extends T> iterator2) {
+        return new IteratorChain(iterator1, iterator2);
+    }
+
+    /**
+     * Returns an iterator for the concatenation of all the given {@code iterators}.
+     *
+     * @param <T>
+     * @param iterators
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> Iterator<T> chain(Iterator<? extends T>[] iterators)
{
+        return new IteratorChain(iterators);
+    }
+
+    /**
+     * Returns an iterator for the concatenation of all the given {@code iterators}.
+     *
+     * @param <T>
+     * @param iterators
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> Iterator<T> chain(Collection<? extends T> iterators)
{
+        return new IteratorChain(iterators);
+    }
+
+    /**
+     * Returns an iterator for elements of an array of {@code values}.
+     *
+     * @param <T>
+     * @param values  the array to iterate over.
+     * @param from  the index to start iterating at.
+     * @param to  the index to finish iterating at.
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> Iterator<T> arrayIterator(T[] values, int from, int to)
{
+        return new ArrayIterator(values, from, to);
+    }
+
+    /**
+     * Returns an iterator with elements from an original {@code iterator} where the
+     * given {@code predicate} matches removed.
+     *
+     * @param <T>
+     * @param iterator
+     * @param predicate
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> Iterator<T> filter(Iterator<? extends T> iterator,
+            final Predicate<? super T> predicate) {
+
+        return new FilterIterator(iterator, new org.apache.commons.collections.Predicate()
{
+            @Override
+            public boolean evaluate(Object object) {
+                return predicate.evaluate((T) object);
+            }
+        });
+    }
+
+    /**
+     * Returns an iterator with elements of an original  {@code iterator} mapped by
+     * a {@code f}.
+     *
+     * @param <T>
+     * @param <R>
+     * @param <S>
+     * @param iterator
+     * @param f
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    public static <T, R, S extends T> Iterator<R> map(Iterator<? extends T>
iterator,
+            final Function1<S, ? super R> f) {
+
+        return new TransformIterator(iterator, new org.apache.commons.collections.Transformer()
{
+            @Override
+            public Object transform(Object input) {
+                return f.apply((S) input);
+            }
+        });
+    }
+
+    /**
+     * Flattens an iterator of iterators into a single iterator.
+     * @param iterators
+     * @param <T>
+     * @return
+     */
+    public static <T> Iterator<? extends T> flatten(final Iterator<Iterator<?
extends T>> iterators) {
+        return new Iterator<T>() {
+            private Iterator<? extends T> current;
+
+            @Override
+            public boolean hasNext() {
+                if (current != null && current.hasNext()) {
+                    return true;
+                }
+                else if (!iterators.hasNext()) {
+                    return false;
+                }
+                else {
+                    do {
+                        current = iterators.next();
+                    } while (!current.hasNext() && iterators.hasNext());
+                    return current.hasNext();
+                }
+            }
+
+            @Override
+            public T next() {
+                if (!hasNext()) {
+                    throw new NoSuchElementException();
+                }
+
+                return current.next();
+            }
+
+            @Override
+            public void remove() {
+                if (current == null) {
+                    throw new IllegalStateException();
+                }
+
+                current.remove();
+            }
+        };
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Predicate.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Predicate.java?rev=1299472&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Predicate.java
(added)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Predicate.java
Sun Mar 11 22:38:32 2012
@@ -0,0 +1,33 @@
+/*
+ * 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.utils;
+
+/**
+ * Type safe counter part of {@link org.apache.commons.collections.Predicate}.
+ *
+ * @param <T> type of values this predicate is defined on
+ */
+public interface Predicate<T> {
+
+    /**
+     * Use the specified parameter to perform a test that returns true or false.
+     *
+     * @param arg  the predicate to evaluate, should not be changed
+     * @return true or false
+     */
+    boolean evaluate(T arg);
+}

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Predicates.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Predicates.java?rev=1299472&r1=1299471&r2=1299472&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Predicates.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Predicates.java
Sun Mar 11 22:38:32 2012
@@ -19,8 +19,6 @@
 
 package org.apache.jackrabbit.utils;
 
-import org.apache.jackrabbit.spi.commons.iterator.Predicate;
-
 public final class Predicates {
     public static final Predicate<?> TRUE = constant(true);
     public static final Predicate<?> FALSE = constant(false);

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/RangeIteratorAdapter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/RangeIteratorAdapter.java?rev=1299472&r1=1299471&r2=1299472&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/RangeIteratorAdapter.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/RangeIteratorAdapter.java
Sun Mar 11 22:38:32 2012
@@ -19,8 +19,6 @@
 
 package org.apache.jackrabbit.utils;
 
-import org.apache.jackrabbit.spi.commons.iterator.Iterators;
-
 import javax.jcr.RangeIterator;
 import java.util.Collection;
 import java.util.Iterator;



Mime
View raw message