java.lang.Object
org.refcodes.filesystem.FileHandleImpl
- All Implemented Interfaces:
FileHandle
,FileSizeAccessor
,org.refcodes.mixin.CreatedDateAccessor
,org.refcodes.mixin.ModifiedDateAccessor
,org.refcodes.mixin.NameAccessor
,org.refcodes.mixin.PathAccessor
- Direct Known Subclasses:
FileHandleImpl.MutableFileHandleImpl
Straight forward implementation of the
FileHandle
,.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
The implementation of aFileHandle.MutableFileHandle
. ------------------------------------------------------------------------- CAUTION: fiddling with the path and the name attributes causes theFileHandleImpl.MutableFileHandleImpl.hashCode()
andFileHandleImpl.MutableFileHandleImpl.equals(Object)
methods to change behavior which can cause problems especially in collections!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.filesystem.FileHandle
FileHandle.MutableFileHandle
Nested classes/interfaces inherited from interface org.refcodes.filesystem.FileSizeAccessor
FileSizeAccessor.FileSizeMutator, FileSizeAccessor.FileSizeProperty
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
Nested classes/interfaces inherited from interface org.refcodes.mixin.PathAccessor
org.refcodes.mixin.PathAccessor.PathBuilder<B extends org.refcodes.mixin.PathAccessor.PathBuilder<?>>, org.refcodes.mixin.PathAccessor.PathMutator, org.refcodes.mixin.PathAccessor.PathProperty
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFileHandleImpl
(String aKey) Constructs aFileHandle
object with the given properties.FileHandleImpl
(String aPath, String aName) Constructs aFileHandle
object with the given properties.FileHandleImpl
(String aPath, String aName, long aSize, Date aCreatedDate, Date aModifiedDate) Constructs aFileHandle
object with the given properties.FileHandleImpl
(FileHandle aFileHandle) Constructs aFileHandle
object with the properties of the givenFileHandle
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
The date when the file was created.long
The size of the content of the file.The date when the file was modified.getName()
The name is the part of the key without the path.getPath()
The path is the part of the key without the name.int
hashCode()
toKey()
The key is the fully qualified name to identify the file.Converts the giveFileHandle
to aFileHandle.MutableFileHandle
.
-
Field Details
-
_path
-
_name
-
_size
protected long _size -
_createdDate
-
_modifiedDate
-
-
Constructor Details
-
FileHandleImpl
public FileHandleImpl(String aPath, String aName, long aSize, Date aCreatedDate, Date aModifiedDate) Constructs aFileHandle
object with the given properties.- Parameters:
aPath
- The path to which the file handle points.aName
- The name to which the path pointsaSize
- The size of the fileaCreatedDate
- The creation date of the fileaModifiedDate
- The modified date of the file
-
FileHandleImpl
Constructs aFileHandle
object with the given properties.- Parameters:
aKey
- The path and the name (= the key) to which the file handle points.
-
FileHandleImpl
Constructs aFileHandle
object with the given properties.- Parameters:
aPath
- The path to which the file handle points.aName
- The name to which the path points
-
FileHandleImpl
Constructs aFileHandle
object with the properties of the givenFileHandle
.- Parameters:
aFileHandle
- TheFileHandle
from which to take the required properties.
-
-
Method Details
-
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 interfaceFileHandle
- Specified by:
getPath
in interfaceorg.refcodes.mixin.PathAccessor
- Returns:
- The path of the file's key without the name.
-
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 interfaceFileHandle
- Specified by:
getName
in interfaceorg.refcodes.mixin.NameAccessor
- Returns:
- The name of the file's key without the path.
-
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.- Specified by:
toKey
in interfaceFileHandle
- Returns:
- The fully qualified key of the file.
-
getFileSize
public long getFileSize()The size of the content of the file.- Specified by:
getFileSize
in interfaceFileHandle
- Specified by:
getFileSize
in interfaceFileSizeAccessor
- Returns:
- The content size of the file.
-
getCreatedDate
The date when the file was created.- Specified by:
getCreatedDate
in interfaceorg.refcodes.mixin.CreatedDateAccessor
- Specified by:
getCreatedDate
in interfaceFileHandle
- Returns:
- The creation date.
-
getModifiedDate
The date when the file was modified.- Specified by:
getModifiedDate
in interfaceFileHandle
- Specified by:
getModifiedDate
in interfaceorg.refcodes.mixin.ModifiedDateAccessor
- Returns:
- The modification date.
-
hashCode
public int hashCode() -
equals
-
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.- Specified by:
toMutableFileHandle
in interfaceFileHandle
- Returns:
- the mutable file handle
-