Package org.ametys.plugins.repository
Class NodeIteratorIterable<A extends AmetysObject>
- java.lang.Object
-
- org.ametys.plugins.repository.NodeIteratorIterable<A>
-
- Type Parameters:
A- the actual type ofAmetysObjects.
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<A>,AmetysObjectIterable<A>
public class NodeIteratorIterable<A extends AmetysObject> extends Object implements AmetysObjectIterable<A>
Implementation ofAmetysObjectIterablebased on a underlying JCRNodeIterator.
Please note that this implementation only works with NodeIterators containing nodes actually bound to AmetysObjects.
If a node exists in the iterator and does not correspond to anAmetysObject, anAmetysRepositoryExceptionwill be thrown.
UnlessAmetysObjectIterator.skip(long)is called on the underlying Iterator, results are buffered so that one may safely calliterator()more than once, even if the underlyingNodeIteratorwill be consumed only once.
IfAmetysObjectIterator.skip(long)is called, any subsequent call toiterator()will throw anIllegalStateException.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classNodeIteratorIterable.NodeIteratorIterator
-
Field Summary
Fields Modifier and Type Field Description (package private) List<A>_bufferprivate NodeIterator_iterator(package private) String_parentPath(package private) AmetysObjectResolver_resolver(package private) Session_session(package private) boolean_skipCalled
-
Constructor Summary
Constructors Constructor Description NodeIteratorIterable(AmetysObjectResolver resolver, NodeIterator iterator, String parentPath, Session session)Creates aNodeIteratorIterable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the associated resources.
AnAmetysObjectIterablemust NOT be closed if any of the containedAmetysObjectis still in use.longgetSize()Returns the number of elements in this iterable.AmetysObjectIterator<A>iterator()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ametys.plugins.repository.AmetysObjectIterable
spliterator, stream
-
-
-
-
Field Detail
-
_resolver
AmetysObjectResolver _resolver
-
_parentPath
String _parentPath
-
_buffer
List<A extends AmetysObject> _buffer
-
_skipCalled
boolean _skipCalled
-
_iterator
private NodeIterator _iterator
-
-
Constructor Detail
-
NodeIteratorIterable
public NodeIteratorIterable(AmetysObjectResolver resolver, NodeIterator iterator, String parentPath, Session session)
Creates aNodeIteratorIterable.- Parameters:
resolver- the applicationAmetysObjectResolver.iterator- the underlyingNodeIterator.parentPath- the parent path in the Ametys hierarchy of allAmetysObjectbeing returned.session- the JCR Session corresponding to the specified NodeIterator
-
-
Method Detail
-
getSize
public long getSize()
Description copied from interface:AmetysObjectIterableReturns the number of elements in this iterable. If this information is unavailable, returns -1.- Specified by:
getSizein interfaceAmetysObjectIterable<A extends AmetysObject>- Returns:
- a long
-
iterator
public AmetysObjectIterator<A> iterator()
- Specified by:
iteratorin interfaceAmetysObjectIterable<A extends AmetysObject>- Specified by:
iteratorin interfaceIterable<A extends AmetysObject>
-
close
public void close()
Description copied from interface:AmetysObjectIterableClose the associated resources.
AnAmetysObjectIterablemust NOT be closed if any of the containedAmetysObjectis still in use.- Specified by:
closein interfaceAmetysObjectIterable<A extends AmetysObject>- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-