|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Entity
This is the interface for a FileSystem
entity, for instance an
EFile
or a Directory
.
Entities are true entities. A file entity is the representation of the file
itself, not just the file's location (like a java.io.File
object is).
For example, if the file f
is deleted or moved away and another file
f
is created in the same place, perhaps with the same contents, the
two files are not the same entities and will be represented by two different
EFile
instances. Each one of the files will also always(*) be represented by the same EFile
instance.
Compare this behavior with how java.io.File
works; java.io.File
will not care if there is a new file entity in the location it
references, and you can have any number of java.io.File
objects
referencing the same location.
Because entity objects are true entities, entity equality is the same as
identity. Hence entity equality can be checked with the ==
operator.
The location of an entity within the file system, and its location relative
to other entities are represented with EntityLocation
:s.
Some entity types, Directory
:s notably, support EntityView
:s.
An entity class extends its corresponding view class, if it has one. (
Directory
extends DirectoryView
, for instance.) Many EntityFS
methods work on the view classes rather than the entity classes.
If the FileSystem
is locking, many entity methods require that the
caller holds either the entity's read or write lock when calling them. Entity
implementations don't enforce any specific locking strategy (see discussion
in FileSystem
).
A lock that is not properly released can render the entity unusable. Locks
should be used in try
, finally
blocks:
EntityLock rl = myFile.lockForReading();
try
{
do stuff...
}
finally
{
rl.unlock()
}
Entity objects are designed to only have the bare minimum of methods to be
usable, and the methods are rather low-level. To every entity type there is
usually a corresponding utility object with a richer set of methods.
Entity
methods are complemented by those in
Entities
.
For an excellent discussion on entities versus value objects, see the book Domain Driven Design by Eric Evans.
* Actually an entity may be represented by more than one
entity object, but never simultaneously. Just like any Java object, an entity
object may be garbage collected if it is not referenced. Then a new entity
object will be created the next time that the entity is requested.
Entities
Method Summary | |
---|---|
boolean |
hasExecuteAccess()
Check if the caller has execute access to this entity. |
boolean |
hasReadAccess()
Check if the caller has read access to this entity. |
boolean |
hasWriteAccess()
Check if the caller has write access to this entity. |
Methods inherited from interface org.entityfs.EntityView |
---|
canRead, canWrite, copy, copy, copyAttributes, createLock, disconnect, getCapability, getFileSystem, getLastModified, getParent, getType, getViewed, getViewedEntity, isConnected, isRootDirectory, isValid, lock, rename, setLastModified, supportsCapability, touch |
Methods inherited from interface java.lang.Comparable |
---|
compareTo |
Methods inherited from interface org.entityfs.event.Observable |
---|
addObserver, countObservers, deleteObserver, deleteObservers |
Methods inherited from interface org.entityfs.Named |
---|
getName |
Methods inherited from interface org.entityfs.lock.ReadLockable |
---|
getReadLock, isReadLockedByCurrentThread, lockForReading |
Methods inherited from interface org.entityfs.Deletable |
---|
delete, isDeleted |
Methods inherited from interface org.entityfs.lock.WriteLockable |
---|
getWriteLock, isWriteLockedByCurrentThread, lockForWriting |
Method Detail |
---|
boolean hasReadAccess()
true
if the caller has read access, false
if not.AccessController
boolean hasWriteAccess()
true
if the caller has write access, false
if
not.AccessController
boolean hasExecuteAccess()
true
if the caller has execute access, false
if
not.AccessController
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |