org.entityfs.impl
Class AbstractDirectoryDelegateProxy

java.lang.Object
  extended by org.entityfs.support.lang.ObjectProxySupport<T>
      extended by org.entityfs.impl.AbstractEntityDelegateProxy<DirectoryDelegate,DirectoryAdapter>
          extended by org.entityfs.impl.AbstractDirectoryDelegateProxy
All Implemented Interfaces:
DirectoryDelegate, EntityDelegate
Direct Known Subclasses:
AttributesEnablingDirectoryDelegateProxy, SymbolicLinkEnablingDirectoryDelegateProxy

public abstract class AbstractDirectoryDelegateProxy
extends AbstractEntityDelegateProxy<DirectoryDelegate,DirectoryAdapter>
implements DirectoryDelegate

This is an abstract stub implementation of a directory delegate proxy. It forwards all method calls to the proxied delegate. This can be used as a starting point for custom implementations.

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

Constructor Summary
protected AbstractDirectoryDelegateProxy(DirectoryDelegate proxied)
           
 
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.
 EntityImplementation createEntity(FileSystemImplementation fs, String name, EntityDelegate ed)
          Create an entity object for the given delegate.
 void delete(Collection<String> c)
          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 class org.entityfs.impl.AbstractEntityDelegateProxy
canRead, canWrite, copy, copyAttributes, exists, getDelegateOfTypeOrNull, getEntityAdapter, getFileSystem, getLastModified, getName, getOwner, init, isReadOnly, rename, setLastModified, setOwner
 
Methods inherited from class org.entityfs.support.lang.ObjectProxySupport
equals, getProxied, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.entityfs.impl.DirectoryDelegate
createChildDelegate
 
Methods inherited from interface org.entityfs.impl.EntityDelegate
canRead, canWrite, copy, copyAttributes, exists, getDelegateOfTypeOrNull, getEntityAdapter, getFileSystem, getLastModified, getName, getOwner, init, isReadOnly, rename, setLastModified, setOwner
 

Constructor Detail

AbstractDirectoryDelegateProxy

protected AbstractDirectoryDelegateProxy(DirectoryDelegate proxied)
Method Detail

getEntityType

public EntityType getEntityType(String name)
Description copied from interface: DirectoryDelegate
Get the type of the child entity.

Specified by:
getEntityType in interface DirectoryDelegate
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

public boolean containsEntity(String name)
Specified by:
containsEntity in interface DirectoryDelegate

getEntityNames

public String[] getEntityNames()
Description copied from interface: DirectoryDelegate
Get a set with the names of all child entities.

Specified by:
getEntityNames in interface DirectoryDelegate
Returns:
An array with the names of all child entities. If the directory is empty, an empty array is returned.

createEntity

public EntityImplementation createEntity(FileSystemImplementation fs,
                                         String name,
                                         EntityDelegate ed)
Description copied from interface: DirectoryDelegate
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) ).

Specified by:
createEntity in interface DirectoryDelegate
Parameters:
fs - The file system.
name - The name of the new entity.
ed - The new entity delegate.
Returns:
An entity for the delegate.

copyFromEntity

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

Specified by:
copyFromEntity in interface DirectoryDelegate
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

public void delete(Collection<String> c)
            throws FileSystemException
Description copied from interface: DirectoryDelegate
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.

Specified by:
delete in interface DirectoryDelegate
Parameters:
c - 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.