|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.entityfs.util.AggregatingEntityRepository
public class AggregatingEntityRepository
This is an EntityRepository
that aggregates the contents
of several entity repositories. It can be used to make several directories
look as one.
This object keeps an internal list of all repositories supplied to the constructor. When the client requests an entity, all repositories in the list are searched until the entity is found.
The read lock of this object is a CompoundEntityLock
over all
aggregated repositories. This object does not have any write lock since it is
read only.
Constructor Summary | |
---|---|
AggregatingEntityRepository(Collection<? extends EntityRepository> c)
Create a new object. |
Method Summary | |
---|---|
boolean |
containsEntity(EntityView ev)
Does this entity holder contain the supplied entity? If this is called on a symbolic link, it is checked if the link target is a directory and that directory contains the entity. |
boolean |
containsEntity(String name)
Can an entity with the given name be retrieved from this object? If this is called on a symbolic link, it is checked if the link target is a directory and that directory contains an entity with the given name. |
EntityView |
getEntityOrNull(String name)
Get the named entity. |
EntityLock |
getReadLock()
Get the read lock without locking it. |
boolean |
isEmpty()
Is the listable empty? If a directory view is empty, the viewed directory may still contain entities that are hidden by the view's filter. |
boolean |
isReadLockedByCurrentThread()
Does the calling thread hold a read lock for this object? A write lock also qualifies as a read lock. |
Iterator<EntityView> |
iterator()
|
Set<EntityView> |
listEntities()
Return all entities that are visible in this directory. |
EntityLock |
lockForReading()
Lock object for reading and return the lock. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AggregatingEntityRepository(Collection<? extends EntityRepository> c)
c
- A collection of repositories. The repositories are added to the
internal list of repositories in the order that they are returned when
iterating over the collection.Method Detail |
---|
public EntityLock getReadLock()
ReadLockable
This method always returns a lock, even if the object's file system is not locking or if the object is read only.
getReadLock
in interface ReadLockable
public EntityLock lockForReading()
ReadLockable
EntityLockAdapterFactory
and
LockAcquiringStrategy
used. If this is called on an object that
somehow is connected to an entity object, that entity's file system's
entity lock adapter factory and lock acquiring strategy is used.
A read lock cannot be upgraded to a write lock (just like how Java's
ReadWriteLock
works).
For more discussions on locks and locking, see Entity
and
FileSystem
.
This method always returns a lock, even if the object's file system is not locking or if the object is read only.
lockForReading
in interface ReadLockable
public boolean isReadLockedByCurrentThread()
ReadLockable
isReadLockedByCurrentThread
in interface ReadLockable
true
if the lockable object is read or write locked by
the current thread.public boolean isEmpty()
EntityListable
isEmpty
in interface EntityListable
true
if the directory view is empty.public boolean containsEntity(String name)
EntityHolder
containsEntity
in interface EntityHolder
name
- The name of the entity.
true
if there is an entity with the given name referenced
by this holder.public boolean containsEntity(EntityView ev)
EntityHolder
containsEntity
in interface EntityHolder
ev
- The entity (or a view of it).
true
If the entity holder contains the supplied entity.public Set<EntityView> listEntities()
EntityListable
If this is called on a directory view, all returned ViewCapable
entities inherit the view's filters.
listEntities
in interface EntityListable
Set
of entity views. If this is called on a directory
entity object, a set of entity objects (not views) are returned. The set
may be empty, but never null
.public EntityView getEntityOrNull(String name)
EntityHolder
If this is called on a directory view, and the returned entity is
ViewCapable
, the returned entity view inherits the same view
settings as the directory view (same filter instances).
If this is called on an EntityHolder
that contains several
entities with the same name, the implementation may choose how to deal
with that. This can never happen for directories since entity names in a
directory are required to be unique.
getEntityOrNull
in interface EntityHolder
name
- The name of the entity.
EntityView
or null
. If this method is called
on a DirectoryView
and the returned entity is ViewCapable
, the returned object inherits the view settings of the parent. If the
returned entity is a file, the returned object can be cast to an
EFile
, if it is a directory, it can be cast to a
DirectoryView
(or a Directory
if this method is called on
a Directory
rather than a DirectoryView
). The type of the
returned object can be determined by calling its
EntityView.getType()
method or by using instanceof
.public Iterator<EntityView> iterator()
iterator
in interface Iterable<EntityView>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |