Remote Systems
v6.4.1

com.ibm.etools.systems.core.archiveutils
Interface ISystemArchiveHandler

All Known Implementing Classes:
SystemTarHandler, SystemZipHandler

public interface ISystemArchiveHandler


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 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 typeRegistery)
          Compresses the file file and adds it to the archive, saving it in the encoding specified by encoding if the isText is true.
 boolean create()
          Turns the archive that this handler represents into a new, empty archive.
 boolean createFile(String fullVirtualName)
          Creates a new, empty file in the archive.
 boolean createFolder(String fullVirtualName)
          Creates a new, empty folder in the archive.
 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 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, 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.
 long getTimeStampFor(String fullVirtualName)
           
 VirtualChild[] getVirtualChildFolders(String fullVirtualName)
           
 VirtualChild[] getVirtualChildren(String fullVirtualName)
           
 VirtualChild[] getVirtualChildrenList()
           
 VirtualChild[] getVirtualChildrenList(String parent)
           
 VirtualChild getVirtualFile(String fullVirtualName)
           
 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.
 SystemSearchLineMatch[] search(String fullVirtualName, SystemSearchStringMatcher matcher)
          Searches for text within a virtual file in this archive.
 

Method Detail

create

public boolean create()
Turns the archive that this handler represents into a new, empty archive. (The archive could not exist before, in which case this would be a true creation).

Returns:
Whether or not the blank archive was successfuly created.

getVirtualChildrenList

public VirtualChild[] getVirtualChildrenList()
Returns:
an array containing all the entries in the archive file in a flat format, where the entries' filenames are prepended by the path to the entry within the virtual file system. If there are no entries in the file, returns an array of size 0.

getVirtualChildrenList

public VirtualChild[] getVirtualChildrenList(String parent)
Returns:
an array containing all the entries in the archive file in a flat format, whose full paths begin with the String parent. Returns an array of length 0 if there are no such entries.

getVirtualChildren

public VirtualChild[] getVirtualChildren(String fullVirtualName)
Returns:
an array containing the virtual children of the virtual directory named fullVirtualName. If fullVirtualName is "", returns the top level in the virtual file system tree. If there are no values to return, returns null.

getVirtualChildFolders

public VirtualChild[] getVirtualChildFolders(String fullVirtualName)
Returns:
an array containing the virtual children of the virtual directory named 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.

getVirtualFile

public VirtualChild getVirtualFile(String fullVirtualName)
Returns:
the virtual File or Folder referred to by 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.

exists

public boolean exists(String fullVirtualName)
Returns:
Whether or not the virtual file or folder named fullVirtualName exists in the archive (physically).

exists

public boolean exists()
Returns:
Whether or not the handler exists. Usually false if the archive is corrupted or unreadable.

getArchive

public File getArchive()
Returns:
the archive that this handler deals with

getTimeStampFor

public long getTimeStampFor(String fullVirtualName)
Returns:
the current timestamp (last modified) for the entry in the archive named fullVirtualName

getSizeFor

public long getSizeFor(String fullVirtualName)
Returns:
the current size (uncompressed) for the entry in the archive named fullVirtualName

extractVirtualFile

public boolean extractVirtualFile(String fullVirtualName,
                                  File destination)
Extracts the virtual file named fullVirtualName from the archive, placing the results in destination.

Parameters:
fullVirtualName - The full path and name of the virtual file in the archive.
destination - The destination file for the extracted virtual file.
Returns:
true iff the extraction is successful

extractVirtualFile

public boolean extractVirtualFile(String fullVirtualName,
                                  File destination,
                                  String sourceEncoding,
                                  boolean isText)
Extracts the virtual file named 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.

Parameters:
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.
Returns:
true iff the extraction is successful

extractVirtualDirectory

public boolean extractVirtualDirectory(String dir,
                                       File destinationParent)
Extracts the directory dir (and its children) from the archive and places the results in the directory destinationParent.

Parameters:
dir - The full name of the virtual directory to extract
destinationParent - A handle to the directory in which the extracted directory will be placed as a subdirectory.
Returns:
true iff the extraction is successful

extractVirtualDirectory

public 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. Extracts to the native encoding (if isText), but assumes that the source was archived using sourceEncoding.

Parameters:
dir - The full name of the virtual directory to extract
destinationParent - 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
Returns:
true iff the extraction is successful

