|
Remote Systems v6.4.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.etools.systems.core.archiveutils.SystemZipHandler
Field Summary | |
---|---|
protected boolean |
_exists
|
protected File |
_file
|
protected long |
_vfsLastModified
|
protected HashMap |
_virtualFS
|
protected ZipFile |
_zipfile
|
Constructor Summary | |
---|---|
SystemZipHandler(File file)
Creates a new SystemZipHandler and associates it with file . |
Method Summary | |
---|---|
boolean |
add(File[] files,
String virtualPath,
String[] names)
A generalization of the add method. |
boolean |
add(File[] files,
String virtualPath,
String[] names,
String[] encodings,
boolean[] isText)
A generalization of the add method. |
boolean |
add(File[] files,
String virtualPath,
String[] names,
String[] encodings,
boolean[] isText,
boolean closeZipFile)
Same as add(File[] files, String virtualPath, String[] names, String[] encodings) but you can choose whether or not you want to leave the zipfile open after return. |
boolean |
add(File file,
String virtualPath,
String name)
Compresses the file file and adds it to the archive,
placing it in the virtual directory virtualPath . |
boolean |
add(File file,
String virtualPath,
String name,
String encoding,
boolean isText)
Compresses the file file and adds it to the archive,
saving it in the encoding specified by encoding if the isText is true.
|
boolean |
add(File file,
String virtualPath,
String name,
String encoding,
ISystemFileTypes registry)
Compresses the file file and adds it to the archive,
saving it in the encoding specified by encoding if the isText is true.
|
protected ZipEntry |
appendEmptyFile(ZipOutputStream dest,
String name)
Works similarly to appendFile, except no actual data is appended to the zipfile, only an entry is created. |
protected ZipEntry |
appendFile(File file,
ZipOutputStream dest,
String virtualPath,
String name,
String encoding,
boolean isText)
Compresses the contents of file , adding them to the
ZipFile managed by dest . |
protected void |
buildTree()
Builds the virtual file system tree out of the entries in the zipfile. |
protected boolean |
closeZipFile()
|
boolean |
create()
Turns the archive that this handler represents into a new, empty archive. |
protected boolean |
createFile(File file)
|
boolean |
createFile(String name)
Creates a new, empty file in the archive. |
boolean |
createFolder(String name)
Creates a new, empty folder in the archive. |
protected ZipEntry |
createSafeZipEntry(String name)
A "safe" ZipEntry is one whose virtual path does not begin with a "/". |
protected boolean |
createVirtualObject(String name,
boolean closeZipFile)
Creates a new, empty object in the virtual File system, and creates an empty file or folder in the physical zip file. |
boolean |
delete(String fullVirtualName)
Deletes the entry fullVirtualName from the archive, and returns
whether or not the deletion was successful. |
boolean |
delete(String fullVirtualName,
boolean closeZipFile)
Same as delete(String fullVirtualName) but you can choose whether or not you want to leave the zipfile open after return. |
protected void |
delTree(VirtualChild vc)
Deletes all the children of the directory VirtualChild vc
recursively down to the leaves.
|
boolean |
exists()
|
boolean |
exists(String fullVirtualName)
|
boolean |
extractVirtualDirectory(String dir,
File destinationParent)
Extracts the directory dir (and its children) from
the archive and places the results in the directory destinationParent . |
boolean |
extractVirtualDirectory(String dir,
File destinationParent,
File destination)
Extracts the directory dir (and its children) from
the archive and places the results in the directory destinationParent .
|
boolean |
extractVirtualDirectory(String dir,
File destinationParent,
File destination,
String sourceEncoding,
boolean isText)
Extracts the directory dir (and its children) from
the archive and places the results in the directory destinationParent .
|
boolean |
extractVirtualDirectory(String dir,
File destinationParent,
String sourceEncoding,
boolean isText)
Extracts the directory dir (and its children) from
the archive and places the results in the directory destinationParent .
|
boolean |
extractVirtualFile(String fullVirtualName,
File destination)
Extracts the virtual file named fullVirtualName from the archive,
placing the results in destination . |
boolean |
extractVirtualFile(String fullVirtualName,
File destination,
boolean closeZipFile,
String sourceEncoding,
boolean isText)
Same as extractVirtualFile(String fullVirtualName, File destination) but you can choose whether or not you want to leave the zipfile open after return. |
boolean |
extractVirtualFile(String fullVirtualName,
File destination,
String sourceEncoding,
boolean isText)
Extracts the virtual file named fullVirtualName from the archive,
placing the results in destination . |
protected void |
fillBranch(ZipEntry next)
Populates an entire branch of the tree that comprises the virtual file system. |
boolean |
fullRename(String fullVirtualName,
String newFullVirtualName)
Replaces the full name and path of the entry fullVirtualName
with the new full name and path newFullVirtualName .
|
boolean |
fullRename(String fullVirtualName,
String newFullVirtualName,
boolean closeZipFile)
Same as fullRename(String fullVirtualName, String newFullVirtualName) but you can choose whether or not you want to leave the zipfile open after return. |
File |
getArchive()
|
String |
getArchiveComment()
|
String |
getClassification(String fullVirtualName)
Returns the classification for the entry with the given path. |
String |
getClassification(String fullVirtualName,
boolean closeZipFile)
Same as getClassification(String), but you can choose whether to leave the zip file open after the method is closed. |
String |
getCommentFor(String fullVirtualName)
Gets the user-defined comment for a specific entry in the archive. |
String |
getCommentFor(String fullVirtualName,
boolean closeZipFile)
same as getCommentFor(String) but you can choose whether or not to leave the zipfile open after the method is closed |
long |
getCompressedSizeFor(String fullVirtualName)
Gets the amount of space taken up by a specific entry in the archive when it is in compressed form. |
long |
getCompressedSizeFor(String fullVirtualName,
boolean closeZipFile)
same as getCompressedSizeFor(String) but you can choose whether or not to leave the zipfile open after the method is closed |
String |
getCompressionMethodFor(String fullVirtualName)
Gets the method used to compress a specific entry in the archive. |
String |
getCompressionMethodFor(String fullVirtualName,
boolean closeZipFile)
same as getCompressionMethodFor(String) but you can choose whether or not to leave the zipfile open after the method is closed |
File[] |
getFiles(String[] fullNames)
Extracts and returns the specified list of virtual files from the archive. |
long |
getSizeFor(String fullVirtualName)
|
long |
getSizeFor(String fullVirtualName,
boolean closeZipFile)
|
String |
getStandardName(VirtualChild vc)
Gets the archive-type specific standard name for the VirtualChild vc . |
long |
getTimeStampFor(String fullVirtualName)
|
long |
getTimeStampFor(String fullVirtualName,
boolean closeZipFile)
Same as getTimeStampFor(String fullVirtualName) but you can choose whether or not you want to leave the zipfile open after return. |
VirtualChild[] |
getVirtualChildFolders(String fullVirtualName)
|
VirtualChild[] |
getVirtualChildren(String fullVirtualName)
|
VirtualChild[] |
getVirtualChildrenList()
|
VirtualChild[] |
getVirtualChildrenList(boolean closeZipFile)
Same as getVirtualChildrenList(), but you can choose whether to leave the zip file open or closed upon return. |
VirtualChild[] |
getVirtualChildrenList(String parent)
|
VirtualChild[] |
getVirtualChildrenList(String parent,
boolean closeZipFile)
Same as getVirtualChildrenList(String parent) but you can choose whether or not you want to leave the zipfile open after return. |
VirtualChild |
getVirtualFile(String fullVirtualName)
|
static void |
listAllFiles(File parent,
HashSet found)
Helper method. . . populates found with a
collapsed list of all nodes in the subtree
of the file system rooted at parent . |
boolean |
move(String fullVirtualName,
String destinationVirtualPath)
Moves the entry fullVirtualName to the location
specified by destinationVirtualPath , while leaving the entry with
the same name as before. |
protected boolean |
openZipFile()
Opens the zipfile that this handler manages. |
protected void |
recreateZipDeleteEntries(VirtualChild[] vcList,
ZipOutputStream dest,
HashSet omitChildren)
Recreates a zip file from a list of virtual children, optionally omitting a group of children whose names are in the Set omitChildren |
protected void |
recreateZipRenameEntries(VirtualChild[] vcList,
ZipOutputStream dest,
HashMap names)
Recreates a zip file from a list of virtual children, but renaming the one of the VirtualChildren. |
protected void |
recursivePopulate(String key,
VirtualChild value)
Actually does the work for the fillBranch method. |
boolean |
rename(String fullVirtualName,
String newName)
Renames the entry fullVirtualName to the new name
newName while still leaving the entry in the same virtual
directory. |
boolean |
replace(String fullVirtualName,
File file,
String name)
Compress the file file and replace the virtual file
referred to by fullVirtualName with the compressed file.
|
boolean |
replace(String fullVirtualName,
File file,
String name,
boolean closeZipFile)
Same as replace(String fullVirtualName, File file, String name) but you can choose whether or not you want to leave the zipfile open after return. |
protected void |
replaceOldZip(File outputTempFile)
Replaces the old zip file managed by this SystemZipHandler, with the zip file referred to by outputTempFile. |
protected ZipEntry |
safeGetEntry(String name)
Returns the entry corresponding to name from _zipfile. |
SystemSearchLineMatch[] |
search(String fullVirtualName,
SystemSearchStringMatcher matcher)
Searches for text within a virtual file in this archive. |
protected boolean |
updateVirtualFSIfNecessary()
If the mod-times of the underlying zip file and the file used to create the virtualFS are different, update the virtualFS. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected ZipFile _zipfile
protected HashMap _virtualFS
protected File _file
protected long _vfsLastModified
protected boolean _exists
Constructor Detail |
public SystemZipHandler(File file)
file
.
file
- The file that this handler will wrapper.
IOException
- If there is an error handling file
Method Detail |
protected void buildTree()
protected void fillBranch(ZipEntry next)
next
- The ZipEntry from which the branch will be built.protected void recursivePopulate(String key, VirtualChild value)
public VirtualChild[] getVirtualChildrenList()
getVirtualChildrenList
in interface ISystemArchiveHandler
public VirtualChild[] getVirtualChildrenList(boolean closeZipFile)
public VirtualChild[] getVirtualChildrenList(String parent)
getVirtualChildrenList
in interface ISystemArchiveHandler
parent
.
Returns an array of length 0 if there are no such entries.public VirtualChild[] getVirtualChildrenList(String parent, boolean closeZipFile)
public VirtualChild[] getVirtualChildren(String fullVirtualName)
getVirtualChildren
in interface ISystemArchiveHandler
fullVirtualName
. If fullVirtualName
is "",
returns the top level in the virtual file system tree. If there are no
values to return, returns null.public VirtualChild[] getVirtualChildFolders(String fullVirtualName)
getVirtualChildFolders
in interface ISystemArchiveHandler
fullVirtualName
that are themselves directories.
If fullVirtualName
is "",
returns the top level of directories in the virtual file system tree.
If there are no values to return, returns null.public VirtualChild getVirtualFile(String fullVirtualName)
getVirtualFile
in interface ISystemArchiveHandler
fullVirtualName
.
This method never returns null. In cases where the VirtualChild does not
physically exist in the archive, this method returns a new VirtualChild object
whose exists() method returns false.public boolean exists(String fullVirtualName)
exists
in interface ISystemArchiveHandler
fullVirtualName
exists in the archive (physically).public File getArchive()
getArchive
in interface ISystemArchiveHandler
public long getTimeStampFor(String fullVirtualName)
getTimeStampFor
in interface ISystemArchiveHandler
fullVirtualName
public long getTimeStampFor(String fullVirtualName, boolean closeZipFile)
public long getSizeFor(String fullVirtualName)
getSizeFor
in interface ISystemArchiveHandler
fullVirtualName
public long getSizeFor(String fullVirtualName, boolean closeZipFile)
public boolean extractVirtualFile(String fullVirtualName, File destination)
ISystemArchiveHandler
fullVirtualName
from the archive,
placing the results in destination
.
extractVirtualFile
in interface ISystemArchiveHandler
fullVirtualName
- The full path and name of the virtual file in the archive.destination
- The destination file for the extracted virtual file.
public boolean extractVirtualFile(String fullVirtualName, File destination, String sourceEncoding, boolean isText)
ISystemArchiveHandler
fullVirtualName
from the archive,
placing the results in destination
. Extracts to the native encoding, but assumes
that the source was archived using sourceEncoding
if isText
is true.
extractVirtualFile
in interface ISystemArchiveHandler
fullVirtualName
- The full path and name of the virtual file in the archive.destination
- The destination file for the extracted virtual file.sourceEncoding
- The encoding of the file in the archive.isText
- Whether or not the virtual file is a text file.
public boolean extractVirtualFile(String fullVirtualName, File destination, boolean closeZipFile, String sourceEncoding, boolean isText)
public boolean extractVirtualDirectory(String dir, File destinationParent)
ISystemArchiveHandler
dir
(and its children) from
the archive and places the results in the directory destinationParent
.
extractVirtualDirectory
in interface ISystemArchiveHandler
dir
- The full name of the virtual directory to extractdestinationParent
- A handle to the directory in which the extracted
directory will be placed as a subdirectory.
public boolean extractVirtualDirectory(String dir, File destinationParent, String sourceEncoding, boolean isText)
ISystemArchiveHandler
dir
(and its children) from
the archive and places the results in the directory destinationParent
.
Extracts to the native encoding (if isText
), but assumes
that the source was archived using sourceEncoding
.
extractVirtualDirectory
in interface ISystemArchiveHandler
dir
- The full name of the virtual directory to extractdestinationParent
- A handle to the directory in which the extracted
directory will be placed as a subdirectory.sourceEncoding
- The encoding of the files in the archive.isText
- Whether or not the files in the directory are text files
public boolean extractVirtualDirectory(String dir, File destinationParent, File destination)
ISystemArchiveHandler
dir
(and its children) from
the archive and places the results in the directory destinationParent
.
The results will be named destination.getName() rather than dir
's name.
extractVirtualDirectory
in interface ISystemArchiveHandler
dir
- The full name of the virtual directory to extractdestinationParent
- A handle to the directory in which the extracted
directory will be placed as a subdirectory.destination
- A handle to the directory that will be created. Whatever
contents are in that directory will be replaced with what is extracted from
the archive.
public boolean extractVirtualDirectory(String dir, File destinationParent, File destination, String sourceEncoding, boolean isText)
ISystemArchiveHandler
dir
(and its children) from
the archive and places the results in the directory destinationParent
.
The results will be named destination.getName() rather than dir
's name.
Extracts to the native encoding (if isText
), but assumes
that the source was archived using sourceEncoding
.
extractVirtualDirectory
in interface ISystemArchiveHandler
dir
- The full name of the virtual directory to extractdestinationParent
- A handle to the directory in which the extracted
directory will be placed as a subdirectory.destination
- A handle to the directory that will be created. Whatever
contents are in that directory will be replaced with what is extracted from
the archive.sourceEncoding
- The encoding of the files in the archive.isText
- Whether or not the files to be extracted in the directory are all text files
protected boolean createFile(File file)
public boolean add(File file, String virtualPath, String name)
ISystemArchiveHandler
file
and adds it to the archive,
placing it in the virtual directory virtualPath
. Pass the
name as the parameter name
. If the virtual path does not exist
in the archive, create it. If file
is a directory, copy it and
its contents into the archive, maintaining the tree structure.
add
in interface ISystemArchiveHandler
public boolean add(File file, String virtualPath, String name, String encoding, ISystemFileTypes registry)
ISystemArchiveHandler
file
and adds it to the archive,
saving it in the encoding specified by encoding
if the isText is true.
placing it in the virtual directory virtualPath
. Pass the
name as the parameter name
. If the virtual path does not exist
in the archive, create it. If file
is a directory, copy it and
its contents into the archive, maintaining the tree structure.
add
in interface ISystemArchiveHandler
public boolean add(File file, String virtualPath, String name, String encoding, boolean isText)
ISystemArchiveHandler
file
and adds it to the archive,
saving it in the encoding specified by encoding
if the isText is true.
placing it in the virtual directory virtualPath
. Pass the
name as the parameter name
. If the virtual path does not exist
in the archive, create it. If file
is a directory, copy it and
its contents into the archive, maintaining the tree structure.
add
in interface ISystemArchiveHandler
public boolean add(File[] files, String virtualPath, String[] names)
ISystemArchiveHandler
files
and adds each of them to the archive, placing them
in the virtual directory virtualPath
. Pass the names of the files
as the parameter names
, where files[i]
has the name names[i]
.
If the virtual path does not exist in the archive, create it.
add
in interface ISystemArchiveHandler
public boolean add(File[] files, String virtualPath, String[] names, String[] encodings, boolean[] isText)
ISystemArchiveHandler
files
and adds each of them to the archive, placing them
in the virtual directory virtualPath
. Save the i'th file in the i'th encoding (if isText[i] is true)
specified by encodings
. Pass the names of the files
as the parameter names
, where files[i]
has the name names[i]
.
If the virtual path does not exist in the archive, create it.
add
in interface ISystemArchiveHandler
public boolean add(File[] files, String virtualPath, String[] names, String[] encodings, boolean[] isText, boolean closeZipFile)
public static void listAllFiles(File parent, HashSet found)
found
with a
collapsed list of all nodes in the subtree
of the file system rooted at parent
.
protected void recreateZipDeleteEntries(VirtualChild[] vcList, ZipOutputStream dest, HashSet omitChildren) throws IOException
vcList
- The list of virtual children to create the zip fromdest
- The ZipOutputStream representing the zip file where the
children are to be recreatedomitChildren
- The set of names of children to omit when creating
the zipfile. Null or empty set if there are no ommisions.
IOException
protected void recreateZipRenameEntries(VirtualChild[] vcList, ZipOutputStream dest, HashMap names) throws IOException
vcList
- The list of virtual children to create the zip fromdest
- The ZipOutputStream representing the zip file where the
children are to be recreated
IOException
protected ZipEntry appendFile(File file, ZipOutputStream dest, String virtualPath, String name, String encoding, boolean isText) throws IOException
file
, adding them to the
ZipFile managed by dest
. The file is encoded in the encoding
specified by encoding
. A new entry is created in the
ZipFile with virtual path and name of virtualPath
and name
respectively.
IOException
protected void replaceOldZip(File outputTempFile) throws IOException
IOException
- if outputTempFile cannot be used as a ZipFile.public boolean delete(String fullVirtualName)
ISystemArchiveHandler
fullVirtualName
from the archive, and returns
whether or not the deletion was successful.
delete
in interface ISystemArchiveHandler
public boolean delete(String fullVirtualName, boolean closeZipFile)
protected void delTree(VirtualChild vc)
vc
recursively down to the leaves.
Pre: vc.isDirectory is true
vc
- The child whose children we are deleting.public boolean replace(String fullVirtualName, File file, String name)
ISystemArchiveHandler
file
and replace the virtual file
referred to by fullVirtualName
with the compressed file.
Pass the name of the file as the parameter name
.
replace
in interface ISystemArchiveHandler
public boolean replace(String fullVirtualName, File file, String name, boolean closeZipFile)
public boolean fullRename(String fullVirtualName, String newFullVirtualName)
ISystemArchiveHandler
fullVirtualName
with the new full name and path newFullVirtualName
.
Returns true if and only if the operation was successfull.
fullRename
in interface ISystemArchiveHandler
public boolean fullRename(String fullVirtualName, String newFullVirtualName, boolean closeZipFile)
public boolean move(String fullVirtualName, String destinationVirtualPath)
ISystemArchiveHandler
fullVirtualName
to the location
specified by destinationVirtualPath
, while leaving the entry with
the same name as before. Returns true if and only if the move was successfull.
move
in interface ISystemArchiveHandler
public boolean rename(String fullVirtualName, String newName)
ISystemArchiveHandler
fullVirtualName
to the new name
newName
while still leaving the entry in the same virtual
directory. Returns true if and only if the rename was successfull.
rename
in interface ISystemArchiveHandler
public File[] getFiles(String[] fullNames)
ISystemArchiveHandler
getFiles
in interface ISystemArchiveHandler
fullNames
- The list of files to return
public boolean createFolder(String name)
ISystemArchiveHandler
createFolder
in interface ISystemArchiveHandler
name
- The full name and path of the new folder within the virtual file system.
public boolean createFile(String name)
ISystemArchiveHandler
createFile
in interface ISystemArchiveHandler
name
- The full name and path of the new file within the virtual file system.
protected boolean createVirtualObject(String name, boolean closeZipFile)
name
- The name of the file or folder to create. The object
created will be a folder if and only if
name
ends in a "/".
protected ZipEntry appendEmptyFile(ZipOutputStream dest, String name) throws IOException
dest
- The destination zip stream to append the entry.name
- The new, virtual fullname to give the entry.
IOException
- If there was an error appending the entry to the stream.protected ZipEntry createSafeZipEntry(String name)
name
- The virtual name for the new, safe ZipEntry.
public String getStandardName(VirtualChild vc)
ISystemArchiveHandler
vc
. For example, for Zips, if vc is a directory, then
the standard name must end with a "/".
getStandardName
in interface ISystemArchiveHandler
protected boolean openZipFile()
protected boolean closeZipFile()
protected boolean updateVirtualFSIfNecessary()
protected ZipEntry safeGetEntry(String name) throws IOException
name
from _zipfile. Never returns
null, but rather, throws an IOException if it cannot find the entry. Tries to retrieve
both name
and "/" + name, to accomodate for zipfiles created
in a unix environment. ASSUMES THAT _zipfile IS ALREADY OPEN!
- Throws:
IOException
public boolean create()
ISystemArchiveHandler
create
in interface ISystemArchiveHandler
public SystemSearchLineMatch[] search(String fullVirtualName, SystemSearchStringMatcher matcher)
ISystemArchiveHandler
search
in interface ISystemArchiveHandler
fullVirtualName
- the virtual file to search.matcher
- the pattern matcher to use.
public boolean exists()
exists
in interface ISystemArchiveHandler
public String getCommentFor(String fullVirtualName)
ISystemArchiveHandler
getCommentFor
in interface ISystemArchiveHandler
fullVirtualName
- The entry who's comment is desired
public String getCommentFor(String fullVirtualName, boolean closeZipFile)
public long getCompressedSizeFor(String fullVirtualName)
ISystemArchiveHandler
getCompressedSizeFor
in interface ISystemArchiveHandler
fullVirtualName
- The entry who's compressed size is desired
public long getCompressedSizeFor(String fullVirtualName, boolean closeZipFile)
public String getCompressionMethodFor(String fullVirtualName)
ISystemArchiveHandler
getCompressionMethodFor
in interface ISystemArchiveHandler
fullVirtualName
- The entry who's compression method is desired
public String getCompressionMethodFor(String fullVirtualName, boolean closeZipFile)
public String getArchiveComment()
getArchiveComment
in interface ISystemArchiveHandler
public String getClassification(String fullVirtualName)
ISystemArchiveHandler
getClassification
in interface ISystemArchiveHandler
fullVirtualName
- the virtual name.
com.ibm.etools.systems.core.archiveutils.ISystemArchiveHandler#isExecutable(java.lang.String)
public String getClassification(String fullVirtualName, boolean closeZipFile)
com.ibm.etools.systems.core.archiveutils.ISystemArchiveHandler#isExecutable(java.lang.String)
|
Remote Systems v6.4.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |