Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

RSE
Release 3.0

org.eclipse.rse.services.clientserver.archiveutils
Class SystemTarHandler


java.lang.Object
  extended by 
org.eclipse.rse.services.clientserver.archiveutils.SystemTarHandler
All Implemented Interfaces:
ISystemArchiveHandler
Direct Known Subclasses:
SystemTgzHandler

public class SystemTarHandler
extends Object
implements ISystemArchiveHandler

This class deals with tar files.


Field Summary
protected   SystemReentrantMutex _mutex
           
protected   File file
           
protected  long modTimeDuringCache
           
protected  org.eclipse.rse.services.clientserver.archiveutils.SystemTarHandler.VirtualFileSystem vfs
           
 
Constructor Summary
SystemTarHandler ( File file)
          Constructor for handler.
 
Method Summary
 void add ( File[] files, String virtualPath, String[] names, ISystemOperationMonitor archiveOperationMonitor)
          A generalization of the add method.
 void add ( File[] files, String virtualPath, String[] names, String[] sourceEncodings, String[] targetEncodings, boolean[] isTexts, ISystemOperationMonitor archiveOperationMonitor)
          A generalization of the add method.
 void add ( File file, String virtualPath, String name, ISystemOperationMonitor archiveOperationMonitor)
          Compresses the file file and adds it to the archive, placing it in the virtual directory virtualPath.
 void add ( File file, String virtualPath, String name, String encoding, ISystemFileTypes registry, ISystemOperationMonitor archiveOperationMonitor)
          Compresses the file file and adds it to the archive, saving it in the encoding specified by encoding if saving in text mode.
 void add ( File file, String virtualPath, String name, String sourceEncoding, String targetEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor)
          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.
 void add ( File file, String virtualPath, String name, String sourceEncoding, String targetEncoding, ISystemFileTypes typeRegistery, ISystemOperationMonitor archiveOperationMonitor)
          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.
 void add ( InputStream stream, String virtualPath, String name, String sourceEncoding, String targetEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor)
          Compresses the bytes in the InputStream stream and adds them as an entry to the archive, saving them in the encoding specified by encoding if isText is true, and placing it in the virtual directory virtualPath.
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.
 void 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.
 void createFile ( String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor)
          Creates a new, empty file in the archive.
 void createFolder ( String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor)
          Creates a new, empty folder in the archive.
protected  boolean createTar ( VirtualChild[] children, TarOutputStream outStream, HashMap renameMap, ISystemOperationMonitor archiveOperationMonitor)
          Creates a tar file from the given virtual child objects, using the given output stream and renaming entries according to hash map entries.
protected  boolean createTar ( VirtualChild[] children, TarOutputStream outStream, HashSet omitChildren, ISystemOperationMonitor archiveOperationMonitor)
          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, ISystemOperationMonitor archiveOperationMonitor)
          Creates a virtual object that does not already exist in the virtual file system.
 boolean delete ( String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor)
          Deletes the entry fullVirtualName from the archive, and returns whether or not the deletion was successful.
protected  boolean doDelete ( String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor)
          Delete a virtual object.
 boolean exists ()
          Check if the archive handler implementation associated with this class exists.
 boolean exists ( String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor)
          Check whether a given virtual node exists in an archive.
 void extractVirtualDirectory ( String fullVirtualName, File destinationParent, File destination, ISystemOperationMonitor archiveOperationMonitor)
          Extracts the directory dir (and its children) from the archive and places the results in the directory destinationParent.
 void extractVirtualDirectory ( String dir, File destinationParent, File destination, String sourceEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor)
          Extracts the directory dir (and its children) from the archive and places the results in the directory destinationParent.
 void extractVirtualDirectory ( String fullVirtualName, File destinationParent, ISystemOperationMonitor archiveOperationMonitor)
          Extracts the directory dir (and its children) from the archive and places the results in the directory destinationParent.
 void extractVirtualDirectory ( String dir, File destinationParent, String sourceEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor)
          Extracts the directory dir (and its children) from the archive and places the results in the directory destinationParent.
 void extractVirtualFile ( String fullVirtualName, File destination, ISystemOperationMonitor archiveOperationMonitor)
          Extracts the virtual file named fullVirtualName from the archive, placing the results in destination.
 void extractVirtualFile ( String fullVirtualName, File destination, String sourceEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor)
          Extracts the virtual file named fullVirtualName from the archive, placing the results in destination.
 void fullRename ( String fullVirtualName, String newFullVirtualName, ISystemOperationMonitor archiveOperationMonitor)
          Replaces the full name and path of the entry fullVirtualName with the new full name and path newFullVirtualName.
  File getArchive ()
          Return the archive that this handler deals with.
  String getArchiveComment ()
          Get the comment associated with an archive.
  String getClassification ( String fullVirtualName)
          Get the classification for the entry with the given path.
  String getCommentFor ( String fullVirtualName)
          Get the user-defined comment for a specific entry in the archive.
 long getCompressedSizeFor ( String fullVirtualName)
          Get the amount of space taken up by a specific entry in the archive when it is in compressed form.
  String getCompressionMethodFor ( String fullVirtualName)
          Get the method used to compress a specific entry in the archive.
  File[] getFiles ( String[] fullNames, ISystemOperationMonitor archiveOperationMonitor)
          Extracts and returns the specified list of virtual files from the archive.
 long getSizeFor ( String fullVirtualName)
          Return the size for an archive node.
  String getStandardName ( VirtualChild vc)
          Get the archive-type specific standard name for the VirtualChild vc.
