org.at4j.archive
Class AbstractArchiveEntry<T extends ArchiveEntry<T,U>,U extends ArchiveDirectoryEntry<T,U>>

java.lang.Object
  extended by org.at4j.archive.AbstractArchiveEntry<T,U>
Type Parameters:
T - The type of entries in this archive.
U - The type of directory entries in this archive.
All Implemented Interfaces:
ArchiveEntry<T,U>, Lockable, ReadLockable, Named
Direct Known Subclasses:
TarEntry, ZipEntry

public abstract class AbstractArchiveEntry<T extends ArchiveEntry<T,U>,U extends ArchiveDirectoryEntry<T,U>>
extends Object
implements ArchiveEntry<T,U>

Abstract base class for archive entry implementations.

Since:
1.0
Author:
Karl Gustafsson

Constructor Summary
protected AbstractArchiveEntry(AbsoluteLocation loc, ArchiveEntryCollaborator<T,U> collaborator)
          Create a new archive entry.
 
Method Summary
protected  ArchiveEntryCollaborator<T,U> getCollaborator()
           
 AbsoluteLocation getLocation()
          Get the location of the entry in the archive.
 String getName()
          Get the entry's file name.
 U getParent()
          Get the parent directory entry for this archive entry.
 EntityLock getReadLock()
          Since archive objects are read only, this method only returns a dummy lock.
 boolean isReadLockedByCurrentThread()
          This method always returns true.
 EntityLock lockForReading()
          Since archive objects are read only, this method only returns a dummy lock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractArchiveEntry

protected AbstractArchiveEntry(AbsoluteLocation loc,
                               ArchiveEntryCollaborator<T,U> collaborator)
Create a new archive entry.

Parameters:
loc - The entry's location in the archive.
collaborator - Collaborator object that gives access to the archive.
Method Detail

getLocation

public AbsoluteLocation getLocation()
Description copied from interface: ArchiveEntry
Get the location of the entry in the archive.

Specified by:
getLocation in interface ArchiveEntry<T extends ArchiveEntry<T,U>,U extends ArchiveDirectoryEntry<T,U>>
Returns:
The entry's location.

getCollaborator

protected ArchiveEntryCollaborator<T,U> getCollaborator()

getReadLock

public EntityLock getReadLock()
Since archive objects are read only, this method only returns a dummy lock.

Specified by:
getReadLock in interface ReadLockable
Returns:
A dummy lock.

isReadLockedByCurrentThread

public boolean isReadLockedByCurrentThread()
                                    throws IllegalStateException
This method always returns true.

Specified by:
isReadLockedByCurrentThread in interface ReadLockable
Returns:
true, always.
Throws:
IllegalStateException - If this is called on a disconnected entity view.

lockForReading

public EntityLock lockForReading()
                          throws LockTimeoutException
Since archive objects are read only, this method only returns a dummy lock.

Specified by:
lockForReading in interface ReadLockable
Returns:
A dummy lock.
Throws:
LockTimeoutException - If the lock acquiring timed out. (It is up to the LockAcquiringStrategy to decide if lock acquiring can time out.)

getName

public String getName()
Get the entry's file name.

Specified by:
getName in interface Named
Returns:
The entry's file name.

getParent

public U getParent()
Get the parent directory entry for this archive entry.

Specified by:
getParent in interface ArchiveEntry<T extends ArchiveEntry<T,U>,U extends ArchiveDirectoryEntry<T,U>>
Returns:
The entry's parent directory entry. If the entry is the root entry, this method returns null.