Class FileImpl

  • All Implemented Interfaces:
    IFile
    Direct Known Subclasses:
    DirectoryImpl

    public class FileImpl
    extends java.lang.Object
    implements IFile
    An implementation of IFile that represents a java.io.File.
    • Constructor Detail

      • FileImpl

        public FileImpl​(java.io.File f,
                        java.io.File rootFile)
        Parameters:
        f - this file.
        rootFile - the root of the vFS.
    • Method Detail

      • convert

        public IDirectory convert()
        Specified by:
        convert in interface IFile
        Returns:
        if this is a directory return this as an IDirectory, otherwise return null.
      • getLastModified

        public long getLastModified()
        Specified by:
        getLastModified in interface IFile
        Returns:
        the last modified date of the file.
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface IFile
        Returns:
        the name of the file relative to the root of the virtual FS. This will return a '/' separated path indepedent of underlying filesystem
      • getParent

        public IDirectory getParent()
        Specified by:
        getParent in interface IFile
        Returns:
        returns the parent directory of this IFile, or null if this is the root.
      • getSize

        public long getSize()
        Specified by:
        getSize in interface IFile
        Returns:
        the size of the file.
      • isDirectory

        public boolean isDirectory()
        Specified by:
        isDirectory in interface IFile
        Returns:
        true iff this IFile is also an IDirectory
      • isFile

        public boolean isFile()
        Specified by:
        isFile in interface IFile
        Returns:
        true iff this IFile is not an IDirectory
      • open

        public java.io.InputStream open()
                                 throws java.io.IOException
        Description copied from interface: IFile
        The input stream returned by this method should always be closed after use.
        Specified by:
        open in interface IFile
        Returns:
        An InputStream to read the file from.
        Throws:
        java.io.IOException
      • getRoot

        public IDirectory getRoot()
        Specified by:
        getRoot in interface IFile
        Returns:
        the root of this file system.
      • toURL

        public java.net.URL toURL()
                           throws java.net.MalformedURLException
        Specified by:
        toURL in interface IFile
        Returns:
        a URL that can be used to get at this file at a later date.
        Throws:
        java.net.MalformedURLException
      • equals

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

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • convertNested

        public IDirectory convertNested()
        Specified by:
        convertNested in interface IFile
        Returns:
        if this is a directory or an archive, returns the opened IDirectory