|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.entityfs.util.Entities
public final class Entities
Entities
contains static methods for working with Entity
:s
and EntityView
:s.
The Files
and Directories
utility classes contains utility
methods that complement the methods in this class.
The methods in this class will use the locking strategy for utility classes
described in EntityLock
.
Entity
,
EntityView
,
Files
,
Directories
Method Summary | ||
---|---|---|
static boolean |
canRead(EntityView ev)
Can the application read from the supplied entity, given the right access rights and locks? |
|
static boolean |
canWrite(EntityView ev)
Can the application write to the supplied entity, given the right access rights and locks? |
|
static Collection<EntityView> |
copy(Collection<? extends EntityView> c,
EntityAcceptingEntityView<?> targetDir)
Copy a collection of entities to a target directory. |
|
static Collection<EntityView> |
copy(Collection<? extends EntityView> c,
EntityAcceptingEntityView<?> targetE,
EntityCopySpecification spec)
Copy a collection of entities to a target directory. |
|
static Collection<? extends EntityView> |
copy(EntityView ent,
EntityAcceptingEntityView<?> targetDir)
Copies the contents of the entity to a new entity in the target directory. |
|
static Collection<? extends EntityView> |
copy(EntityView ent,
EntityAcceptingEntityView<?> targetDir,
boolean preserveAttr)
Copies the contents of the entity to a new entity in the target directory. |
|
static Collection<? extends EntityView> |
copy(EntityView ent,
EntityAcceptingEntityView<?> targetDir,
EntityCopySpecification spec)
Copies the contents of the entity to an entity in the target directory. |
|
static Collection<? extends EntityView> |
copy(EntityView ent,
EntityAcceptingEntityView<?> targetDir,
String newName)
Copies the contents of the entity to an entity with another name in the target directory. |
|
static Collection<? extends EntityView> |
copy(EntityView ent,
EntityAcceptingEntityView<?> targetDir,
String newName,
boolean preserveAttr)
Copies the contents of the entity to an entity with another name in the target directory. |
|
static Collection<? extends EntityView> |
copy(EntityView ent,
EntityLocation<? extends EntityLocation<?>> el)
Copies the contents of the entity to a new entity in a directory. |
|
static void |
copyAttributes(EntityView e1,
EntityView e2)
Copy attributes from e1 to e2 . |
|
static EFile |
copyFileContents(NamedReadableFile f,
EntityAcceptingEntityView<?> targetE)
Copy the contents of the NamedReadableFile to a new file with the
same name in the supplied EntityAcceptingEntityView (commonly a
Directory ). |
|
static EFile |
copyFileContents(ReadableFile f,
EntityAcceptingEntityView<?> targetE,
String targetName)
Copy the contents of the ReadableFile to a new file in the
supplied EntityAcceptingEntityView (commonly a Directory
). |
|
static void |
delete(EntityView ent)
Delete the entity. |
|
static void |
deleteEntity(EntityView ent)
This methods does the same as the delete(EntityView) . |
|
static void |
deleteRecursively(EntityView ent)
Delete an entity recursively. |
|
static void |
deleteRecursively(EntityView ent,
boolean deleteRoot)
Delete an entity recursively. |
|
static AbsoluteLocation |
getAbsoluteLocation(EntityView ev)
Get the absolute location of an entity. |
|
static AbsoluteLocation |
getCanonicalLocation(EntityView ent)
Return the canonical location for the entity. |
|
static long |
getLastModified(EntityView ev)
Get the last modification time of an entity. |
|
static String |
getName(Named n)
Get the entity's name. |
|
static Directory |
getParent(Entity ent)
Get the entity's parent directory. |
|
static DirectoryView |
getParent(EntityView ev)
Get the entity's parent directory. |
|
static RelativeLocation |
getRelativeLocation(EntityView e1,
EntityView e2)
Get the location of e1 , relative to e2 . |
|
static Pair<List<EntityView>> |
getSmallestDifferentHierarchies(Entity e1,
Entity e2)
Get the smallest possible entity hierarchy with a common root entity for the two entities. |
|
static
|
getValidEntity(T ent)
Get a valid entity object for the same absolute location in the file system as the supplied entity. |
|
static EntityView |
getValidEntityOrNull(EntityView ev,
boolean mustBeOfSameType)
Get a valid entity object for the same absolute location in the file system as the supplied entity. |
|
static boolean |
isDeleted(EntityView ev)
Is the entity deleted? |
|
static boolean |
isValid(EntityView ev)
Is the entity valid? Deleting an entity invalidates the entity object. |
|
static List<EntityLock> |
lockHierarchies(Pair<? extends List<? extends EntityView>> h,
Collection<? extends EntityView> entitiesToWriteLock)
Lock the two hierarchies sharing a root element top-down. |
|
static
|
move(T ent,
EntityAcceptingEntityView<?> target)
Move the entity to a new directory in the same file system. |
|
static
|
move(T ent,
EntityLocation<?> to)
Move the entity to the directory referenced by the entity location in the same file system. |
|
static
|
rename(T ent,
EntityAcceptingEntityView<?> target,
EntityRenameSpecification spec)
Move and/or rename the entity using the supplied settings. |
|
static
|
rename(T ent,
EntityAcceptingEntityView<?> target,
String newName)
Rename the entity and move it to a new directory in the same file system. |
|
static
|
rename(T ent,
EntityLocation<?> to)
Rename and/or move the entity to the target location. |
|
static
|
rename(T ent,
String newName)
Rename the entity. |
|
static
|
replace(EntityView e1,
T e2)
Replace the entity e1 with the entity e2 . |
|
static
|
setLastModified(T ev,
long t)
Set the last modification time of an entity. |
|
static
|
touch(T ev)
Touch the entity. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean isValid(EntityView ev)
ev
- The entity to check.
true
if the entity is valid, false
if it is
invalid.EntityView.isValid()
,
isDeleted(EntityView)
public static boolean isDeleted(EntityView ev)
ev
- The entity to check.
true
if the entity is deletedDeletable.isDeleted()
,
isValid(EntityView)
public static boolean canRead(EntityView ev)
ev
- The entity to investigate. The entity is temporarily locked for
reading by the method.
true
if the application can read from the entitypublic static boolean canWrite(EntityView ev)
ev
- The entity to investigate. The entity is temporarily locked for
reading by the method.
true
if the application can write to the entitypublic static Pair<List<EntityView>> getSmallestDifferentHierarchies(Entity e1, Entity e2)
The returned hierarchies may not be valid by the time this method returns since no entities are locked; another thread might have moved entities around. The client has to verify that the hierarchies are still valid before using them.
e1
- An entity.e2
- Another entity.
e1
and
the last entity in the second list is e2
. The other entities in
the lists are parent entities of e1
and e2
, respectively.lockHierarchies(Pair, Collection)
public static List<EntityLock> lockHierarchies(Pair<? extends List<? extends EntityView>> h, Collection<? extends EntityView> entitiesToWriteLock)
h
- A Pair
of entity hierarchies sharing the same root
entity. (The first entity returned from each collection.)entitiesToWriteLock
- A collection of entities that should be locked
for writing. All other entities are locked for reading. The collection
can be null
if all entities should be locked for reading.
null
any of the hierarchies are
invalid.getSmallestDifferentHierarchies(Entity, Entity)
public static <T extends EntityView> T move(T ent, EntityAcceptingEntityView<?> target) throws EntityFoundException, EntityNotFoundException, NotADirectoryException, AccessDeniedException, ReadOnlyException
If the entity supports some
ECEntityAttributes
capability, the
entities attributes are also moved.
ent
- The entity to move.target
- A directory or an entity that can be dereferenced to a
directory.
ent
EntityFoundException
- If an entity with the same name already
exists in the target directory.
NotADirectoryException
- If the target entity is not a directory
and references an entity that is not a directory.
EntityNotFoundException
- If the target entity is not a directory
and does not reference an entity at all.
AccessDeniedException
- If the caller does not have sufficient
access rights.
ReadOnlyException
- If the target directory is read only.EntityView.rename(DirectoryView, String)
,
move(EntityView, EntityLocation)
,
rename(EntityView, EntityAcceptingEntityView, String)
,
rename(EntityView, EntityAcceptingEntityView,
EntityRenameSpecification)
public static <T extends EntityView> T move(T ent, EntityLocation<?> to) throws EntityFoundException, EntityNotFoundException, NotADirectoryException, AccessDeniedException, ReadOnlyException
If the entity supports some
ECEntityAttributes
capability, the
entities attributes are also moved.
ent
- The entity to move.to
- The target location.
ent
EntityFoundException
- If an entity with the same name already
exists at the target location.
NotADirectoryException
- If the target entity is not a directory
and does not reference an entity that is a directory.
EntityNotFoundException
- If the target directory does not exist.
AccessDeniedException
- If the caller does not have sufficient
access rights.
ReadOnlyException
- If the target directory is read only.move(EntityView, EntityAcceptingEntityView)
,
rename(EntityView, EntityLocation)
,
rename(EntityView, EntityAcceptingEntityView,
EntityRenameSpecification)
public static <T extends EntityView> T rename(T ent, EntityLocation<?> to) throws EntityFoundException, EntityNotFoundException, NotADirectoryException, AccessDeniedException, ReadOnlyException
If the entity supports some
ECEntityAttributes
capability, the
entities attributes are also moved.
ent
- The entity to rename.to
- The new location. If the location is a RelativeLocation
, it is taken to be relative to the entity's current parent directory.
ent
EntityFoundException
- If an entity with the same name already
exists at the target location.
NotADirectoryException
- If the target entity is not a directory
and does not reference an entity that is a directory.
EntityNotFoundException
- If the target directory does not exist.
AccessDeniedException
- If the caller does not have sufficient
access rights.
ReadOnlyException
- If the target directory is read only.move(EntityView, EntityLocation)
,
rename(EntityView, String)
,
rename(EntityView, EntityAcceptingEntityView, String)
,
rename(EntityView, EntityAcceptingEntityView,
EntityRenameSpecification)
public static <T extends EntityView> T rename(T ent, String newName) throws AccessDeniedException, ReadOnlyException
If the entity supports some
ECEntityAttributes
capability, the
entities attributes are also moved.
ent
- The entity to rename.newName
- The new name.
ent
AccessDeniedException
- If the caller does not have sufficient
access rights.
ReadOnlyException
- If the entity is read only.rename(EntityView, EntityLocation)
,
rename(EntityView, EntityAcceptingEntityView,
EntityRenameSpecification)
public static <T extends EntityView> T rename(T ent, EntityAcceptingEntityView<?> target, String newName) throws EntityFoundException, NotADirectoryException, EntityNotFoundException, AccessDeniedException, ReadOnlyException
If the entity supports some
ECEntityAttributes
capability, the
entities attributes are also moved.
ent
- The entity to move and rename.target
- A directory or an entity that can be dereferenced to a
directory.newName
- The new name.
ent
EntityFoundException
- If an entity with the new name already
exists in the target directory.
NotADirectoryException
- If the target entity is not a directory
and references an entity that is not a directory.
EntityNotFoundException
- If the target entity is not a directory
and does not reference an entity at all.
AccessDeniedException
- If the caller does not have sufficient
access rights.
ReadOnlyException
- If the target directory is read only.move(EntityView, EntityAcceptingEntityView)
,
rename(EntityView, EntityLocation)
,
rename(EntityView, String)
,
rename(EntityView, EntityAcceptingEntityView,
EntityRenameSpecification)
public static <T extends EntityView> T rename(T ent, EntityAcceptingEntityView<?> target, EntityRenameSpecification spec) throws EntityFoundException, NotADirectoryException, EntityNotFoundException, AccessDeniedException, ReadOnlyException
If the entity supports some
ECEntityAttributes
capability, the
entities attributes are also moved.
ent
- The entity to move and/or rename.target
- A directory or an entity that can be dereferenced to a
directory.spec
- Settings for the move and/or rename operation.
ent
EntityFoundException
- If an entity with the new name already
exists in the target directory.
NotADirectoryException
- If the target entity is not a directory
and references an entity that is not a directory.
EntityNotFoundException
- If the target entity is not a directory
and does not reference an entity at all.
AccessDeniedException
- If the caller does not have sufficient
access rights.
ReadOnlyException
- If the target directory is read only.move(EntityView, EntityAcceptingEntityView)
,
rename(EntityView, EntityLocation)
,
rename(EntityView, String)
,
rename(EntityView, EntityAcceptingEntityView, String)
public static Collection<? extends EntityView> copy(EntityView ent, EntityLocation<? extends EntityLocation<?>> el) throws EntityNotFoundException, EntityFoundException, ReadOnlyException, AccessDeniedException, UncheckedInterruptedException
If the entity supports some
ECEntityAttributes
capability, those
attributes are not copied.
el
- The location of the target directory. If the target is a
RelativeLocation
, it is taken to be relative to the source
entity's parent directory, unless the source entity is the root
directory.
EntityView.copy(DirectoryView, String, EntityLock[])
.
EntityNotFoundException
- If a directory or an entity that might
reference a directory cannot be found at the target location.
EntityFoundException
- If there already is an entity with the same
name as the entity to copy in the target directory.
ReadOnlyException
- If the target directory is read only.
AccessDeniedException
- If the calling thread has insufficient
access rights.
UncheckedInterruptionException
- May be thrown if the copy
operation is interrupted. (It is up to the file system implementation to
honor this.)
UncheckedInterruptedException
copy(EntityView, EntityAcceptingEntityView)
,
copy(EntityView, EntityAcceptingEntityView, String)
,
copy(EntityView, EntityAcceptingEntityView,
EntityCopySpecification)
,
copyFileContents(ReadableFile, EntityAcceptingEntityView, String)
public static Collection<? extends EntityView> copy(EntityView ent, EntityAcceptingEntityView<?> targetDir) throws EntityFoundException, EntityNotFoundException, NotADirectoryException, ReadOnlyException, AccessDeniedException, UncheckedInterruptedException
If the entity supports some
ECEntityAttributes
capability, those
attributes are not copied.
ent
- The entity to copy.targetDir
- The target directory or an entity that can be
dereferenced to a target directory. May be in another file system.
EntityView.copy(DirectoryView, String, EntityLock[])
.
EntityFoundException
- If there already is an entity with the same
name in the target directory.
NotADirectoryException
- If the target entity is not a directory
and does not reference an entity that is a directory.
EntityNotFoundException
- If the target entity is not a directory
and does not reference an entity at all.
UncheckedInterruptionException
- May be thrown if the copy
operation is interrupted. (It is up to the file system implementation to
honor this.)
AccessDeniedException
- If the calling thread has insufficient
access rights.
ReadOnlyException
- If the target directory is read only.
UncheckedInterruptedException
copy(EntityView, EntityLocation)
,
copy(EntityView, EntityAcceptingEntityView, String)
,
copy(EntityView, EntityAcceptingEntityView,
EntityCopySpecification)
,
copyFileContents(ReadableFile, EntityAcceptingEntityView, String)
public static Collection<? extends EntityView> copy(EntityView ent, EntityAcceptingEntityView<?> targetDir, boolean preserveAttr) throws EntityFoundException, EntityNotFoundException, NotADirectoryException, ReadOnlyException, AccessDeniedException, UncheckedInterruptedException
If the entity supports some
ECEntityAttributes
capability, those
attributes are copied if preserveAttr
is set to true
.
ent
- The entity to copy.targetDir
- The target directory or an entity that can be
dereferenced to a target directory. May be in another file system.preserveAttr
- Should entity attributes such as the last
modification time be copied to the target entity?
EntityView.copy(DirectoryView, String, EntityLock[])
.
EntityFoundException
- If there already is an entity with the same
name in the target directory.
NotADirectoryException
- If the target entity is not a directory
and does not reference an entity that is a directory.
EntityNotFoundException
- If the target entity is not a directory
and does not reference an entity at all.
UncheckedInterruptionException
- May be thrown if the copy
operation is interrupted. (It is up to the file system implementation to
honor this.)
AccessDeniedException
- If the calling thread has insufficient
access rights.
ReadOnlyException
- If the target directory is read only.
UncheckedInterruptedException
copy(EntityView, EntityLocation)
,
copy(EntityView, EntityAcceptingEntityView, String)
,
copy(EntityView, EntityAcceptingEntityView,
EntityCopySpecification)
,
copyFileContents(ReadableFile, EntityAcceptingEntityView, String)
public static Collection<? extends EntityView> copy(EntityView ent, EntityAcceptingEntityView<?> targetDir, String newName) throws EntityFoundException, EntityNotFoundException, NotADirectoryException, ReadOnlyException, AccessDeniedException, UncheckedInterruptedException
If the entity supports some
ECEntityAttributes
capability, those
attributes are not copied.
ent
- The entity to copy.targetDir
- The target directory or an entity that can be
dereferenced to a target directory. May be in another file system.newName
- The name of the target entity.
EntityView.copy(DirectoryView, String, EntityLock[])
.
EntityFoundException
- If there already is an entity with the same
name as the target.
NotADirectoryException
- If the target entity is not a directory
and does not reference an entity that is a directory.
EntityNotFoundException
- If the target entity is not a directory
and does not reference an entity at all.
UncheckedInterruptionException
- May be thrown if the copy
operation is interrupted. (It is up to the file system implementation to
honor this.)
AccessDeniedException
- If the calling thread has insufficient
access rights.
ReadOnlyException
- If the target directory is read only.
UncheckedInterruptedException
copy(EntityView, EntityLocation)
,
copy(EntityView, EntityAcceptingEntityView, String)
,
copy(EntityView, EntityAcceptingEntityView,
EntityCopySpecification)
,
copyFileContents(ReadableFile, EntityAcceptingEntityView, String)
public static Collection<? extends EntityView> copy(EntityView ent, EntityAcceptingEntityView<?> targetDir, String newName, boolean preserveAttr) throws EntityFoundException, EntityNotFoundException, NotADirectoryException, ReadOnlyException, AccessDeniedException, UncheckedInterruptedException
If the entity supports some
ECEntityAttributes
capability, those
attributes are copied if preserveAttr
is set to true
.
ent
- The entity to copy.targetDir
- The target directory or an entity that can be
dereferenced to a target directory. May be in another file system.newName
- The name of the target entity.preserveAttr
- Should entity attributes such as the last
modification time be copied to the target?
EntityView.copy(DirectoryView, String, EntityLock[])
.
EntityFoundException
- If there already is an entity with the same
name as the target.
NotADirectoryException
- If the target entity is not a directory
and does not reference an entity that is a directory.
EntityNotFoundException
- If the target entity is not a directory
and does not reference an entity at all.
UncheckedInterruptionException
- May be thrown if the copy
operation is interrupted. (It is up to the file system implementation to
honor this.)
AccessDeniedException
- If the calling thread has insufficient
access rights.
ReadOnlyException
- If the target directory is read only.
UncheckedInterruptedException
copy(EntityView, EntityLocation)
,
copy(EntityView, EntityAcceptingEntityView, String)
,
copy(EntityView, EntityAcceptingEntityView,
EntityCopySpecification)
,
copyFileContents(ReadableFile, EntityAcceptingEntityView, String)
public static Collection<? extends EntityView> copy(EntityView ent, EntityAcceptingEntityView<?> targetDir, EntityCopySpecification spec) throws EntityFoundException, EntityNotFoundException, NotADirectoryException, ReadOnlyException, AccessDeniedException, UncheckedInterruptedException
EntityCopySpecification
object determines the
settings for the copy operation.
The target directory may be in another file system.
ent
- The entity to copy.targetDir
- The target directory or an entity that can be
dereferenced to a target directory. May be in another file system.spec
- Settings for the copy operation.
EntityView.copy(DirectoryView, String, EntityLock[])
. If an
overwrite strategy that doesn't overwrite existing entities and doesn't
throw an exception is used, and there is already an entity on the target
location, the returned collection contains that entity as its single
element.
EntityFoundException
- If there already is an entity with the same
name as the target and that entity cannot be overwritten.
NotADirectoryException
- If the target entity is not a directory
and does not reference an entity that is a directory.
EntityNotFoundException
- If the target entity is not a directory
and does not reference an entity at all.
UncheckedInterruptionException
- May be thrown if the copy
operation is interrupted. (It is up to the file system implementation to
honor this.)
AccessDeniedException
- If the calling thread has insufficient
access rights.
ReadOnlyException
- If the target directory is read only.
UncheckedInterruptedException
public static Collection<EntityView> copy(Collection<? extends EntityView> c, EntityAcceptingEntityView<?> targetE, EntityCopySpecification spec) throws EntityFoundException, EntityNotFoundException, NotADirectoryException, ReadOnlyException, AccessDeniedException, UncheckedInterruptedException
EntityCopySpecification
object determines the settings for the
copy operation. The name property of the specification object is ignored;
the names of the copied entities are preserved in the new target
directory.
The target directory may be in another file system.
c
- The collection of entities to copy.targetE
- The target directory or an entity that can be dereferenced
to a target directory.spec
- Settings for the copy operation. The name property of the
settings is ignored; names are preserved in the target directory.
EntityFoundException
- If there already is an entity with the same
name as a copied entity at the target and that entity cannot be
overwritten.
NotADirectoryException
- If the target entity is not a directory
and does not reference an entity that is a directory.
EntityNotFoundException
- If the target entity is not a directory
and does not reference an entity at all.
UncheckedInterruptionException
- May be thrown if the copy
operation is interrupted. (It is up to the file system implementation to
honor this.)
AccessDeniedException
- If the calling thread has insufficient
access rights.
ReadOnlyException
- If the target directory is read only.
UncheckedInterruptedException
public static Collection<EntityView> copy(Collection<? extends EntityView> c, EntityAcceptingEntityView<?> targetDir) throws EntityFoundException, EntityNotFoundException, NotADirectoryException, ReadOnlyException, AccessDeniedException, UncheckedInterruptedException
EntityCopySpecification
settings are used.
The target directory may be in another file system.
c
- The collection of entities to copy.targetDir
- The target directory or an entity that can be
dereferenced to a target directory.
EntityFoundException
- If there already is an entity with the same
name as a copied entity at the target and that entity cannot be
overwritten.
NotADirectoryException
- If the target entity is not a directory
and does not reference an entity that is a directory.
EntityNotFoundException
- If the target entity is not a directory
and does not reference an entity at all.
UncheckedInterruptionException
- May be thrown if the copy
operation is interrupted. (It is up to the file system implementation to
honor this.)
AccessDeniedException
- If the calling thread has insufficient
access rights.
ReadOnlyException
- If the target directory is read only.
UncheckedInterruptedException
public static EFile copyFileContents(ReadableFile f, EntityAcceptingEntityView<?> targetE, String targetName) throws EntityFoundException, EntityNotFoundException, NotADirectoryException, ReadOnlyException, AccessDeniedException, UncheckedInterruptedException, WrappedIOException
ReadableFile
to a new file in the
supplied EntityAcceptingEntityView
(commonly a Directory
).
The difference between this method and the
copy(EntityView, EntityAcceptingEntityView)
methods is that this
method only copies the file contents; it does not try to copy metadata
and other extra information that may be associated with the source file.
If the entity supports some
ECEntityAttributes
capability, those
attributes are not copied.
f
- The file to copy.targetE
- The target directory or an entity that can be dereferenced
to a target directory. May be in another file system.targetName
- The name of the file to create.
EntityFoundException
- If there already is an entity with the same
name as the target.
NotADirectoryException
- If the target entity is not a directory
and references an entity that is not a directory.
EntityNotFoundException
- If the target entity is not a directory
and does not reference an entity at all.
UncheckedInterruptionException
- May be thrown if the copy
operation is interrupted. (It is up to the file system implementation to
honor this.)
AccessDeniedException
- If the calling thread has insufficient
access rights.
ReadOnlyException
- If the target directory is read only.
WrappedIOException
- On I/O errors when copying the file.
UncheckedInterruptedException
copyFileContents(NamedReadableFile, EntityAcceptingEntityView)
,
copy(EntityView, EntityAcceptingEntityView)
public static EFile copyFileContents(NamedReadableFile f, EntityAcceptingEntityView<?> targetE) throws EntityFoundException, NotADirectoryException, ReadOnlyException, AccessDeniedException, UncheckedInterruptedException, WrappedIOException
NamedReadableFile
to a new file with the
same name in the supplied EntityAcceptingEntityView
(commonly a
Directory
).
The difference between this method and the
copy(EntityView, EntityAcceptingEntityView)
methods is that this
method only copies the file contents; it does not try to copy metadata
and other extra information that may be associated with the source file.
If the entity supports some
ECEntityAttributes
capability, those
attributes are not copied.
f
- The file to copy.targetE
- The target directory or an entity that can be dereferenced
to a target directory. May be in another file system.
EntityFoundException
- If there already is an entity with the same
name as the target.
NotADirectoryException
- If the target entity is not a directory
and references an entity that is not a directory.
EntityNotFoundException
- If the target entity is not a directory
and does not reference an entity at all.
UncheckedInterruptionException
- May be thrown if the copy
operation is interrupted. (It is up to the file system implementation to
honor this.)
AccessDeniedException
- If the calling thread has insufficient
access rights.
ReadOnlyException
- If the target directory is read only.
WrappedIOException
- On I/O errors when copying the file.
UncheckedInterruptedException
copyFileContents(ReadableFile, EntityAcceptingEntityView, String)
,
copy(EntityView, EntityAcceptingEntityView)
public static void copyAttributes(EntityView e1, EntityView e2) throws ReadOnlyException, AccessDeniedException, WrappedIOException
e1
to e2
.
For ordinary file systems, the attributes only consist of the entity's latest modification time. Capabilities may add more attributes.
e1
- The entity to copy attributes frome2
- The entity to copy attributes to
AccessDeniedException
- If the calling thread has insufficient
access rights.
ReadOnlyException
- If the target directory is read only.
WrappedIOException
- On I/O errors when copying the attributes.EntityView.copyAttributes(EntityView)
public static void deleteEntity(EntityView ent) throws ReadOnlyException, AccessDeniedException
delete(EntityView)
. When using
EntityFS from JavaScript (from a Schmant script, for instance), the
method name delete
is reserved for JavaScript. Use this method
instead.
ent
- The entity to delete.
AccessDeniedException
- If the calling thread has insufficient
access rights.
ReadOnlyException
- If the target entity is read only.delete(EntityView)
public static void delete(EntityView ent) throws ReadOnlyException, AccessDeniedException
ent
- The entity to delete.
AccessDeniedException
- If the calling thread has insufficient
access rights.
ReadOnlyException
- If the target entity is read only.Deletable.delete()
,
deleteEntity(EntityView)
public static <T extends EntityView> T replace(EntityView e1, T e2) throws ReadOnlyException, AccessDeniedException, DirectoryNotEmptyException
e1
with the entity e2
. e1
is
deleted and e2
is moved to e1
's previous location. The
entities must be in the same file system.
e1
- The entity to replace.e2
- The entity to replace it with.
e2
AccessDeniedException
- If the calling thread has insufficient
access rights.
ReadOnlyException
- If the target entity is read only.
DirectoryNotEmptyException
- If the target is a non-empty directorypublic static AbsoluteLocation getAbsoluteLocation(EntityView ev) throws AccessDeniedException
Try to avoid working with absolute locations as much as possible, as constructing an absolute location will require read locking the entity's entire parent hierarchy up to the root directory.
AccessDeniedException
- If the calling thread has insufficient
access rights.public static AbsoluteLocation getCanonicalLocation(EntityView ent) throws CircularReferenceException, AccessDeniedException
ent
- The entity.
CircularReferenceException
- If there is a circular reference in a
chain of entity-accepting entities that have to be dereferenced in order
to find the entity.
AccessDeniedException
- If the calling thread does not have execute
access to the entities necessary for creating the canonical location.FileSystems.getCanonicalLocation(org.entityfs.FileSystem,
AbsoluteLocation)
,
File.getCanonicalFile()
public static RelativeLocation getRelativeLocation(EntityView e1, EntityView e2) throws AccessDeniedException, FileSystemException
e1
, relative to e2
. Both entities
must be in the same file system.
e1
- The first entity.e2
- The second entity.
e1
relative to e2
.
AccessDeniedException
- If the calling thread has insufficient
access rights.
FileSystemException
- If the entities are not in the same file
system. (And on other errors.)Directories.getChildRelativeLocation(DirectoryView, EntityView)
public static long getLastModified(EntityView ev) throws AccessDeniedException
ev
- The entity.
AccessDeniedException
- If the calling thread does not have read
access to the entity.EntityView.getLastModified()
,
setLastModified(EntityView, long)
public static <T extends EntityView> T setLastModified(T ev, long t) throws AccessDeniedException, ReadOnlyException
ev
- The entity.t
- The new last modification time for the entity.
ev
AccessDeniedException
- If the calling thread does not have write
access to the entity.
ReadOnlyException
- If the file system is read only.EntityView.setLastModified(long)
,
getLastModified(EntityView)
public static <T extends EntityView> T touch(T ev) throws ReadOnlyException, AccessDeniedException
ev
- The entity.
ev
AccessDeniedException
- If the calling thread does not have write
access to the entity.
ReadOnlyException
- If the entity is read only.EntityView.touch()
public static DirectoryView getParent(EntityView ev) throws AccessDeniedException
ev
- The entity.
null
if the entity is
the root directory.
AccessDeniedException
- If the calling thread does not have read
access to the entity.EntityView.getParent()
,
getParent(Entity)
public static Directory getParent(Entity ent) throws AccessDeniedException
Since the entity supplied to this method is not a view, the method can
convert the result to a Directory
.
ent
- The entity.
null
if the entity is
the root directory.
AccessDeniedException
- If the calling thread does not have read
access to the entity.EntityView.getParent()
,
getParent(EntityView)
public static String getName(Named n) throws AccessDeniedException
n
- The entity
AccessDeniedException
- If the calling thread does not have read
access to the entity.Named.getName()
public static EntityView getValidEntityOrNull(EntityView ev, boolean mustBeOfSameType) throws WrongEntityTypeException, AccessDeniedException
ev
- The entity.mustBeOfSameType
- Require that the valid entity is of the same
entity type as ev
. If this is set and this method finds a valid
entity of another type (file vs. directory, for instance), this method
will throw a WrongEntityTypeException
.
ev
is still valid, it is returned. Otherwise this
method returns the valid entity that occupies the same absolute location
in the file system, if there is one. If no such entity can be found,
null
is returned.
WrongEntityTypeException
- If it is required that the found entity
should be of the same type as ev
, and a valid entity is found
that is not, this exception is thrown.
AccessDeniedException
getValidEntity(EntityView)
public static <T extends EntityView> T getValidEntity(T ent) throws EntityNotFoundException, WrongEntityTypeException, AccessDeniedException
T
- The type of the entity.ent
- The entity.
ent
. If ent
still is valid, it is
returned.
EntityNotFoundException
- If no valid entity occupies the same
absolute location in the file system as ent
did.
WrongEntityTypeException
- If the valid entity with the same
absolute location in the file system as ent
is of another type
(file vs. directory, for instance).
AccessDeniedException
- If the calling thread does not have the
required access rights.getValidEntityOrNull(EntityView, boolean)
public static void deleteRecursively(EntityView ent) throws ReadOnlyException, AccessDeniedException, EntityFoundException
This method will lock entities and their parent entities for writing when it deletes the entities.
If this method throws an exception, some of the entities to delete may have been deleted before the exception is thrown.
ent
- The entity to delete recursively.
ReadOnlyException
- If a read only entity is encountered.
AccessDeniedException
- If the calling thread does not have the
required permissions to delete an entity.
EntityFoundException
- If this method tries to delete a non-empty
directory. This may happen if the supplied entity is a
DirectoryView
that uses a
Filter
that hides at least one of its
child entities.IteratorDeleter
,
deleteRecursively(EntityView, boolean)
public static void deleteRecursively(EntityView ent, boolean deleteRoot) throws ReadOnlyException, AccessDeniedException, EntityFoundException
If the deleteRoot
argument is set to false
, the ent
entity itself will not be deleted.
This method will lock entities and their parent entities for writing when it deletes the entities.
If this method throws an exception, some of the entities to delete may have been deleted before the exception is thrown.
ent
- The entity to delete recursively.
ReadOnlyException
- If a read only entity is encountered.
AccessDeniedException
- If the calling thread does not have the
required permissions to delete an entity.
EntityFoundException
- If this method tries to delete a non-empty
directory. This may happen if the supplied entity is a
DirectoryView
that uses a
Filter
that hides at least one of its
child entities.IteratorDeleter
,
deleteRecursively(EntityView)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |