org.entityfs.cap.metadata.impl
Interface MetadataEnablingEntityDelegate

All Superinterfaces:
EntityDelegate

public interface MetadataEnablingEntityDelegate
extends EntityDelegate

This interface is implemented by metadata-enabling entity delegates. It is used by capabilities that implement the ECMetadata and ECNamedMetadata capabilities.

Metadata is stored in named "files" (the implementation is up to the implementing capability).

Implementations of this class do not have to verify that entities are properly locked. That is done by the capability objects.

This interface is the public API of metadata implementations for other capability implementations (entity delegates) that need metadata support. They can get an implementation of this interface by calling EntityDelegate.getDelegateOfTypeOrNull(Class) with the argument MetadataEnablingEntityDelegate.class. The delegates that use this interface must ensure that entities are locked according to the contract in ECMetadata or ECNamedMetadata before calling any of this interface's methods.

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

Method Summary
 FileDelegate createMetadataFile(String name)
          Create the entity's metadata file.
 void deleteMetadataFile(String name)
          Delete the metadata file with the supplied name.
 FileDelegate getMetadataFile(String name)
          Get a metadata file.
 Set<String> getMetadataFileNames()
          Get the names of all metadata files.
 Map<String,FileDelegate> getMetadataFiles()
          Return all the entity's metadata files, mapped under their names.
 boolean hasMetadataFile(String name)
          Check if the metadata file is created.
 
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

hasMetadataFile

boolean hasMetadataFile(String name)
Check if the metadata file is created.

The entity must be locked for reading when calling this method. It is up to the caller to verify that.

Parameters:
name - The name of the metadata file.
Returns:
true if the metadata file has been created.

createMetadataFile

FileDelegate createMetadataFile(String name)
                                throws EntityFoundException,
                                       ReadOnlyException
Create the entity's metadata file.

The entity must be locked for writing when calling this method. It is up to the caller to verify that.

Parameters:
name - The name of the metadata file.
Returns:
The new metadata file.
Throws:
EntityFoundException - If the metadata file already exists.
ReadOnlyException - If this is called on a read only file system.

getMetadataFile

FileDelegate getMetadataFile(String name)
Get a metadata file. It the file does not exist, null is returned.

The entity must be locked for reading when calling this method. It is up to the caller to verify that.

Parameters:
name - The name of the metadata file.
Returns:
The entity's metadata file, or null if it has not been created yet.

getMetadataFiles

Map<String,FileDelegate> getMetadataFiles()
Return all the entity's metadata files, mapped under their names.

Returns:
All the entity's metadata files. Maybe empty but never null.

deleteMetadataFile

void deleteMetadataFile(String name)
                        throws ReadOnlyException
Delete the metadata file with the supplied name. If no such metadata file exists, this method does nothing.

Parameters:
name - The name of the metadata file to delete.
Throws:
ReadOnlyException - If the file system is read only.

getMetadataFileNames

Set<String> getMetadataFileNames()
Get the names of all metadata files.

Returns:
The names of all the metadata files. If the entity does not have any metadata files, this method returns an empty set.