protected   TarFile getTarFile ()
          Gets a tar file from the underlying file.
protected   TarOutputStream getTarOutputStream ( File outputFile)
          Get the tar output stream for a given file.
 long getTimeStampFor ( String fullVirtualName)
          Return the timestamp for an archive node.
protected   VirtualChild getVirtualChild ( TarEntry entry)
          Returns a virtual child given a tar entry.
  VirtualChild[] getVirtualChildFolders ( String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor)
          Return those children of a specified node in an archive, which are folders.
  VirtualChild[] getVirtualChildren ( String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor)
          Return the children of a specified node in an archive.
  VirtualChild[] getVirtualChildrenList ( ISystemOperationMonitor archiveOperationMonitor)
          Return a flat list of entries in an archive.
  VirtualChild[] getVirtualChildrenList ( String parent, ISystemOperationMonitor archiveOperationMonitor)
          Return a flat list of entries in an archive, whose full paths begin with the given parent prefix.
  VirtualChild getVirtualFile ( String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor)
          Return an archive node specified by a given virtual path.
protected  void init ( File file)
          Initializes the handler from the given file and does caching.
 void listAllFiles ( File parent, List found)
          Helper method.
 void move ( String fullVirtualName, String destinationVirtualPath, ISystemOperationMonitor archiveOperationMonitor)
          Moves the entry fullVirtualName to the location specified by destinationVirtualPath, while leaving the entry with the same name as before.
 void rename ( String fullVirtualName, String newName, ISystemOperationMonitor archiveOperationMonitor)
          Renames the entry fullVirtualName to the new name newName while still leaving the entry in the same virtual directory.
 void replace ( String fullVirtualName, File file, String name, ISystemOperationMonitor archiveOperationMonitor)
          Compress the file file and replace the virtual file referred to by fullVirtualName with the compressed file.
 void replace ( String fullVirtualName, InputStream stream, String name, String sourceEncoding, String targetEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor)
          Compress the InputStream stream and replace the virtual file referred to by fullVirtualName with the compressed stream.
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, ISystemOperationMonitor archiveOperationMonitor)
          Search 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.
protected  void updateTree ( HashMap newOldNames)
          Update the virtual file system tree.
protected   VirtualChild updateVirtualChild ( TarEntry entry, VirtualChild child)
          update a virtual child given a tar entry.
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file

protected 
File file

modTimeDuringCache

protected long modTimeDuringCache

vfs

protected org.eclipse.rse.services.clientserver.archiveutils.SystemTarHandler.VirtualFileSystem vfs

_mutex

protected 
SystemReentrantMutex _mutex
Since:
3.0
Constructor Detail

SystemTarHandler

public SystemTarHandler(
File file)
                 throws 
IOException
Constructor for handler. Calls init.

Parameters:
file - the tar file.
Throws:
IOException
Method Detail

init

protected void init(
File file)
             throws 
IOException
Initializes the handler from the given file and does caching.

Parameters:
file - the file to handle
Throws:
IOException - in case of error during initialization (can be thrown by overriding methods)

createCache

protected void createCache()
Reads the contents of the tar file, and caches the entries.


updateTree

