Class FileHandleImpl

  • All Implemented Interfaces:
    FileHandle, org.refcodes.mixin.CreatedDateAccessor, org.refcodes.mixin.ModifiedDateAccessor, org.refcodes.mixin.NameAccessor, org.refcodes.mixin.PathAccessor, org.refcodes.mixin.SizeAccessor
    Direct Known Subclasses:
    FileHandleImpl.MutableFileHandleImpl

    public class FileHandleImpl
    extends java.lang.Object
    implements FileHandle
    Straight forward implementation of the FileHandle,.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  FileHandleImpl.MutableFileHandleImpl
      The implementation of a FileHandle.MutableFileHandle. ------------------------------------------------------------------------- CAUTION: fiddling with the path and the name attributes causes the FileHandleImpl.MutableFileHandleImpl.hashCode() and FileHandleImpl.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.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
      • Nested classes/interfaces inherited from interface org.refcodes.mixin.SizeAccessor

        org.refcodes.mixin.SizeAccessor.SizeMutator, org.refcodes.mixin.SizeAccessor.SizeProperty
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Date _createdDate  
      protected java.util.Date _modifiedDate  
      protected java.lang.String _name  
      protected java.lang.String _path  
      protected long _size  
    • Constructor Summary

      Constructors 
      Constructor Description
      FileHandleImpl​(java.lang.String aKey)
      Constructs a FileHandle object with the given properties.
      FileHandleImpl​(java.lang.String aPath, java.lang.String aName)
      Constructs a FileHandle object with the given properties.
      FileHandleImpl​(java.lang.String aPath, java.lang.String aName, long aSize, java.util.Date aCreatedDate, java.util.Date aModifiedDate)
      Constructs a FileHandle object with the given properties.
      FileHandleImpl​(FileHandle aFileHandle)
      Constructs a FileHandle object with the properties of the given FileHandle.
    • Field Detail

      • _path

        protected java.lang.String _path
      • _name

        protected java.lang.String _name
      • _size

        protected long _size
      • _createdDate

        protected java.util.Date _createdDate
      • _modifiedDate

        protected java.util.Date _modifiedDate
    • Constructor Detail

      • FileHandleImpl

        public FileHandleImpl​(java.lang.String aPath,
                              java.lang.String aName,
                              long aSize,
                              java.util.Date aCreatedDate,
                              java.util.Date aModifiedDate)
        Constructs a FileHandle object with the given properties.
        Parameters:
        aPath - The path to which the file handle points.
        aName - The name to which the path points
        aSize - The size of the file
        aCreatedDate - The creation date of the file
        aModifiedDate - The modified date of the file
      • FileHandleImpl

        public FileHandleImpl​(java.lang.String aKey)
        Constructs a FileHandle object with the given properties.
        Parameters:
        aKey - The path and the name (= the key) to which the file handle points.
      • FileHandleImpl

        public FileHandleImpl​(java.lang.String aPath,
                              java.lang.String aName)
        Constructs a FileHandle object with the given properties.
        Parameters:
        aPath - The path to which the file handle points.
        aName - The name to which the path points
      • FileHandleImpl

        public FileHandleImpl​(FileHandle aFileHandle)
        Constructs a FileHandle object with the properties of the given FileHandle.
        Parameters:
        aFileHandle - The FileHandle from which to take the required properties.
    • Method Detail

      • getPath

        public 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's FileSystem.PATH_DELIMITER attribute.
        Specified by:
        getPath in interface FileHandle
        Specified by:
        getPath in interface org.refcodes.mixin.PathAccessor
        Returns:
        The path of the file's key without the name.
      • getName

        public 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's FileSystem.PATH_DELIMITER attribute.
        Specified by:
        getName in interface FileHandle
        Specified by:
        getName in interface org.refcodes.mixin.NameAccessor
        Returns:
        The name of the file's key without the path.
      • toKey

        public 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.
        Specified by:
        toKey in interface FileHandle
        Returns:
        The fully qualified key of the file.
      • getSize

        public long getSize()
        The size of the content of the file.
        Specified by:
        getSize in interface FileHandle
        Specified by:
        getSize in interface org.refcodes.mixin.SizeAccessor
        Returns:
        The content size of the file.
      • getCreatedDate

        public java.util.Date getCreatedDate()
        The date when the file was created.
        Specified by:
        getCreatedDate in interface org.refcodes.mixin.CreatedDateAccessor
        Specified by:
        getCreatedDate in interface FileHandle
        Returns:
        The creation date.
      • getModifiedDate

        public java.util.Date getModifiedDate()
        The date when the file was modified.
        Specified by:
        getModifiedDate in interface FileHandle
        Specified by:
        getModifiedDate in interface org.refcodes.mixin.ModifiedDateAccessor
        Returns:
        The modification date.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toMutableFileHandle

        public FileHandle.MutableFileHandle toMutableFileHandle()
        Converts the give FileHandle to a FileHandle.MutableFileHandle. The mutable FileHandle allows the modification of (fiddling around with) attributes. ------------------------------------------------------------------------- ATTENTION: Usually fiddling around with attributes is not necessary, as the FileSystem 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 the FileHandle 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 the FileHandle know how to create a FileHandle.MutableFileHandle without information loss, the business logic does not require to take care of any yet unknown extensions. ------------------------------------------------------------------------- CAUTION: Working with modified FileHandles on the FileSystem can cause unexpected (severe) behavior (data loss), so we assume that you know what you do when using the FileHandle.MutableFileHandle! ------------------------------------------------------------------------- Use FileHandle.MutableFileHandle.toFileHandle() to get back to a FileHandle to avoid hassle with collections, the Object.hashCode() and the Object.equals(Object) operations.
        Specified by:
        toMutableFileHandle in interface FileHandle
        Returns:
        the mutable file handle