extractVirtualDirectory

public 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. The results will be named destination.getName() rather than dir's name.

Parameters:
dir - The full name of the virtual directory to extract
destinationParent - 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.
Returns:
true iff the extraction is successful

extractVirtualDirectory

public 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. 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.

Parameters:
dir - The full name of the virtual directory to extract
destinationParent - 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
Returns:
true iff the extraction is successful

add

public 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. 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.

Returns:
true if and only if the add was successful

add

public 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. 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.

Returns:
true if and only if the add was successful

add

public boolean add(File file,
                   String virtualPath,
                   String name,
                   String encoding,
                   ISystemFileTypes typeRegistery)
Compresses the file 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.

Returns:
true if and only if the add was successful

add

public boolean add(File[] files,
                   String virtualPath,
                   String[] names)
A generalization of the add method. Compresses the array of files 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.

Returns:
true if and only if the add was successful

add

public boolean add(File[] files,
                   String virtualPath,
                   String[] names,
                   String[] encodings,
                   boolean[] isText)
A generalization of the add method. Compresses the array of files 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.

Returns:
true if and only if the add was successful

replace

public 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. Pass the name of the file as the parameter name.

Returns:
true if and only if the replace was successful

delete

public boolean delete(String fullVirtualName)
Deletes the entry fullVirtualName from the archive, and returns whether or not the deletion was successful.


rename

public 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. Returns true if and only if the rename was successfull.


move

public 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. Returns true if and only if the move was successfull.


fullRename

public boolean fullRename(String fullVirtualName,
                          String newFullVirtualName)
Replaces the full name and path of the entry fullVirtualName with the new full name and path newFullVirtualName. Returns true if and only if the operation was successfull.


getFiles

public File[] getFiles(String[] fullNames)
Extracts and returns the specified list of virtual files from the archive.

Parameters:
fullNames - The list of files to return
Returns:
An array of handles to the extracted files. If fullNames has length 0 then this method returns an array of length 0.

createFolder

public boolean createFolder(String fullVirtualName)
Creates a new, empty folder in the archive. If parent folders do not exist either, creates them.

Parameters:
fullVirtualName - The full name and path of the new folder within the virtual file system.
Returns:
Whether or not the creation was successful.

createFile

public boolean createFile(String fullVirtualName)
Creates a new, empty file in the archive. If parent folders do not exist either, creates them.

Parameters:
fullVirtualName - The full name and path of the new file within the virtual file system.
Returns:
Whether or not the creation was successful.

getStandardName

public String getStandardName(VirtualChild vc)
Gets the archive-type specific standard name for the VirtualChild vc. For example, for Zips, if vc is a directory, then the standard name must end with a "/".


search

public SystemSearchLineMatch[] search(String fullVirtualName,
                                      SystemSearchStringMatcher matcher)
Searches for text within a virtual file in this archive. A good implementation will not actually extract the file to disk.

Parameters:
fullVirtualName - the virtual file to search.
matcher - the pattern matcher to use.
Returns:
an array of match objects corresponding to lines where matches were found. Returns an empty array if there are no results.

getCommentFor

public String getCommentFor(String fullVirtualName)
Gets the user-defined comment for a specific entry in the archive.

Parameters:
fullVirtualName - The entry who's comment is desired
Returns:
the comment as a String or "" if there is none

getCompressedSizeFor

public long getCompressedSizeFor(String fullVirtualName)
Gets the amount of space taken up by a specific entry in the archive when it is in compressed form. Compare with getSizeFor(String) which gets the size of the entry after it is decompressed.

Parameters:
fullVirtualName - The entry who's compressed size is desired
Returns:
the compressed size of the specified entry, or 0 if the entry is not found. If the archive is not a compression type (ie. tar), return the same as getSizeFor(String).

getCompressionMethodFor

public String getCompressionMethodFor(String fullVirtualName)
Gets the method used to compress a specific entry in the archive.

Parameters:
fullVirtualName - The entry who's compression method is desired
Returns:
The compression method of the specified entry, or "" if none.

getArchiveComment

public String getArchiveComment()
Returns:
The comment associated with this archive, or "" if there is none.

getClassification

public String getClassification(String fullVirtualName)
Returns the classification for the entry with the given path.

Parameters:
fullVirtualName - the virtual name.
Returns:
the classification.

Remote Systems
v6.4.1

Copyright © 2005 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.