org.entityfs
Interface DirectoryView

All Superinterfaces:
Comparable<EntityView>, Deletable, EntityAcceptingEntityView<DirectoryView>, EntityHolder, EntityListable, EntityRepository, EntityView, Iterable<EntityView>, Lockable, Named, Observable, ReadLockable, ReadWriteLockable, ViewCapable<DirectoryView>, WriteLockable
All Known Subinterfaces:
Directory, DirectoryImplementation, DirectoryViewImplementation
All Known Implementing Classes:
DirectoryImpl, DirectoryViewImpl

public interface DirectoryView
extends EntityAcceptingEntityView<DirectoryView>, EntityRepository

A DirectoryView is a view of a directory that uses a Filter to hide child entities that does not pass the filter. A directory can have any number of views associated with it and views can also be nested.

The directory view is Iterable over its child entities. The iterator method requires execute access to and a read lock for the directory. To iterate recursively over all entities in the directory's subtree, use one of the iterator methods in Directories.

A directory view is Observable for updates. It can send the following events:

When registering an EntityObserver on a view rather on an entity, the view puts itself as the sender of the events. If an event contain child entities (is a ChildEntitiesEvent), all included child entities are filtered and views with the same filter rules as the observed view are created for ViewCapable child entities.

Read more about views in the EntityView documentation.

Since:
1.0
Author:
Karl Gustafsson
See Also:
Entities, EntityAcceptingEntities, Directories, PollingDirectoryMonitorer
In_jar:
entityfs-core

Method Summary
 String getUniqueEntityName(String prefix, String suffix)
          Get a unique entity name with the given prefix and suffix in the directory.
 EntityView newEntity(EntityType et, String name, Object data)
          Create a new child entity in the directory.
 
Methods inherited from interface org.entityfs.EntityAcceptingEntityView
canBeDereferenced, dereferenceOrNull
 
Methods inherited from interface org.entityfs.EntityView
canRead, canWrite, copy, copy, copyAttributes, createLock, disconnect, getCapability, getFileSystem, getLastModified, getParent, getType, getViewed, getViewedEntity, isConnected, isRootDirectory, isValid, lock, rename, setLastModified, supportsCapability, touch
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface org.entityfs.event.Observable
addObserver, countObservers, deleteObserver, deleteObservers
 
Methods inherited from interface org.entityfs.Named
getName
 
Methods inherited from interface org.entityfs.lock.ReadLockable
getReadLock, isReadLockedByCurrentThread, lockForReading
 
Methods inherited from interface org.entityfs.Deletable
delete, isDeleted
 
Methods inherited from interface org.entityfs.lock.WriteLockable
getWriteLock, isWriteLockedByCurrentThread, lockForWriting
 
Methods inherited from interface org.entityfs.ViewCapable
getFilter, hasFilters, newView
 
Methods inherited from interface org.entityfs.EntityHolder
containsEntity, containsEntity, getEntityOrNull
 
Methods inherited from interface org.entityfs.EntityListable
isEmpty, listEntities
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

newEntity

EntityView newEntity(EntityType et,
                     String name,
                     Object data)
                     throws EntityFoundException,
                            IllegalArgumentException,
                            IllegalStateException,
                            WriteLockRequiredException,
                            AccessDeniedException
Create a new child entity in the directory. If this is called on a directory view, and the created entity is ViewCapable, a view with the same filter instances as the directory view is returned.

Directories also contains methods for creating child entities.

Parameters:
et - The type of the entity to create.
name - The name of the new entity.
data - Entity type-specific data needed to create the entity. Most entity types (files and directories) happily accept null.
Returns:
The new entity. If the entity is ViewCapable, it inherits the view settings of this directory view. The result can be casted to the entity interface specified by the supplied entity type, et. For instance to an EFile if et is an ETFile or to a DirectoryView if et is an ETDirectory.
Throws:
EntityFoundException - If an entity with the same name already exists in the directory.
IllegalArgumentException - If the entity name is invalid in the file system.
IllegalStateException - If the view is disconnected.
WriteLockRequiredException - If the client does not have a write lock for the directory.
AccessDeniedException - If the client does not have write access to the directory.
Locks_required:
A write lock.
Permissions_required:
Write access.
Generates_events:
ChildEntityAddedEvent for this., EntityModifiedEvent for this., NewEntityEvent for the created entity., ChildEntityModifiedEvent for this's parent directory.

getUniqueEntityName

String getUniqueEntityName(String prefix,
                           String suffix)
                           throws IllegalArgumentException,
                                  IllegalStateException,
                                  ReadLockRequiredException,
                                  AccessDeniedException
Get a unique entity name with the given prefix and suffix in the directory. The entity name is unique in the directory (not only in the view) at the time of calling.

Parameters:
prefix - The prefix string to be used in generating the entity name. It must contain at least three characters.
suffix - The file name suffix, for instance .tmp.
Returns:
A unique entity name.
Throws:
IllegalArgumentException - If the prefix contains fewer than three characters.
IllegalStateException - If the view is disconnected.
ReadLockRequiredException - If the client does not have a read lock for the directory.
AccessDeniedException - If the client does not have read access to the directory.
Locks_required:
A read lock. (Use a write lock if an entity with the unique name should be created after calling this method to be certain that the name is still unique by the time that the entity is created.)
Permissions_required:
Read access