Package gw.fs.jar
Class JarFileDirectoryImpl
- java.lang.Object
-
- gw.fs.jar.JarFileDirectoryImpl
-
- All Implemented Interfaces:
IDirectory
,IResource
,IJarFileDirectory
public class JarFileDirectoryImpl extends Object implements IJarFileDirectory
-
-
Constructor Summary
Constructors Constructor Description JarFileDirectoryImpl(File file)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearCaches()
boolean
create()
boolean
delete()
IDirectory
dir(String relativePath)
boolean
equals(Object obj)
boolean
exists()
Indicates whether this resource exists.IFile
file(String path)
Constucts a file given the path.InputStream
getInputStream(JarEntry entry)
JarFile
getJarFile()
String
getName()
Gets this file's or directory's name.JarEntryDirectoryImpl
getOrCreateDirectory(String relativeName)
JarEntryFileImpl
getOrCreateFile(String relativeName)
IDirectory
getParent()
Gets this file's our directory's parent directory.ResourcePath
getPath()
boolean
hasChildFile(String path)
Returns true if the given path represents a child of this directory that exists.boolean
isAdditional()
boolean
isChildOf(IDirectory dir)
Indicates whether this resource is a direct child of the given directory.boolean
isDescendantOf(IDirectory dir)
Indicates whether this resource is a descendant of the given directory.boolean
isInJar()
boolean
isJavaFile()
List<? extends IDirectory>
listDirs()
List<? extends IFile>
listFiles()
boolean
mkdir()
String
relativePath(IResource resource)
File
toJavaFile()
String
toString()
URI
toURI()
-
-
-
Constructor Detail
-
JarFileDirectoryImpl
public JarFileDirectoryImpl(File file)
-
-
Method Detail
-
getInputStream
public InputStream getInputStream(JarEntry entry) throws IOException
- Throws:
IOException
-
getOrCreateDirectory
public JarEntryDirectoryImpl getOrCreateDirectory(String relativeName)
- Specified by:
getOrCreateDirectory
in interfaceIJarFileDirectory
-
getOrCreateFile
public JarEntryFileImpl getOrCreateFile(String relativeName)
- Specified by:
getOrCreateFile
in interfaceIJarFileDirectory
-
dir
public IDirectory dir(String relativePath)
- Specified by:
dir
in interfaceIDirectory
-
file
public IFile file(String path)
Description copied from interface:IDirectory
Constucts a file given the path. If the path is relative path, it will be constructed based on the current directory- Specified by:
file
in interfaceIDirectory
- Parameters:
path
- the path of the file- Returns:
- The file that is under the directory with the name
-
mkdir
public boolean mkdir() throws IOException
- Specified by:
mkdir
in interfaceIDirectory
- Throws:
IOException
-
listDirs
public List<? extends IDirectory> listDirs()
- Specified by:
listDirs
in interfaceIDirectory
-
listFiles
public List<? extends IFile> listFiles()
- Specified by:
listFiles
in interfaceIDirectory
-
relativePath
public String relativePath(IResource resource)
- Specified by:
relativePath
in interfaceIDirectory
-
getParent
public IDirectory getParent()
Description copied from interface:IResource
Gets this file's our directory's parent directory.
-
getName
public String getName()
Description copied from interface:IResource
Gets this file's or directory's name.
-
exists
public boolean exists()
Description copied from interface:IResource
Indicates whether this resource exists.
-
delete
public boolean delete() throws IOException
- Specified by:
delete
in interfaceIResource
- Throws:
IOException
-
getPath
public ResourcePath getPath()
-
isChildOf
public boolean isChildOf(IDirectory dir)
Description copied from interface:IResource
Indicates whether this resource is a direct child of the given directory.
-
isDescendantOf
public boolean isDescendantOf(IDirectory dir)
Description copied from interface:IResource
Indicates whether this resource is a descendant of the given directory.- Specified by:
isDescendantOf
in interfaceIResource
- Parameters:
dir
- the directory which would be the ancestor- Returns:
- true if this is a descendant of the given directory
-
toJavaFile
public File toJavaFile()
- Specified by:
toJavaFile
in interfaceIResource
-
getJarFile
public JarFile getJarFile()
-
isJavaFile
public boolean isJavaFile()
- Specified by:
isJavaFile
in interfaceIResource
-
clearCaches
public void clearCaches()
- Specified by:
clearCaches
in interfaceIDirectory
-
hasChildFile
public boolean hasChildFile(String path)
Description copied from interface:IDirectory
Returns true if the given path represents a child of this directory that exists. It's essentially equivalent to calling file(path).exists(), but in cases where this directory caches its list of children and the path represents a direct child of this directory, this method can be optimized to avoid file system access by looking in the list of cached children.- Specified by:
hasChildFile
in interfaceIDirectory
- Parameters:
path
- the path of the file- Returns:
- true if the path represents a file that exists as a child of this directory
-
isAdditional
public boolean isAdditional()
- Specified by:
isAdditional
in interfaceIDirectory
- Returns:
- true if this is an "additional" path for resources not copied to the target classpath e.g., config bullshit.
-
-