RSE
Release 1.0

org.eclipse.rse.services.local.files
Class LocalFileService

java.lang.Object
  extended byorg.eclipse.rse.services.files.AbstractFileService
      extended byorg.eclipse.rse.services.local.files.LocalFileService
All Implemented Interfaces:
IFileService, ILocalService, IService

public class LocalFileService
extends AbstractFileService
implements IFileService, ILocalService


Nested Class Summary
 class LocalFileService.LocalFileNameFilter
           
 
Field Summary
protected  ISystemFileTypes _fileTypeRegistry
           
 
Fields inherited from class org.eclipse.rse.services.files.AbstractFileService
FILE_TYPE_FILES, FILE_TYPE_FILES_AND_FOLDERS, FILE_TYPE_FOLDERS
 
Constructor Summary
LocalFileService(ISystemFileTypes fileTypeRegistry)
           
 
Method Summary
protected  IHostFile[] convertToHostFiles(File[] files, int type)
           
 boolean copy(IProgressMonitor monitor, String srcParent, String srcName, String tgtParent, String tgtName)
          Copy the file or folder to the specified destination
 boolean copyBatch(IProgressMonitor monitor, String[] srcParents, String[] srcNames, String tgtParent)
          Copy a set of files or folders to the specified destination
 boolean copyFromArchive(File sourceFolderOrFile, File targetFolder, String newName, IProgressMonitor monitor, String sourceEncoding, String targetEncoding, boolean isText)
          Copy a file or folder to a new target parent folder, but if copying from an archive, extract the file in the encoding specified
 IHostFile createFile(IProgressMonitor monitor, String remoteParent, String fileName)
          Create a file on the host
protected  LocalVirtualHostFile createFileInArchive(File newFile)
           
 IHostFile createFolder(IProgressMonitor monitor, String remoteParent, String folderName)
          Create a folder on the host
protected  LocalVirtualHostFile createFolderInArchive(File newFolder)
           
 boolean delete(IProgressMonitor monitor, String remoteParent, String fileName)
          Deletes a file or folder on the host
protected  boolean deleteArchive(File file)
           
protected  boolean deleteFromArchive(File destination)
          Deletes a virtual file from its archive.
 boolean download(IProgressMonitor monitor, String remoteParent, String remoteFile, File destinationFile, boolean isBinary, String hostEncoding)
          Copy a file from the remote file system to the local system.
protected  File getContainingArchive(File file)
           
 String getDescription()
           
 IHostFile getFile(IProgressMonitor monitor, String remoteParent, String name)
           
 String getName()
           
 IHostFile[] getRoots(IProgressMonitor monitor)
           
 IHostFile getUserHome()
           
protected  String getVirtualPart(String absPath)
           
protected  void handleSpecialChars(StringBuffer buf)
           
 void initService(IProgressMonitor monitor)
           
protected  IHostFile[] internalFetch(IProgressMonitor monitor, String remoteParent, String fileFilter, int type)
           
 boolean isCaseSensitive()
          Indicates whether the file system is case sensitive
protected  boolean isSpecialChar(char c)
          Checks whether the given character is a special character in the shell.
 boolean isWindows()
           
 boolean move(IProgressMonitor monitor, String srcParent, String srcName, String tgtParent, String tgtName)
          Move the file or folder specified
 boolean rename(IProgressMonitor monitor, String remoteParent, String oldName, String newName)
          Renames a file or folder on the host
 boolean rename(IProgressMonitor monitor, String remoteParent, String oldName, String newName, IHostFile oldFile)
          Renames a file or folder on the host
protected  boolean renameVirtualFile(File destination, String newName)
          Renames a virtual file
 void uninitService(IProgressMonitor monitor)
           
 boolean upload(IProgressMonitor monitor, File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding)
          Copy a file to the remote file system.
 boolean upload(IProgressMonitor monitor, InputStream stream, String remoteParent, String remoteFile, boolean isBinary, String hostEncoding)
          Copy a file to the remote file system.
 
Methods inherited from class org.eclipse.rse.services.files.AbstractFileService
deleteBatch, getFiles, getFilesAndFolders, getFolders, getMessage, isRightType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.rse.services.files.IFileService
deleteBatch, getFiles, getFilesAndFolders, getFolders
 
Methods inherited from interface org.eclipse.rse.services.IService
getMessage
 

Field Detail

_fileTypeRegistry

protected ISystemFileTypes _fileTypeRegistry
Constructor Detail

LocalFileService

public LocalFileService(ISystemFileTypes fileTypeRegistry)
Method Detail

getName

public String getName()
Specified by:
getName in interface IService

getDescription

public String getDescription()
Specified by:
getDescription in interface IService

isWindows

public boolean isWindows()

upload

public boolean upload(IProgressMonitor monitor,
                      InputStream stream,
                      String remoteParent,
                      String remoteFile,
                      boolean isBinary,
                      String hostEncoding)
               throws SystemMessageException
Description copied from interface: IFileService
Copy a file to the remote file system. The remote target is denoted by a string representing the parent and a string representing the file.

Specified by:
upload in interface IFileService
Parameters:
monitor - the monitor for this potentially long running operation
stream - input stream to transfer
remoteParent - - a string designating the parent folder of the target for this file.
remoteFile - - a string designating the name of the file to be written on the remote system.
isBinary - - indicates whether the file is text or binary
hostEncoding - - the tgt encoding of the file (if text)
Returns:
true if the file was uploaded
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

download

public boolean download(IProgressMonitor monitor,
                        String remoteParent,
                        String remoteFile,
                        File destinationFile,
                        boolean isBinary,
                        String hostEncoding)
                 throws SystemMessageException
Description copied from interface: IFileService
Copy a file from the remote file system to the local system.

Specified by:
download in interface IFileService
Parameters:
monitor - the monitor for this potentially long running operation
remoteParent - - a String designating the remote parent.
remoteFile - - a String designating the remote file residing in the parent.
destinationFile - - The file that is to be written. If the file exists it is overwritten.
isBinary - - indicates whether the file is text on binary
hostEncoding - - the encoding on the host (if text)
Returns:
true if the file was copied from the remote system.
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

upload

public boolean upload(IProgressMonitor monitor,
                      File localFile,
                      String remoteParent,
                      String remoteFile,
                      boolean isBinary,
                      String srcEncoding,
                      String hostEncoding)
               throws SystemMessageException
Description copied from interface: IFileService
Copy a file to the remote file system. The remote target is denoted by a string representing the parent and a string representing the file.

Specified by:
upload in interface IFileService
Parameters:
monitor - the monitor for this potentially long running operation
localFile - - a real file in the local file system.
remoteParent - - a string designating the parent folder of the target for this file.
remoteFile - - a string designating the name of the file to be written on the remote system.
isBinary - - indicates whether the file is text or binary
srcEncoding - - the src encoding of the file (if text)
hostEncoding - - the tgt encoding of the file (if text)
Returns:
true if the file was uploaded
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

internalFetch

protected IHostFile[] internalFetch(IProgressMonitor monitor,
                                    String remoteParent,
                                    String fileFilter,
                                    int type)
Specified by:
internalFetch in class AbstractFileService

convertToHostFiles

protected IHostFile[] convertToHostFiles(File[] files,
                                         int type)

getUserHome

public IHostFile getUserHome()
Specified by:
getUserHome in interface IFileService
Returns:
the String containing the name of the user's home directory on this connection that would be contained in implementations of this service.

getRoots

public IHostFile[] getRoots(IProgressMonitor monitor)
Specified by:
getRoots in interface IFileService
Parameters:
monitor - the monitor for this potentially long running operation Return the list of roots for this system
Returns:
the list of host files.

getFile

public IHostFile getFile(IProgressMonitor monitor,
                         String remoteParent,
                         String name)
Specified by:
getFile in interface IFileService
Parameters:
monitor - the monitor for this potentially long running operation
remoteParent -
name -
Returns:
the host file given the parent path and file name

createFile

public IHostFile createFile(IProgressMonitor monitor,
                            String remoteParent,
                            String fileName)
                     throws SystemMessageException
Description copied from interface: IFileService
Create a file on the host

Specified by:
createFile in interface IFileService
Parameters:
monitor - the monitor for this potentially long running operation
remoteParent - the parent directory
fileName - the name of the new file
Returns:
the newly created file
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

createFileInArchive

protected LocalVirtualHostFile createFileInArchive(File newFile)
                                            throws SystemMessageException
Throws:
SystemMessageException

getContainingArchive

protected File getContainingArchive(File file)

getVirtualPart

protected String getVirtualPart(String absPath)

createFolder

public IHostFile createFolder(IProgressMonitor monitor,
                              String remoteParent,
                              String folderName)
                       throws SystemMessageException
Description copied from interface: IFileService
Create a folder on the host

Specified by:
createFolder in interface IFileService
Parameters:
monitor - the progress monitor
remoteParent - the parent directory
folderName - the name of the new folder
Returns:
the newly created folder
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

createFolderInArchive

protected LocalVirtualHostFile createFolderInArchive(File newFolder)
                                              throws SystemMessageException
Throws:
SystemMessageException

delete

public boolean delete(IProgressMonitor monitor,
                      String remoteParent,
                      String fileName)
               throws SystemMessageException
Description copied from interface: IFileService
Deletes a file or folder on the host

