diff options
author | Eike Stepper | 2016-09-24 04:51:14 +0000 |
---|---|---|
committer | Eike Stepper | 2016-09-24 04:51:14 +0000 |
commit | c2093a6e13fa9a1fc8c2292e189485b56bf43a11 (patch) | |
tree | 9e05165d9c0b9ad799d8b786012c182e6a7b3f9b /plugins/org.eclipse.net4j.util/src | |
parent | dbb75e2acebb5fb443056e76840d256ea4f439b1 (diff) | |
download | cdo-c2093a6e13fa9a1fc8c2292e189485b56bf43a11.tar.gz cdo-c2093a6e13fa9a1fc8c2292e189485b56bf43a11.tar.xz cdo-c2093a6e13fa9a1fc8c2292e189485b56bf43a11.zip |
[402714] Local changes are not considered by CDOTransaction's queryResources(), queryInstances() and queryXRefs()
https://bugs.eclipse.org/bugs/show_bug.cgi?id=402714
Diffstat (limited to 'plugins/org.eclipse.net4j.util/src')
3 files changed, 102 insertions, 2 deletions
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/AbstractCloseableIterator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/AbstractCloseableIterator.java new file mode 100644 index 0000000000..c67be45ced --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/AbstractCloseableIterator.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2004-2016 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.util.collection; + +/** + * @author Eike Stepper + * @since 3.7 + */ +public abstract class AbstractCloseableIterator<E> extends AbstractIterator<E> implements CloseableIterator<E> +{ + public AbstractCloseableIterator() + { + } + + @Override + protected abstract Object computeNextElement(); + + public abstract void close(); + + public abstract boolean isClosed(); + + @SuppressWarnings("unchecked") + public static <T> CloseableIterator<T> emptyCloseable() + { + return (CloseableIterator<T>)EmptyIterator.INSTANCE; + } +} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/AbstractIterator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/AbstractIterator.java index 0eeb8818ad..e9598c92be 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/AbstractIterator.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/AbstractIterator.java @@ -89,9 +89,9 @@ public abstract class AbstractIterator<T> implements Iterator<T> /** * @author Eike Stepper */ - private static final class EmptyIterator implements ListIterator<Object> + static final class EmptyIterator implements ListIterator<Object>, CloseableIterator<Object> { - private static final ListIterator<Object> INSTANCE = new EmptyIterator(); + static final ListIterator<Object> INSTANCE = new EmptyIterator(); public boolean hasNext() { @@ -137,5 +137,15 @@ public abstract class AbstractIterator<T> implements Iterator<T> { throw new UnsupportedOperationException(); } + + public void close() + { + // Do nothing. + } + + public boolean isClosed() + { + return true; + } } } diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/DelegatingCloseableIterator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/DelegatingCloseableIterator.java new file mode 100644 index 0000000000..b58624d08f --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/DelegatingCloseableIterator.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2004-2016 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.util.collection; + +import java.util.Iterator; +import java.util.NoSuchElementException; + +/** + * @author Eike Stepper + * @since 3.7 + */ +public class DelegatingCloseableIterator<E> implements CloseableIterator<E> +{ + private final Iterator<E> delegate; + + private boolean closed; + + public DelegatingCloseableIterator(Iterator<E> delegate) + { + this.delegate = delegate; + } + + public boolean hasNext() + { + return !closed && delegate.hasNext(); + } + + public E next() + { + if (closed) + { + throw new NoSuchElementException(); + } + + return delegate.next(); + } + + public void close() + { + closed = true; + } + + public boolean isClosed() + { + return closed; + } +} |