Class JarEntryFile

  • All Implemented Interfaces:
    IFile

    public class JarEntryFile
    extends Object
    implements IFile
    • Method Detail

      • getFileSystem

        @NotNull
        public FileSystem getFileSystem()
        Description copied from interface: IFile
        Use getFS() instead Note the IFileSystem is per-protocol, in which it differs from FileSystem.
        Specified by:
        getFileSystem in interface IFile
      • getName

        @NotNull
        public String getName()
        Specified by:
        getName in interface IFile
        Returns:
        simply the last name of the file (the furthest one)
      • getParent

        public IFile getParent()
        Specified by:
        getParent in interface IFile
        Returns:
        null iff the instance is root and has no parent, the parent folder otherwise
      • getChildren

        public List<IFile> getChildren()
        Specified by:
        getChildren in interface IFile
        Returns:
        the children of this file in case when it is a folder, null iff it is a file and therefore has no children
      • isArchive

        public boolean isArchive()
        Specified by:
        isArchive in interface IFile
      • isInArchive

        public boolean isInArchive()
        Specified by:
        isInArchive in interface IFile
        Returns:
        whether the underlying pathname points to an archive file or some of its contents
      • findChild

        @NotNull
        public IFile findChild​(@NotNull
                               String name)
        Description copied from interface: IFile
        Immediate child only. Empty name is forbidden. Neither path separators nor archive separators can't present in name
        Specified by:
        findChild in interface IFile
      • isDirectory

        public boolean isDirectory()
        Specified by:
        isDirectory in interface IFile
      • getPath

        @NotNull
        public String getPath()
        Description copied from interface: IFile
        Returns a path of this file in a file system.
        Specified by:
        getPath in interface IFile
      • lastModified

        public long lastModified()
        Description copied from interface: IFile
        fixme if it is the same as in java.io.File then we need to enforce it
        Specified by:
        lastModified in interface IFile
      • exists

        public boolean exists()
        Specified by:
        exists in interface IFile
      • createNewFile

        public boolean createNewFile()
        Description copied from interface: IFile
        creates a physical file
        Specified by:
        createNewFile in interface IFile
        Returns:
        whether it is a success
      • mkdirs

        public boolean mkdirs()
        Specified by:
        mkdirs in interface IFile
      • delete

        public boolean delete()
        Description copied from interface: IFile
        FIXME document what happens if one deletes non-empty folder. IoFile seems to force deletion. Is it the contract?
        Specified by:
        delete in interface IFile
        Returns:
        true if the deletion went with a success
      • rename

        public boolean rename​(@NotNull
                              String newName)
        Description copied from interface: IFile
        renames the file at which the instance of this IFile points (if it exists) the file stays under the same directory and changes its name to the newName
        Specified by:
        rename in interface IFile
        Returns:
        true iff success // * @deprecated use IFile.move(IFile)
      • move

        public boolean move​(@NotNull
                            IFile newParent)
        Description copied from interface: IFile
        moves/renames the file at which the instance of this IFile points
        Specified by:
        move in interface IFile
        Returns:
        true iff success
      • isReadOnly

        public boolean isReadOnly()
        Specified by:
        isReadOnly in interface IFile
      • length

        public long length()
        Specified by:
        length in interface IFile
      • getBundleHome

        public IFile getBundleHome()
        Specified by:
        getBundleHome in interface IFile
        Returns:
        the jar or folder which contains this file
      • setTimeStamp

        public boolean setTimeStamp​(long time)
        Specified by:
        setTimeStamp in interface IFile
      • getUrl

        public URL getUrl()
                   throws MalformedURLException
        The problem here is with jar URLs. JDK does not allow us to work efficiently with jar files via URI. 0. I want to create URL which can be converted to URI. 1. Unfortunately that means that we need to escape space characters. (unescaped URL cannot be converted to the URI due to the #toURI method contract) 2. We are urged to use multi-argument URI constructor in order to properly escape all characters (spaces for instance). Moreover it is a recommended way to comply to all URI protocol conventions. 3. URI multi-arg constructor also asks for its path to be absolute (which -- in his understanding -- means a path starting with '/') 4. In jdk a default URL for a jar-file looks like 'jar:file://a.jar!/b.txt' and calling URL#getPath returns 'file://a.jar!/b.txt' which does not start with the slash and hence is not absolute and therefore cannot be simply passed to the URI constructor. 5. That is why we are compelled to use such a hack in constructor arguments which namely passes a jar:file scheme and passes an honest absolute path '/a.jar!/b.txt'.

        [AP: I would rather return URLs which can be converted to URIs than the ones which can not] Hopefully this hell will be replaced by the upcoming vfs.Path features.

        Specified by:
        getUrl in interface IFile
        Throws:
        MalformedURLException
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object