org.entityfs.impl
Interface DirectoryDelegate

All Superinterfaces:
EntityDelegate
All Known Implementing Classes:
AbstractDirectoryDelegateProxy, AttributesEnablingDirectoryDelegateProxy, DirectoryDelegateImpl, SymbolicLinkEnablingDirectoryDelegateProxy

public interface DirectoryDelegate
extends EntityDelegate

This defines the delegate of a directory entity.

Since:
1.0
Author:
Karl Gustafsson
In_jar:
entityfs-core

Method Summary
 boolean containsEntity(String name)
           
 Set<EntityView> copyFromEntity(EntityImplementation ent, String targetName, boolean preserveAttrs, List<EntityAttributeSetter> asl, EntityLock[] setupLocks)
          Copy an entity to this directory.
 EntityDelegate createChildDelegate(FileSystemImplementation fs, EntityType et, String name, Object data, boolean createInBackend)
          Create a delegate for a child entity.
 EntityImplementation createEntity(FileSystemImplementation fs, String name, EntityDelegate ed)
          Create an entity object for the given delegate.
 void delete(Collection<String> childEntitiesToDelete)
          Delete the directory.
 String[] getEntityNames()
          Get a set with the names of all child entities.
 EntityType getEntityType(String name)
          Get the type of the child entity.
 
Methods inherited from interface org.entityfs.impl.EntityDelegate
canRead, canWrite, copy, copyAttributes, exists, getDelegateOfTypeOrNull, getEntityAdapter, getFileSystem, getLastModified, getName, getOwner, init, isReadOnly, rename, setLastModified, setOwner
 

Method Detail

getEntityType

EntityType getEntityType(String name)
Get the type of the child entity.

Parameters:
name - The name of the child entity.
Returns:
The type of the child entity, or null if no child entity with the supplied name exists.

containsEntity

boolean containsEntity(String name)

getEntityNames

String[] getEntityNames()
Get a set with the names of all child entities.

Returns:
An array with the names of all child entities. If the directory is empty, an empty array is returned.

createChildDelegate

EntityDelegate createChildDelegate(FileSystemImplementation fs,
                                   EntityType et,
                                   String name,
                                   Object data,
                                   boolean createInBackend)
Create a delegate for a child entity. This method is both called when creating a new child file or directory and when creating a delegate object for an existing file or directory (in a FSCPersistent file system).

Implementations of this method cannot assume that this delegate's owner is set since the method may be called before this delegate is fully initialized.

Parameters:
data - Data used for creating the delegate. If the created entity is a file and the data contains a FileDelegate, the contents of the supplied FileDelegate is moved to the new delegate. The caller must ensure that the supplied FileDelegate object is discarded.
createInBackend - Should the entity be created in the backend? If false, the backend representation (the File, for instance) must already exist.

createEntity

EntityImplementation createEntity(FileSystemImplementation fs,
                                  String name,
                                  EntityDelegate ed)
Create an entity object for the given delegate. This method is called by the parent directory entity after a delegate has been created for a new child entity.

Delegates for exotic new entity types can implement this to create entity objects of types that the directory implementation is not aware of. This method can also be used by delegates to initialize themselves if they need the entity object to do so.

This method is responsible for registering the new entity with its parent directory (through DirectoryImplementation.addChildEntity(String, EntityImplementation) ).

Parameters:
fs - The file system.
name - The name of the new entity.
ed - The new entity delegate.
Returns:
An entity for the delegate.

copyFromEntity

Set<EntityView> copyFromEntity(EntityImplementation ent,
                               String targetName,
                               boolean preserveAttrs,
                               List<EntityAttributeSetter> asl,
                               EntityLock[] setupLocks)
Copy an entity to this directory.

Parameters:
ent - The entity to copy.
targetName - The name of the entity to create.
preserveAttrs - Should entity attributes be copied to the target entity?
asl - A list of entity attribute setters that are run just after the target entity has been created and before the setup locks are released. The setters are run in the order that they are stored in the list. May be null. This may only be non-null when preserveAttrs is set to true.
setupLocks - Exception to the rule that the delegate should not bother with locking. This is here so that the delegate can release the lock needed for creating a new entity just after it has been created (but before data is copied to it). This method is responsible for unlocking this lock regardless of whether it is successful or fails.

delete

void delete(Collection<String> childEntitiesToDelete)
            throws DirectoryNotEmptyException,
                   FileSystemException
Delete the directory.

Since capabilities may add files to a directory that are not visible to the client, this method takes a collection of names of child files that should be deleted before the directory is deleted. If the directory would not be deleted after all named files had been deleted, nothing should be deleted.

Parameters:
childEntitiesToDelete - The names of child entities to delete before the directory is deleted. Capability delegates that use files in the directory add to this collection. If no names have been added yet, this argument may be null. Implementations have to check that. before calling their proxied delegate. (See comment above.)
Throws:
DirectoryNotEmptyException - If the directory would not be empty after all the child entities in childEntities had been deleted.
FileSystemException - If the entity cannot be deleted.