Specified by:
delete in interface IFileService
Parameters:
monitor - the progress monitor
remoteParent - the folder containing the file to delete
fileName - the name of the file or folder to delete
Returns:
true if successful
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

deleteFromArchive

protected boolean deleteFromArchive(File destination)
                             throws SystemMessageException
Deletes a virtual file from its archive.

Parameters:
destination - virtual file to delete from archive
Throws:
SystemMessageException

deleteArchive

protected boolean deleteArchive(File file)

rename

public boolean rename(IProgressMonitor monitor,
                      String remoteParent,
                      String oldName,
                      String newName)
               throws SystemMessageException
Description copied from interface: IFileService
Renames a file or folder on the host

Specified by:
rename in interface IFileService
Parameters:
monitor - the progress monitor
remoteParent - the folder containing the file to rename
oldName - the old name of the file or folder to rename
newName - the new name for the file
Returns:
true if successful
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

rename

public boolean rename(IProgressMonitor monitor,
                      String remoteParent,
                      String oldName,
                      String newName,
                      IHostFile oldFile)
               throws SystemMessageException
Description copied from interface: IFileService
Renames a file or folder on the host

Specified by:
rename in interface IFileService
Parameters:
monitor - the progress monitor
remoteParent - the folder containing the file to rename
oldName - the old name of the file or folder to rename
newName - the new name for the file
oldFile - the file to update with the change
Returns:
true if successful
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

renameVirtualFile

protected boolean renameVirtualFile(File destination,
                                    String newName)
                             throws SystemMessageException
Renames a virtual file

Parameters:
destination - virtual file to rename
newName - the new name of the virtual file
Returns:
Throws:
SystemMessageException

move

public boolean move(IProgressMonitor monitor,
                    String srcParent,
                    String srcName,
                    String tgtParent,
                    String tgtName)
             throws SystemMessageException
Description copied from interface: IFileService
Move the file or folder specified

Specified by:
move in interface IFileService
Parameters:
monitor - the progress monitor
srcParent - the folder containing the file or folder to move
srcName - the new of the file or folder to move
tgtParent - the destination folder for the move
tgtName - the name of the moved file or folder
Returns:
true if the file was moved
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

copy

public boolean copy(IProgressMonitor monitor,
                    String srcParent,
                    String srcName,
                    String tgtParent,
                    String tgtName)
             throws SystemMessageException
Description copied from interface: IFileService
Copy the file or folder to the specified destination

Specified by:
copy in interface IFileService
Parameters:
monitor - the progress monitor
srcParent - the folder containing the file or folder to copy
srcName - the new of the file or folder to copy
tgtParent - the destination folder for the copy
tgtName - the name of the copied file or folder
Returns:
true if the file was copied successfully
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

handleSpecialChars

protected void handleSpecialChars(StringBuffer buf)

isSpecialChar

protected boolean isSpecialChar(char c)
Checks whether the given character is a special character in the shell. A special character is '$', '`', '"' and '\'.

Parameters:
c - the character to check.
Returns:
true if the character is a special character, false otherwise.

copyFromArchive

public boolean copyFromArchive(File sourceFolderOrFile,
                               File targetFolder,
                               String newName,
                               IProgressMonitor monitor,
                               String sourceEncoding,
                               String targetEncoding,
                               boolean isText)
                        throws SystemMessageException
Copy a file or folder to a new target parent folder, but if copying from an archive, extract the file in the encoding specified

Parameters:
sourceFolderOrFile - The file or folder to copy
targetFolder - The folder to copy to. No guarantee it is on the same system, so be sure to check getSystemConnection()!
newName - The new name for the copied file or folder
Returns:
true iff the copy succeeded
Throws:
SystemMessageException

initService

public void initService(IProgressMonitor monitor)
Specified by:
initService in interface IService

uninitService

public void uninitService(IProgressMonitor monitor)
Specified by:
uninitService in interface IService

isCaseSensitive

public boolean isCaseSensitive()
Description copied from interface: IFileService
Indicates whether the file system is case sensitive

Specified by:
isCaseSensitive in interface IFileService
Returns:
true if the file system has case sensitive file names

copyBatch

public boolean copyBatch(IProgressMonitor monitor,
                         String[] srcParents,
                         String[] srcNames,
                         String tgtParent)
                  throws SystemMessageException
Description copied from interface: IFileService
Copy a set of files or folders to the specified destination

Specified by:
copyBatch in interface IFileService
Parameters:
monitor - the progress monitor
srcParents - the folders containing each file or folder to copy
srcNames - the names of the files or folders to copy
tgtParent - the destination folder for the copy
Returns:
true if all files were copied
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

RSE
Release 1.0

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