protected void updateTree(
HashMap newOldNames)
Update the virtual file system tree. If newOldName HashMap is input, use the old name in the HashMap to do the search in virtual file system tree.

Since:
3.0

getTarFile

protected 
TarFile getTarFile()
Gets a tar file from the underlying file.

Returns:
the tar file, or null if the tar file does not exist.
Since:
3.0 TarFile moved to API

updateCache

protected void updateCache()
                    throws 
IOException
Updates the cache if the tar file has changed since the last time we cached. Will not change the cache if the tar file hasn't been updated. Other methods should call this method before performing any operations on the cache and the underlying tar file.

Throws:
IOException

getVirtualChildrenList

public 
VirtualChild[] getVirtualChildrenList(
ISystemOperationMonitor archiveOperationMonitor)
Return a flat list of entries in an archive.

Specified by:
getVirtualChildrenList in interface ISystemArchiveHandler
Parameters:
archiveOperationMonitor - the operation progress monitor
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.
Since:
3.0

getVirtualChildrenList

public 
VirtualChild[] getVirtualChildrenList(
String parent,
                                             
ISystemOperationMonitor archiveOperationMonitor)
Return a flat list of entries in an archive, whose full paths begin with the given parent prefix.

Specified by:
getVirtualChildrenList in interface ISystemArchiveHandler
Parameters:
parent - full path of the parent
archiveOperationMonitor - the operation progress monitor
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.
Since:
3.0

getVirtualChildren

public 
VirtualChild[] getVirtualChildren(
String fullVirtualName,
                                         
ISystemOperationMonitor archiveOperationMonitor)
Return the children of a specified node in an archive.

Specified by:
getVirtualChildren in interface ISystemArchiveHandler
Parameters:
fullVirtualName - full virtual path of the parent
archiveOperationMonitor - the operation progress monitor
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.
Since:
3.0

getVirtualChildFolders

public 
VirtualChild[] getVirtualChildFolders(
String fullVirtualName,
                                             
ISystemOperationMonitor archiveOperationMonitor)
Return those children of a specified node in an archive, which are folders.

Specified by:
getVirtualChildFolders in interface ISystemArchiveHandler
Parameters:
fullVirtualName - full virtual path of the parent
archiveOperationMonitor - the operation progress monitor
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.
Since:
3.0

getVirtualFile

public 
VirtualChild getVirtualFile(
String fullVirtualName,
                                   
ISystemOperationMonitor archiveOperationMonitor)
Return an archive node specified by a given virtual path.

Specified by:
getVirtualFile in interface ISystemArchiveHandler
Parameters:
fullVirtualName - full virtual path of the object to retrieve
archiveOperationMonitor - the operation progress monitor
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.
Since:
3.0

exists

public boolean exists(
String fullVirtualName,
                      
ISystemOperationMonitor archiveOperationMonitor)
Check whether a given virtual node exists in an archive.

Specified by:
exists in interface ISystemArchiveHandler
Parameters:
fullVirtualName - full virtual path of the object
archiveOperationMonitor - the operation progress monitor
Returns:
Whether or not the virtual file or folder named fullVirtualName exists in the archive (physically).
Since:
3.0

getArchive

public 
File getArchive()
Description copied from interface: ISystemArchiveHandler
Return the archive that this handler deals with.

Specified by:
getArchive in interface ISystemArchiveHandler
Returns:
the archive that this handler deals with
See Also:
ISystemArchiveHandler.getArchive()

getTimeStampFor

public long getTimeStampFor(
String fullVirtualName)
Description copied from interface: ISystemArchiveHandler
Return the timestamp for an archive node.

Specified by:
getTimeStampFor in interface ISystemArchiveHandler
Parameters:
fullVirtualName - virtual path specifying the node to check
Returns:
the current timestamp (last modified) for the archive entry named fullVirtualName

getSizeFor

public long getSizeFor(
String fullVirtualName)
Description copied from interface: ISystemArchiveHandler
Return the size for an archive node.

Specified by:
getSizeFor in interface ISystemArchiveHandler
Parameters:
fullVirtualName - virtual path specifying the node to check
Returns:
the current size (uncompressed) for the entry in the archive named fullVirtualName

extractVirtualFile

public void extractVirtualFile(
String fullVirtualName,
                               
File destination,
                               
ISystemOperationMonitor archiveOperationMonitor)
                        throws 
SystemMessageException
Extracts the virtual file named fullVirtualName from the archive, placing the results in destination.

Specified by:
extractVirtualFile in interface ISystemArchiveHandler
Parameters:
fullVirtualName - The full path and name of the virtual file in the archive.
destination - The destination file for the extracted virtual file.
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

extractVirtualDirectory

public void extractVirtualDirectory(
String fullVirtualName,
                                    
File destinationParent,
                                    
ISystemOperationMonitor archiveOperationMonitor)
                             throws 
SystemMessageException
Extracts the directory dir (and its children) from the archive and places the results in the directory destinationParent.

Specified by:
extractVirtualDirectory in interface ISystemArchiveHandler
Parameters:
fullVirtualName - 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.
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

extractVirtualDirectory

public void extractVirtualDirectory(
String fullVirtualName,
                                    
File destinationParent,
                                    
File destination,
                                    
ISystemOperationMonitor archiveOperationMonitor)
                             throws 
SystemMessageException
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.

Specified by:
extractVirtualDirectory in interface ISystemArchiveHandler
Parameters:
fullVirtualName - 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.
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

add

public void add(
File file,
                
String virtualPath,
                
String name,
                
ISystemOperationMonitor archiveOperationMonitor)
         throws 
SystemMessageException
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.

Specified by:
add in interface ISystemArchiveHandler
Parameters:
file - the file to be added to the archive
virtualPath - the destination of the file
name - the name of the result virtual file
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

listAllFiles

public void listAllFiles(
File parent,
                         
List found)
Helper method. Populates given List found with a collapsed list of all nodes in the subtree of the file system rooted at parent.

Since:
3.0 Vector changed into List

add

public void add(
File[] files,
                
String virtualPath,
                
String[] names,
                
ISystemOperationMonitor archiveOperationMonitor)
         throws 
SystemMessageException
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.

Specified by:
add in interface ISystemArchiveHandler
Parameters:
files - the list of files to be added to the archive
virtualPath - the destination of the file
names - the names of the result virtual files
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

createTar

protected boolean createTar(
VirtualChild[] children,
                            
TarOutputStream outStream,
                            
HashSet omitChildren,
                            
ISystemOperationMonitor archiveOperationMonitor)
                     throws 
IOException
Create a tar file from the given virtual child objects, using the given output stream and omitting the children in the given set.

Parameters:
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.
archiveOperationMonitor - the operation progress monitor
Returns:
true if the operation completes successfully, or false if it has been cancelled.
Throws:
IOException - if an I/O exception occurs.
Since:
org.eclipse.rse.services 3.0

appendFile

protected void appendFile(
File file,
                          
TarEntry entry,
                          
TarOutputStream outStream)
                   throws 
IOException
Appends a file to a tar output stream, using the given entry that represents the file.

Parameters:
file - the file to be appended to the tar output stream.
entry - the entry which represents the file.
outStream - the tar output stream.
Throws:
IOException - if an I/O error occurs.
Since:
3.0 TarEntry moved into API

createTarEntry

protected 
TarEntry createTarEntry(
File file,
                                  
String virtualPath)
Creates a tar entry for a file with the given virtual path. The entry will contain the size and last modified time of the file. The entry's checksum will be calculated.

Parameters:
file - the file for which to create a tar entry.
virtualPath - the virtual path for the entry.
Returns:
the tar entry representing the given file.
Since:
3.0 TarEntry moved into API

changeTarEntry

protected 
TarEntry changeTarEntry(
TarEntry entry,
                                  
File file,
                                  
String virtualPath)
Changes a tar entry according to the file information and given path. The given path will be the new name of the entry. The size and last modified fields will be changed to the file's size and last modified time. The entry's checksum will be calculated.

Parameters:
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.
Returns:
the changed entry.
Since:
3.0 TarEntry moved into API

getVirtualChild

protected 
VirtualChild getVirtualChild(
TarEntry entry)
Returns a virtual child given a tar entry.

Parameters:
entry - a tar entry.
Returns:
the virtual child that represents the tar entry.
Since:
3.0 TarEntry moved into API

updateVirtualChild

protected 
VirtualChild updateVirtualChild(
TarEntry entry,
                                          
VirtualChild child)
update a virtual child given a tar entry.

Parameters:
entry - a tar entry.
Returns:
the virtual child that represents the tar entry.
Since:
3.0 TarEntry moved into API

