Package gw.fs.jar
Class JarFileDirectoryImpl
- java.lang.Object
-
- gw.fs.jar.JarFileDirectoryImpl
-
- All Implemented Interfaces:
IDirectory,IResource,IJarFileDirectory
public class JarFileDirectoryImpl extends java.lang.Object implements IJarFileDirectory
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<IDirectory>_childDirsprivate java.util.List<IFile>_childFilesprivate java.io.File_fileprivate java.util.jar.JarFile_jarFileprivate java.util.Map<java.lang.String,IResource>_resources
-
Constructor Summary
Constructors Constructor Description JarFileDirectoryImpl(java.io.File file)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearCaches()booleancreate()booleandelete()IDirectorydir(java.lang.String relativePath)booleanequals(java.lang.Object obj)booleanexists()Indicates whether this resource exists.IFilefile(java.lang.String path)Constucts a file given the path.java.io.InputStreamgetInputStream(java.util.jar.JarEntry entry)java.util.jar.JarFilegetJarFile()java.lang.StringgetName()Gets this file's or directory's name.JarEntryDirectoryImplgetOrCreateDirectory(java.lang.String relativeName)JarEntryFileImplgetOrCreateFile(java.lang.String relativeName)IDirectorygetParent()Gets this file's our directory's parent directory.ResourcePathgetPath()booleanhasChildFile(java.lang.String path)Returns true if the given path represents a child of this directory that exists.booleanisAdditional()booleanisChildOf(IDirectory dir)Indicates whether this resource is a direct child of the given directory.booleanisDescendantOf(IDirectory dir)Indicates whether this resource is a descendant of the given directory.booleanisInJar()booleanisJavaFile()java.util.List<? extends IDirectory>listDirs()java.util.List<? extends IFile>listFiles()booleanmkdir()private voidprocessJarEntry(java.util.jar.JarEntry e)java.lang.StringrelativePath(IResource resource)java.io.FiletoJavaFile()java.lang.StringtoString()java.net.URItoURI()
-
-
-
Field Detail
-
_file
private java.io.File _file
-
_jarFile
private java.util.jar.JarFile _jarFile
-
_resources
private java.util.Map<java.lang.String,IResource> _resources
-
_childDirs
private java.util.List<IDirectory> _childDirs
-
_childFiles
private java.util.List<IFile> _childFiles
-
-
Method Detail
-
processJarEntry
private void processJarEntry(java.util.jar.JarEntry e)
-
getInputStream
public java.io.InputStream getInputStream(java.util.jar.JarEntry entry) throws java.io.IOException- Throws:
java.io.IOException
-
getOrCreateDirectory
public JarEntryDirectoryImpl getOrCreateDirectory(java.lang.String relativeName)
- Specified by:
getOrCreateDirectoryin interfaceIJarFileDirectory
-
getOrCreateFile
public JarEntryFileImpl getOrCreateFile(java.lang.String relativeName)
- Specified by:
getOrCreateFilein interfaceIJarFileDirectory
-
dir
public IDirectory dir(java.lang.String relativePath)
- Specified by:
dirin interfaceIDirectory
-
file
public IFile file(java.lang.String path)
Description copied from interface:IDirectoryConstucts a file given the path. If the path is relative path, it will be constructed based on the current directory- Specified by:
filein interfaceIDirectory- Parameters:
path- the path of the file- Returns:
- The file that is under the directory with the name
-
mkdir
public boolean mkdir() throws java.io.IOException- Specified by:
mkdirin interfaceIDirectory- Throws:
java.io.IOException
-
listDirs
public java.util.List<? extends IDirectory> listDirs()
- Specified by:
listDirsin interfaceIDirectory
-
listFiles
public java.util.List<? extends IFile> listFiles()
- Specified by:
listFilesin interfaceIDirectory
-
relativePath
public java.lang.String relativePath(IResource resource)
- Specified by:
relativePathin interfaceIDirectory
-
getParent
public IDirectory getParent()
Description copied from interface:IResourceGets this file's our directory's parent directory.
-
getName
public java.lang.String getName()
Description copied from interface:IResourceGets this file's or directory's name.
-
exists
public boolean exists()
Description copied from interface:IResourceIndicates whether this resource exists.
-
delete
public boolean delete() throws java.io.IOException
-
getPath
public ResourcePath getPath()
-
isChildOf
public boolean isChildOf(IDirectory dir)
Description copied from interface:IResourceIndicates whether this resource is a direct child of the given directory.
-
isDescendantOf
public boolean isDescendantOf(IDirectory dir)
Description copied from interface:IResourceIndicates whether this resource is a descendant of the given directory.- Specified by:
isDescendantOfin interfaceIResource- Parameters:
dir- the directory which would be the ancestor- Returns:
- true if this is a descendant of the given directory
-
toJavaFile
public java.io.File toJavaFile()
- Specified by:
toJavaFilein interfaceIResource
-
getJarFile
public java.util.jar.JarFile getJarFile()
-
isJavaFile
public boolean isJavaFile()
- Specified by:
isJavaFilein interfaceIResource
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
clearCaches
public void clearCaches()
- Specified by:
clearCachesin interfaceIDirectory
-
hasChildFile
public boolean hasChildFile(java.lang.String path)
Description copied from interface:IDirectoryReturns 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:
hasChildFilein 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:
isAdditionalin interfaceIDirectory- Returns:
- true if this is an "additional" path for resources not copied to the target classpath e.g., config bullshit.
-
-