org.entityfs.impl.adapter
Interface DirectoryAdapter

All Superinterfaces:
EntityAdapter
All Known Subinterfaces:
ChildRegisteringDirectoryAdapter
All Known Implementing Classes:
RamDirectoryAdapter, ZipDirectoryAdapter

public interface DirectoryAdapter
extends EntityAdapter

This is an adapter for a directory in the backing file system.

A directory adapter may want to keep track of its child EntityAdapter:s if it does not have a way, or at least a reasonably performant way, of creating new adapter objects when they are requested. For instance, a File backed file system does not have to keep track of created entity adapters since it can easily create new adapters based on the File objects in a directory. The RAM file system, on the other hand, must keep track of its entity adapters since they contain the file data and must survive the garbage collection of their respective entity objects. Otherwise the RAM file system would forget data.

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

Method Summary
 void assertCanBeDeleted(Collection<String> childEntitiesToDelete)
          Check if the directory can be deleted provided that all the childEntitiesToDelete entities were deleted first.
 boolean containsEntity(String name)
          Check if the directory contains an entity with the given name (case sensitive or insensitive depending on the file system).
 void deleteChild(String name)
          Delete the named child.
 EntityType getChildEntityType(String name)
          Get the type of the child entity with the given name,
 String[] getEntityNames()
          Get an array with the names of all child entities.
 
Methods inherited from interface org.entityfs.impl.adapter.EntityAdapter
canRead, canWrite, create, delete, exists, getEntityType, getFileSystemAdapter, getLastModified, getName, getParent, init, rename, setLastModified
 

Method Detail

containsEntity

boolean containsEntity(String name)
Check if the directory contains an entity with the given name (case sensitive or insensitive depending on the file system).

Parameters:
name - The name of the entity.
Returns:
true if the directory contains the named entity, false otherwise.

getChildEntityType

EntityType getChildEntityType(String name)
Get the type of the child entity with the given name,

Parameters:
name - The name of the entity.
Returns:
The EntityType, or null if no such entity exists.

getEntityNames

String[] getEntityNames()
Get an array 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.

assertCanBeDeleted

void assertCanBeDeleted(Collection<String> childEntitiesToDelete)
                        throws DirectoryNotEmptyException,
                               FileSystemException
Check if the directory can be deleted provided that all the childEntitiesToDelete entities were deleted first. be empty.

Parameters:
childEntitiesToDelete - The names of child entities to delete before deleting the directory. This may be null.
Throws:
DirectoryNotEmptyException - If the directory is not empty after the named child entities have been deleted.
FileSystemException - If the entity cannot be deleted.

deleteChild

void deleteChild(String name)
                 throws DirectoryNotEmptyException,
                        FileSystemException
Delete the named child. The caller is responsible for making sure that no entity adapters representing the deleted children will be used in the future.

If the named child entity does not exist, this method exits silently.

Parameters:
name - The name of the child to delete.
Throws:
DirectoryNotEmptyException - If the child is a directory that is not empty.
FileSystemException - On other errors.