replaceFile

protected void replaceFile(
File newFile,
                           boolean updateCache)
                    throws 
IOException
Replaces the old tar file managed by the handler with the given file, and optionally update the cache.

Parameters:
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.
Throws:
IOException - if an I/O problem occurs.

replace

public void replace(
String fullVirtualName,
                    
File file,
                    
String name,
                    
ISystemOperationMonitor archiveOperationMonitor)
             throws 
SystemMessageException
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.

Specified by:
replace in interface ISystemArchiveHandler
Parameters:
fullVirtualName - the path of the file to be replaced
file - the file to be added to the archive
name - the name of the file
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

delete

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

Specified by:
delete in interface ISystemArchiveHandler
Parameters:
fullVirtualName - the path of the file to be deleted
archiveOperationMonitor - the operation progress monitor
Returns:
true if the deletion is successful, false if the file to delete was not found so this was a successful no-op.
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

doDelete

protected boolean doDelete(
String fullVirtualName,
                           
ISystemOperationMonitor archiveOperationMonitor)
                    throws 
SystemMessageException
Delete a virtual object.

Parameters:
fullVirtualName - virtual path identifying the object
archiveOperationMonitor - the operation progress monitor
Returns:
true if successful, false if the entry to delete did not exist (so this was a successful no-op).
Throws:
SystemMessageException - in case of an error
Since:
org.eclipse.rse.services 3.0

rename

public void rename(
String fullVirtualName,
                   
String newName,
                   
ISystemOperationMonitor archiveOperationMonitor)
            throws 
SystemMessageException
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 successful.

Specified by:
rename in interface ISystemArchiveHandler
Parameters:
fullVirtualName - the path of the file to be renamed
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

move

public void move(
String fullVirtualName,
                 
String destinationVirtualPath,
                 
ISystemOperationMonitor archiveOperationMonitor)
          throws 
SystemMessageException
Moves the entry fullVirtualName to the location specified by destinationVirtualPath, while leaving the entry with the same name as before.

Specified by:
move in interface ISystemArchiveHandler
Parameters:
fullVirtualName - the path of the file to be renamed
destinationVirtualPath - the destination of the file to move to
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

fullRename

public void fullRename(
String fullVirtualName,
                       
String newFullVirtualName,
                       
ISystemOperationMonitor archiveOperationMonitor)
                throws 
SystemMessageException
Replaces the full name and path of the entry fullVirtualName with the new full name and path newFullVirtualName.

Specified by:
fullRename in interface ISystemArchiveHandler
Parameters:
fullVirtualName - the path of the file to be renamed
newFullVirtualName - the full path of the virtual file name
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

createTar

protected boolean createTar(
VirtualChild[] children,
                            
TarOutputStream outStream,
                            
HashMap renameMap,
                            
ISystemOperationMonitor archiveOperationMonitor)
                     throws 
IOException
Creates a tar file from the given virtual child objects, using the given output stream and renaming entries according to hash map entries.

Parameters:
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.
archiveOperationMonitor - the operation progress monitor
Returns:
true if the operation completes successfully, or false if it is cancelled by the user.
Throws:
IOException - if an I/O exception occurs.
Since:
org.eclipse.rse.services 3.0

changeTarEntryName

protected 
TarEntry changeTarEntryName(
TarEntry entry,
                                      
String newName)
Changes the name of a tar entry. Also calculates the new checksum for the entry.

Parameters:
entry - the entry for which the name has to be changed.
newName - the new name for the entry.
Returns:
the changed entry.
Since:
3.0 TarEntry moved into API

getFiles

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

Specified by:
getFiles in interface ISystemArchiveHandler
Parameters:
fullNames - The list of files to return
archiveOperationMonitor - the operation progress monitor
Returns:
An array of handles to the extracted files. If fullNames has length 0 then this method returns an array of length 0.
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

createFolder

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

Specified by:
createFolder in interface ISystemArchiveHandler
Parameters:
fullVirtualName - The full name and path of the new folder within the virtual file system.
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

createFile

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

Specified by:
createFile in interface ISystemArchiveHandler
Parameters:
fullVirtualName - The full name and path of the new file within the virtual file system.
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

createVirtualObject

protected boolean createVirtualObject(
String name,
                                      
ISystemOperationMonitor archiveOperationMonitor)
                               throws 
