org.entityfs.impl
Class AbstractEntityDelegateProxy<T extends EntityDelegate,U extends EntityAdapter>

java.lang.Object
  extended by org.entityfs.support.lang.ObjectProxySupport<T>
      extended by org.entityfs.impl.AbstractEntityDelegateProxy<T,U>
All Implemented Interfaces:
EntityDelegate
Direct Known Subclasses:
AbstractDirectoryDelegateProxy, AbstractFileDelegateProxy, AbstractSymbolicLinkDelegateProxy

public abstract class AbstractEntityDelegateProxy<T extends EntityDelegate,U extends EntityAdapter>
extends ObjectProxySupport<T>
implements EntityDelegate

This is an abstract stub implementation of an entity delegate proxy that forwards all method calls to the proxied delegate. This can be used as a starting point for implementing custom delegate proxies.

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

Constructor Summary
protected AbstractEntityDelegateProxy(T proxied)
           
 
Method Summary
 boolean canRead()
          Check with the backend to see if this entity can be read.
 boolean canWrite()
          Check with the backend to see if this entity can be written to.
 Set<EntityView> copy(DirectoryImplementation targetDir, String targetName, boolean preserveAttrs, List<EntityAttributeSetter> asl, EntityLock[] setupLocks)
          Copy the entity.
 void copyAttributes(DirectoryImplementation targetParent, EntityImplementation target)
          This implementation does not copy any attributes.
 boolean exists()
          Does the entity really exist in the backend? This is used by some EntityValidityControlStrategy:s.
 EntityDelegate getDelegateOfTypeOrNull(Class<? extends EntityDelegate> c)
          Get an instance of a specific delegate type from the chain of delegates.
 EntityAdapter getEntityAdapter()
          Get the underlying EntityAdapter.
 FileSystemImplementation getFileSystem()
          Get the file system that owns this delegate's entity.
 long getLastModified()
          Get the last time that the entity was modified.
 String getName()
          Get the entity's name.
 EntityImplementation getOwner()
          Get the owner of this delegate.
 void init()
          If overriding this implementation, remember to call super.init()!
 boolean isReadOnly()
          Does the delegate or a delegate proxy make this entity read only?
 void rename(String oldName, DirectoryImplementation targetDir, String newName)
          Rename and/or move the entity.
 void setLastModified(long t)
          Set the time of last modification for the entity.
 void setOwner(EntityImplementation ent)
          This is set when the entity object is created.
 
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
 

Constructor Detail

AbstractEntityDelegateProxy

protected AbstractEntityDelegateProxy(T proxied)
Method Detail

init

public void init()
If overriding this implementation, remember to call super.init()!

Specified by:
init in interface EntityDelegate

getDelegateOfTypeOrNull

public EntityDelegate getDelegateOfTypeOrNull(Class<? extends EntityDelegate> c)
Description copied from interface: EntityDelegate
Get an instance of a specific delegate type from the chain of delegates.

Specified by:
getDelegateOfTypeOrNull in interface EntityDelegate
Parameters:
c - The delegate type.
Returns:
The delegate instance, or null if no such delegate can be found.

setOwner

public void setOwner(EntityImplementation ent)
Description copied from interface: EntityDelegate
This is set when the entity object is created.

Specified by:
setOwner in interface EntityDelegate
Parameters:
ent - The owning entity object.
See Also:
EntityDelegate.init()

getOwner

public EntityImplementation getOwner()
Description copied from interface: EntityDelegate
Get the owner of this delegate.

Specified by:
getOwner in interface EntityDelegate
Returns:
The delegate's owner.

getFileSystem

public FileSystemImplementation getFileSystem()
Description copied from interface: EntityDelegate
Get the file system that owns this delegate's entity.

Specified by:
getFileSystem in interface EntityDelegate
Returns:
The parent file system.

getEntityAdapter

public EntityAdapter getEntityAdapter()
Description copied from interface: EntityDelegate
Get the underlying EntityAdapter. This should only be called by delegate proxies that introduce entirely new entity types.

Specified by:
getEntityAdapter in interface EntityDelegate
Returns:
The adapter to the backend.

exists

public boolean exists()
Description copied from interface: EntityDelegate
Does the entity really exist in the backend? This is used by some EntityValidityControlStrategy:s.

Specified by:
exists in interface EntityDelegate
Returns:
true if the entity exists in the backend.

canRead

public boolean canRead()
Description copied from interface: EntityDelegate
Check with the backend to see if this entity can be read.

Specified by:
canRead in interface EntityDelegate
Returns:
true if the backend can be read.

canWrite

public boolean canWrite()
Description copied from interface: EntityDelegate
Check with the backend to see if this entity can be written to.

If EntityDelegate.isReadOnly() returns true, this method should always return false. (The opposite is not true, however.)

Specified by:
canWrite in interface EntityDelegate
Returns:
true if the backend can be written to.

isReadOnly

public boolean isReadOnly()
Description copied from interface: EntityDelegate
Does the delegate or a delegate proxy make this entity read only?

This method is invoked frequently and should execute fast. It is only invoked for read/write file systems.

Specified by:
isReadOnly in interface EntityDelegate
Returns:
true if the delegate has made the entity read only.

getLastModified

public long getLastModified()
Description copied from interface: EntityDelegate
Get the last time that the entity was modified.

Specified by:
getLastModified in interface EntityDelegate
Returns:
The last modification time.

setLastModified

public void setLastModified(long t)
Description copied from interface: EntityDelegate
Set the time of last modification for the entity.

Specified by:
setLastModified in interface EntityDelegate
Parameters:
t - A time stamp.

getName

public String getName()
Description copied from interface: EntityDelegate
Get the entity's name.

Specified by:
getName in interface EntityDelegate
Returns:
The entity's name.

rename

public void rename(String oldName,
                   DirectoryImplementation targetDir,
                   String newName)
Description copied from interface: EntityDelegate
Rename and/or move the entity.

Specified by:
rename in interface EntityDelegate
Parameters:
oldName - The old name,
targetDir - The new parent directory.
newName - The new name.

copy

public Set<EntityView> copy(DirectoryImplementation targetDir,
                            String targetName,
                            boolean preserveAttrs,
                            List<EntityAttributeSetter> asl,
                            EntityLock[] setupLocks)
Description copied from interface: EntityDelegate
Copy the entity. It is not verified that there does not already exist an entity at the target location.

Specified by:
copy in interface EntityDelegate
Parameters:
targetDir - The target directory of the new entity. This directory may be in another file system.
targetName - The name of the new entity.
preserveAttrs - Should entity attributes be copied to the target entity?
asl - A list of EntityAttributeSetter:s that are run just after the target entity has been created, before the setupLocks are released. This may be null. This may only be non-null if preserveAttrs is true.
setupLocks - Exception to the rule that the delegate should not bother with locking. This is here so that the delegate can release locks used to set up the target entity before data is copied to it. This method is responsible for unlocking this lock regardless of whether it is successful or fails.
Returns:
All new entities that were created. (This may be more than one if, for instance, copying a file from a metadata-enabled file system to a metadata-unaware file system.) It is safe to assume that the objects in the returned Set are real entities, not views.

copyAttributes

public void copyAttributes(DirectoryImplementation targetParent,
                           EntityImplementation target)
This implementation does not copy any attributes. Override to modify that behavior.

Specified by:
copyAttributes in interface EntityDelegate
Parameters:
targetParent - The parent directory of the target. This is null if target is a root directory of a file system. Otherwise it is locked for writing.
target - The target entity to copy attributes to. Locked for writing.