Package org.refcodes.filesystem
Interface FileHandle
-
- All Superinterfaces:
org.refcodes.mixin.CreatedDateAccessor
,org.refcodes.mixin.ModifiedDateAccessor
,org.refcodes.mixin.NameAccessor
,org.refcodes.mixin.PathAccessor
,org.refcodes.mixin.SizeAccessor
- All Known Subinterfaces:
FileHandle.MutableFileHandle
- All Known Implementing Classes:
FileHandleImpl
,FileHandleImpl.MutableFileHandleImpl
public interface FileHandle extends org.refcodes.mixin.PathAccessor, org.refcodes.mixin.NameAccessor, org.refcodes.mixin.SizeAccessor, org.refcodes.mixin.CreatedDateAccessor, org.refcodes.mixin.ModifiedDateAccessor
A file (handle) (descriptor) describes a file in a file system.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
FileHandle.MutableFileHandle
The mutableFileHandle
allows the modification of (fiddling around with) attributes. ------------------------------------------------------------------------- ATTENTION: Usually fiddling around with attributes is not necessary, as theFileSystem
itself provides the sufficient functionality to work with files.-
Nested classes/interfaces inherited from interface org.refcodes.mixin.CreatedDateAccessor
org.refcodes.mixin.CreatedDateAccessor.CreatedDateMutator, org.refcodes.mixin.CreatedDateAccessor.CreatedDateProperty
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.ModifiedDateAccessor
org.refcodes.mixin.ModifiedDateAccessor.ModifiedDateMutator, org.refcodes.mixin.ModifiedDateAccessor.ModifiedDateProperty
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.NameAccessor
org.refcodes.mixin.NameAccessor.NameBuilder<B extends org.refcodes.mixin.NameAccessor.NameBuilder<B>>, org.refcodes.mixin.NameAccessor.NameMutator, org.refcodes.mixin.NameAccessor.NameProperty
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Date
getCreatedDate()
The date when the file was created.java.util.Date
getModifiedDate()
The date when the file was modified.java.lang.String
getName()
The name is the part of the key without the path.java.lang.String
getPath()
The path is the part of the key without the name.long
getSize()
The size of the content of the file.java.lang.String
toKey()
The key is the fully qualified name to identify the file.FileHandle.MutableFileHandle
toMutableFileHandle()
Converts the giveFileHandle
to aFileHandle.MutableFileHandle
.
-
-
-
Method Detail
-
getPath
java.lang.String getPath()
The path is the part of the key without the name. The path separator is not implementation specific and should be retrieved from the file system'sFileSystem.PATH_DELIMITER
attribute.- Specified by:
getPath
in interfaceorg.refcodes.mixin.PathAccessor
- Returns:
- The path of the file's key without the name.
-
getName
java.lang.String getName()
The name is the part of the key without the path. The path separator is not implementation specific and should be retrieved from the file system'sFileSystem.PATH_DELIMITER
attribute.- Specified by:
getName
in interfaceorg.refcodes.mixin.NameAccessor
- Returns:
- The name of the file's key without the path.
-
toKey
java.lang.String toKey()
The key is the fully qualified name to identify the file. The key usually is physically (directory path and filename) or virtually composed of the path and the name.- Returns:
- The fully qualified key of the file.
-
getSize
long getSize()
The size of the content of the file.- Specified by:
getSize
in interfaceorg.refcodes.mixin.SizeAccessor
- Returns:
- The content size of the file.
-
getCreatedDate
java.util.Date getCreatedDate()
The date when the file was created.- Specified by:
getCreatedDate
in interfaceorg.refcodes.mixin.CreatedDateAccessor
- Returns:
- The creation date.
-
getModifiedDate
java.util.Date getModifiedDate()
The date when the file was modified.- Specified by:
getModifiedDate
in interfaceorg.refcodes.mixin.ModifiedDateAccessor
- Returns:
- The modification date.
-
toMutableFileHandle
FileHandle.MutableFileHandle toMutableFileHandle()
Converts the giveFileHandle
to aFileHandle.MutableFileHandle
. The mutableFileHandle
allows the modification of (fiddling around with) attributes. ------------------------------------------------------------------------- ATTENTION: Usually fiddling around with attributes is not necessary, as theFileSystem
itself provides the sufficient functionality to work with files. In some cases though this might be necessary: This method is being provided to allow modification of file attributes while making sure that theFileHandle
itself creates a copy so that any additional attributes provided by extensions of this interface of whom the developer does not know (yet) are preserved. So extensions of theFileHandle
know how to create aFileHandle.MutableFileHandle
without information loss, the business logic does not require to take care of any yet unknown extensions. ------------------------------------------------------------------------- CAUTION: Working with modifiedFileHandle
s on theFileSystem
can cause unexpected (severe) behavior (data loss), so we assume that you know what you do when using theFileHandle.MutableFileHandle
! ------------------------------------------------------------------------- UseFileHandle.MutableFileHandle.toFileHandle()
to get back to aFileHandle
to avoid hassle with collections, theObject.hashCode()
and theObject.equals(Object)
operations.- Returns:
- the mutable file handle
-
-