SystemMessageException
Creates a virtual object that does not already exist in the virtual file system. Creates an empty file in the tar file.

Parameters:
name - the name of the virtual object.
archiveOperationMonitor - the operation progress monitor
Returns:
true if the object was created successfully, false if the object already exists such that this is a successful no-op, or if the operation is cancelled by the user.
Throws:
SystemMessageException - in case of an error.
Since:
org.eclipse.rse.services 3.0

appendEmptyFile

protected 
TarEntry appendEmptyFile(
TarOutputStream outStream,
                                   
String name)
                            throws 
IOException
Creates a new tar entry and appends it to the tar output stream with the given name.

Parameters:
outStream - the tar output stream.
name - the name of the new tar entry.
Returns:
the newly created tar entry.
Throws:
IOException - if an I/O error occurs.
Since:
3.0 TarEntry moved into API

getStandardName

public 
String getStandardName(
VirtualChild vc)
Description copied from interface: ISystemArchiveHandler
Get the archive-type specific standard name for the VirtualChild vc. For example, for Zip archives, if vc is a directory, then the standard name must end with a "/".

Specified by:
getStandardName in interface ISystemArchiveHandler
Parameters:
vc - the archive node to use
Returns:
the standard name for the node

create

public void create()
            throws 
SystemMessageException
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).

Specified by:
create in interface ISystemArchiveHandler
Throws:
SystemMessageException - in case of an error
Since:
3.0

search

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

Specified by:
search in interface ISystemArchiveHandler
Parameters:
fullVirtualName - the virtual file to search.
matcher - the pattern matcher to use.
archiveOperationMonitor - the operation progress monitor
Returns:
an array of match objects corresponding to lines where matches were found. Returns an empty array if there are no results.
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

exists

public boolean exists()
Description copied from interface: ISystemArchiveHandler
Check if the archive handler implementation associated with this class exists.

Specified by:
exists in interface ISystemArchiveHandler
Returns:
Whether or not the handler exists. Usually false if the archive is corrupted or unreadable.

getCommentFor

public 
String getCommentFor(
String fullVirtualName)
Description copied from interface: ISystemArchiveHandler
Get the user-defined comment for a specific entry in the archive.

Specified by:
getCommentFor in interface ISystemArchiveHandler
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)
Description copied from interface: ISystemArchiveHandler
Get 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.

Specified by:
getCompressedSizeFor in interface ISystemArchiveHandler
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)
Description copied from interface: ISystemArchiveHandler
Get the method used to compress a specific entry in the archive.

Specified by:
getCompressionMethodFor in interface ISystemArchiveHandler
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()
Description copied from interface: ISystemArchiveHandler
Get the comment associated with an archive.

Specified by:
getArchiveComment in interface ISystemArchiveHandler
Returns:
The comment associated with this archive, or "" if there is none.

add

public void add(
File file,
                
String virtualPath,
                
String name,
                
String encoding,
                
ISystemFileTypes registry,
                
ISystemOperationMonitor archiveOperationMonitor)
         throws 
SystemMessageException
Compresses the file file and adds it to the archive, saving it in the encoding specified by encoding if saving in text mode. Places the file 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.

Parameters:
file - the file to be added to the archive
virtualPath - the destination of the file
name - the name of the result virtual file
encoding - the file encoding to use
registry - the file type to use (text or binary)
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error
Since:
org.eclipse.rse.services 3.0

add

public void add(
File file,
                
String virtualPath,
                
String name,
                
String sourceEncoding,
                
String targetEncoding,
                boolean isText,
                
ISystemOperationMonitor archiveOperationMonitor)
         throws 
SystemMessageException
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.

Specified by:
add in interface ISystemArchiveHandler
Parameters:
file - the file to be added to the archive
virtualPath - the destination of the file
name - the name of the result virtual file
sourceEncoding - the encoding of the source file
targetEncoding - the encoding of the result file
isText - is the file a text file
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

add

public void add(
File[] files,
                
String virtualPath,
                
String[] names,
                
String[] sourceEncodings,
                
String[] targetEncodings,
                boolean[] isTexts,
                
ISystemOperationMonitor archiveOperationMonitor)
         throws 
SystemMessageException
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.

Specified by:
add in interface ISystemArchiveHandler
Parameters:
files - the list of files to be added to the archive
virtualPath - the destination of the files
names - the names of the result virtual files
sourceEncodings - the encoding of the source files
targetEncodings - the encoding of the result files
isTexts - file transfer mode (binary or text) of the files
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

extractVirtualDirectory

public void extractVirtualDirectory(
String dir,
                                    
File destinationParent,
                                    
File destination,
                                    
String sourceEncoding,
                                    boolean isText,
                                    
ISystemOperationMonitor archiveOperationMonitor)
                             throws 
SystemMessageException
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.

Specified by:
extractVirtualDirectory in interface ISystemArchiveHandler
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
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

extractVirtualDirectory

public void extractVirtualDirectory(
String dir,
                                    
File destinationParent,
                                    
String sourceEncoding,
                                    boolean isText,
                                    
ISystemOperationMonitor archiveOperationMonitor)
                             throws 
SystemMessageException
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.

Specified by:
extractVirtualDirectory in interface ISystemArchiveHandler
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
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

extractVirtualFile

public void extractVirtualFile(
String fullVirtualName,
                               
File destination,
                               
String sourceEncoding,
                               boolean isText,
                               
ISystemOperationMonitor archiveOperationMonitor)
                        throws 
SystemMessageException
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.

Specified by:
extractVirtualFile in interface ISystemArchiveHandler
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.
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

getClassification

public 
String getClassification(
String fullVirtualName)
                         throws 
SystemMessageException
Description copied from interface: ISystemArchiveHandler
Get the classification for the entry with the given path.

Specified by:
getClassification in interface ISystemArchiveHandler
Parameters:
fullVirtualName - the virtual name.
Returns:
the classification.
Throws:
SystemMessageException - in case of an error

add

public void add(
InputStream stream,
                
String virtualPath,
                
String name,
                
String sourceEncoding,
                
String targetEncoding,
                boolean isText,
                
ISystemOperationMonitor archiveOperationMonitor)
         throws 
SystemMessageException
Compresses the bytes in the InputStream stream and adds them as an entry to the archive, saving them in the encoding specified by encoding if isText is true, and 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.

Specified by:
add in interface ISystemArchiveHandler
Parameters:
stream - the InputStream to be added as an entry to the archive
virtualPath - the destination of the stream
name - the name of the result virtual file
sourceEncoding - the encoding of the source stream
targetEncoding - the encoding of the result file
isText - is the file a text file
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

add

public void add(
File file,
                
String virtualPath,
                
String name,
                
String sourceEncoding,
                
String targetEncoding,
                
ISystemFileTypes typeRegistery,
                
ISystemOperationMonitor archiveOperationMonitor)
         throws 
SystemMessageException
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.

Specified by:
add in interface ISystemArchiveHandler
Parameters:
file - the file to be added to the archive
virtualPath - the destination of the file
name - the name of the result virtual file
sourceEncoding - the encoding of the source file
targetEncoding - the encoding of the result file
typeRegistery - file transfer mode (binary or text) of this file
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

replace

public void replace(
String fullVirtualName,
                    
InputStream stream,
                    
String name,
                    
String sourceEncoding,
                    
String targetEncoding,
                    boolean isText,
                    
ISystemOperationMonitor archiveOperationMonitor)
             throws 
SystemMessageException
Compress the InputStream stream and replace the virtual file referred to by fullVirtualName with the compressed stream. Pass the name of the new entry as the parameter name, the encoding of the entry as encoding and whether or not the entry isText or not.

Specified by:
replace in interface ISystemArchiveHandler
Parameters:
fullVirtualName - the path of the file to be replaced
stream - the InputStream to be added as an entry to the archive
name - the name of the result virtual file
sourceEncoding - the encoding of the source stream
targetEncoding - the encoding of the result file
isText - is the file a text file
archiveOperationMonitor - the operation progress monitor
Throws:
SystemMessageException - in case of an error, or SystemOperationCancelledException in case of user cancellation
Since:
3.0

getTarOutputStream

protected 
TarOutputStream getTarOutputStream(
File outputFile)
                                      throws 
FileNotFoundException
Get the tar output stream for a given file. This method can be overridden by subclass to return compressed output steam if needed.

Parameters:
outputFile - the output file to create stream
Returns:
OutputStream the output stream to write
Throws:
FileNotFoundException - when the output file doesn't exist
Since:
org.eclipse.rse.services 3.0

RSE
Release 3.0

Copyright (c) IBM Corporation and others 2000, 2008. All Rights Reserved.

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire