|
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.SystemTarHandler
This class deals with tar files.
Field Summary | |
---|---|
protected File |
file
|
protected long |
modTimeDuringCache
|
protected com.ibm.etools.systems.core.archiveutils.SystemTarHandler.VirtualFileSystem |
vfs
|
Constructor Summary | |
---|---|
SystemTarHandler(File file)
Constructor for handler. |
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[] isTexts)
A generalization of the add method. |
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 TarEntry |
appendEmptyFile(TarOutputStream outStream,
String name)
Creates a new tar entry and appends it to the tar output stream with the given name. |
protected void |
appendFile(File file,
TarEntry entry,
TarOutputStream outStream)
Appends a file to a tar output stream, using the given entry that represents the file. |
protected TarEntry |
changeTarEntry(TarEntry entry,
File file,
String virtualPath)
Changes a tar entry according to the file information and given path. |
protected TarEntry |
changeTarEntryName(TarEntry entry,
String newName)
Changes the name of a tar entry. |
boolean |
create()
Turns the archive that this handler represents into a new, empty archive. |
protected void |
createCache()
Reads the contents of the tar file, and caches the entries. |
boolean |
createFile(String fullVirtualName)
Creates a new, empty file in the archive. |
boolean |
createFolder(String fullVirtualName)
Creates a new, empty folder in the archive. |
protected void |
createTar(VirtualChild[] children,
TarOutputStream outStream,
HashMap renameMap)
Creates a tar file from the given virtual child objects, using the given output stream and renaming entries according to hash map entries. |
protected void |
createTar(VirtualChild[] children,
TarOutputStream outStream,
HashSet omitChildren)
Create a tar file from the given virtual child objects, using the given output stream and omitting the children in the given set. |
protected TarEntry |
createTarEntry(File file,
String virtualPath)
Creates a tar entry for a file with the given virtual path. |
protected boolean |
createVirtualObject(String name)
Creates a virtual object that does not already exist in the virtual file system. |
boolean |
delete(String fullVirtualName)
Deletes the entry fullVirtualName from the archive, and returns
whether or not the deletion was successful. |
boolean |
exists()
|
boolean |
exists(String fullVirtualName)
|
boolean |
extractVirtualDirectory(String fullVirtualName,
File destinationParent)
Extracts the directory dir (and its children) from
the archive and places the results in the directory destinationParent . |
boolean |
extractVirtualDirectory(String fullVirtualName,
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,
String sourceEncoding,
boolean isText)
Extracts the virtual file named fullVirtualName from the archive,
placing the results in destination . |
boolean |
fullRename(String fullVirtualName,
String newFullVirtualName)
Replaces the full name and path of the entry fullVirtualName
with the new full name and path newFullVirtualName .
|
File |
getArchive()
|
String |
getArchiveComment()
|
String |
getClassification(String fullVirtualName)
Returns the classification for the entry with the given path. |
String |
getCommentFor(String fullVirtualName)
Gets the user-defined comment for a specific entry in the archive. |
long |
getCompressedSizeFor(String fullVirtualName)
Gets the amount of space taken up by a specific entry in the archive when it is in compressed form. |
String |
getCompressionMethodFor(String fullVirtualName)
Gets the method used to compress a specific entry in the archive. |
File[] |
getFiles(String[] fullNames)
Extracts and returns the specified list of virtual files from the archive. |
long |
getSizeFor(String fullVirtualName)
|
String |
getStandardName(VirtualChild vc)
Gets the archive-type specific standard name for the VirtualChild vc . |
protected TarFile |
getTarFile()
Gets a tar file from the underlying file. |
long |
getTimeStampFor(String fullVirtualName)
|
protected VirtualChild |
getVirtualChild(TarEntry entry)
Returns a virtual child given a tar entry. |
VirtualChild[] |
getVirtualChildFolders(String fullVirtualName)
|
VirtualChild[] |
getVirtualChildren(String fullVirtualName)
|
VirtualChild[] |
getVirtualChildrenList()
|
VirtualChild[] |
getVirtualChildrenList(String parent)
|
VirtualChild |
getVirtualFile(String fullVirtualName)
|
protected void |
init(File file)
Initializes the handler from the given file and does caching. |
void |
listAllFiles(File parent,
Vector 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. |
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.
|
protected void |
replaceFile(File newFile,
boolean updateCache)
Replaces the old tar file managed by the handler with the given file, and optionally update the cache. |
SystemSearchLineMatch[] |
search(String fullVirtualName,
SystemSearchStringMatcher matcher)
Searches for text within a virtual file in this archive. |
protected void |
updateCache()
Updates the cache if the tar file has changed since the last time we cached. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected File file
protected long modTimeDuringCache
protected com.ibm.etools.systems.core.archiveutils.SystemTarHandler.VirtualFileSystem vfs
Constructor Detail |
public SystemTarHandler(File file) throws IOException
init
.
file
- the tar file.Method Detail |
protected void init(File file) throws IOException
file
-
IOException
protected void createCache()
protected TarFile getTarFile()
null
if the tar file does not exist.protected void updateCache() throws IOException
IOException
public VirtualChild[] getVirtualChildrenList()
getVirtualChildrenList
in interface ISystemArchiveHandler
ISystemArchiveHandler.getVirtualChildrenList()
public VirtualChild[] getVirtualChildrenList(String parent)
getVirtualChildrenList
in interface ISystemArchiveHandler
parent
.
Returns an array of length 0 if there are no such entries.ISystemArchiveHandler.getVirtualChildrenList(java.lang.String)
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.ISystemArchiveHandler.getVirtualChildren(java.lang.String)
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.ISystemArchiveHandler.getVirtualChildFolders(java.lang.String)
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.ISystemArchiveHandler.getVirtualFile(java.lang.String)
public boolean exists(String fullVirtualName)
exists
in interface ISystemArchiveHandler
fullVirtualName
exists in the archive (physically).ISystemArchiveHandler.exists(java.lang.String)
public File getArchive()
getArchive
in interface ISystemArchiveHandler
ISystemArchiveHandler.getArchive()
public long getTimeStampFor(String fullVirtualName)
getTimeStampFor
in interface ISystemArchiveHandler
fullVirtualName
ISystemArchiveHandler.getTimeStampFor(java.lang.String)
public long getSizeFor(String fullVirtualName)
getSizeFor
in interface ISystemArchiveHandler
fullVirtualName
ISystemArchiveHandler.getSizeFor(java.lang.String)
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 extractVirtualDirectory(String fullVirtualName, File destinationParent)
ISystemArchiveHandler
dir
(and its children) from
the archive and places the results in the directory destinationParent
.
extractVirtualDirectory
in interface ISystemArchiveHandler
fullVirtualName
- 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.
ISystemArchiveHandler.extractVirtualDirectory(java.lang.String, java.io.File)
public boolean extractVirtualDirectory(String fullVirtualName, 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
fullVirtualName
- 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.
ISystemArchiveHandler.extractVirtualDirectory(java.lang.String, java.io.File, java.io.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
ISystemArchiveHandler.add(java.io.File, java.lang.String, java.lang.String)
public void listAllFiles(File parent, Vector found)
found
with a
collapsed list of all nodes in the subtree
of the file system rooted at parent
.
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
ISystemArchiveHandler.add(java.io.File[], java.lang.String, java.lang.String[])
protected void createTar(VirtualChild[] children, TarOutputStream outStream, HashSet omitChildren) throws IOException
children
- an array of virtual children from which to create a tar file.outStream
- the tar output stream to use.omitChildren
- the set of names for children that should be omitted from the given array of virtual children.
IOException
- if an I/O exception occurs.protected void appendFile(File file, TarEntry entry, TarOutputStream outStream) throws IOException
file
- the file to be appended to the tar output stream.entry
- the entry which represents the file.outStream
- the tar output stream.
IOException
- if an I/O error occurs.protected TarEntry createTarEntry(File file, String virtualPath)
file
- the file for which to create a tar entry.
protected TarEntry changeTarEntry(TarEntry entry, File file, String virtualPath)
entry
- the entry that needs to be changed.file
- the file for which the tar entry is being changed.virtualPath
- the virtual path for the entry.
protected VirtualChild getVirtualChild(TarEntry entry)
entry
- a tar entry.
protected void replaceFile(File newFile, boolean updateCache) throws IOException
newFile
- the new tar file.updateCache
- true
to update the cache, false
otherwise.
Only specify false
if the cache has already been updated to reflect the
contents of this new file.
IOException
- if an I/O problem occurs.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
ISystemArchiveHandler.replace(java.lang.String, java.io.File, java.lang.String)
public boolean delete(String fullVirtualName)
ISystemArchiveHandler
fullVirtualName
from the archive, and returns
whether or not the deletion was successful.
delete
in interface ISystemArchiveHandler
ISystemArchiveHandler.delete(java.lang.String)
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
ISystemArchiveHandler.rename(java.lang.String, java.lang.String)
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
ISystemArchiveHandler.move(java.lang.String, java.lang.String)
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
ISystemArchiveHandler.fullRename(java.lang.String, java.lang.String)
protected void createTar(VirtualChild[] children, TarOutputStream outStream, HashMap renameMap) throws IOException
children
- an array of virtual children from which to create a tar file.outStream
- the tar output stream to use.renameMap
- a map containing associations between old names and new names. Old names are the keys
in the map, and the values are the new names.
IOException
- if an I/O exception occurs.protected TarEntry changeTarEntryName(TarEntry entry, String newName)
entry
- the entry for which the name has to be changed.newName
- the new name for the entry.
public File[] getFiles(String[] fullNames)
ISystemArchiveHandler
getFiles
in interface ISystemArchiveHandler
fullNames
- The list of files to return
ISystemArchiveHandler.getFiles(java.lang.String[])
public boolean createFolder(String fullVirtualName)
ISystemArchiveHandler
createFolder
in interface ISystemArchiveHandler
fullVirtualName
- The full name and path of the new folder within the virtual file system.
ISystemArchiveHandler.createFolder(java.lang.String)
public boolean createFile(String fullVirtualName)
ISystemArchiveHandler
createFile
in interface ISystemArchiveHandler
fullVirtualName
- The full name and path of the new file within the virtual file system.
ISystemArchiveHandler.createFile(java.lang.String)
protected boolean createVirtualObject(String name)
name
- the name of the virtual object.
true
if the object was created successfully, false
otherwise.protected TarEntry appendEmptyFile(TarOutputStream outStream, String name) throws IOException
outStream
- the tar output stream.name
- the name of the new tar entry.
IOException
- if an I/O error occurs.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
ISystemArchiveHandler.getStandardName(com.ibm.etools.systems.core.archiveutils.VirtualChild)
public boolean create()
ISystemArchiveHandler
create
in interface ISystemArchiveHandler
ISystemArchiveHandler.create()
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 long getCompressedSizeFor(String fullVirtualName)
ISystemArchiveHandler
getCompressedSizeFor
in interface ISystemArchiveHandler
fullVirtualName
- The entry who's compressed size is desired
public String getCompressionMethodFor(String fullVirtualName)
ISystemArchiveHandler
getCompressionMethodFor
in interface ISystemArchiveHandler
fullVirtualName
- The entry who's compression method is desired
public String getArchiveComment()
getArchiveComment
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, String[] encodings, boolean[] isTexts)
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 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
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 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 String getClassification(String fullVirtualName)
ISystemArchiveHandler
getClassification
in interface ISystemArchiveHandler
fullVirtualName
- the virtual name.
ISystemArchiveHandler.getClassification(java.lang.String)
|
Remote Systems v6.4.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |