org.eclipse.rse.core
Class SystemResourceHelpers
java.lang.Object
org.eclipse.rse.core.SystemResourceHelpers
-
All Implemented Interfaces:
-
FileFilter
-
public class SystemResourceHelpers
- extends
Object
- implements
FileFilter
A class with helper methods for working with the underlying Eclipse resources
needed for filters, filter pools and filter pool managers.
Method Summary
|
boolean
|
accept
(
File file)
Method required by FilenameFilter interface, used by java.io.File.list() |
IFile[]
|
convertToFileArray
(
Vector vector)
Convert a vector of IFile objects to an array of IFile. |
IFolder[]
|
convertToFolderArray
(
Vector vector)
Convert a vector of IFolder objects to an array of IFolder. |
Vector
|
convertToVector
(
String[] array)
Convert a name array to a vector. |
Vector
|
convertToVectorAndStrip
(
String[] array,
String namePrefix,
String nameSuffix)
Convert a name array to a vector. |
boolean
|
createFolder
(
IFolder folder)
Create new folder |
boolean
|
deleteFile
(
IFile file)
Delete a file |
boolean
|
deleteFolder
(
IFolder folder)
Delete a folder |
void
|
deleteResource
(
IResource fileOrFolder)
Method to delete a folder or file and absorb the exception |
boolean
|
ensureFolderExists
(
IFolder folder)
Create a folder, if it does not already exist. |
boolean
|
exists
(
IResource resource)
For some reason the exists() method on IResource is fundamentally not reliable. |
boolean
|
fileExists
(
IFile file)
Check if a file exists in the file system. |
IFile
|
getFile
(
IContainer parent,
String fileName)
Get a file whose parent is either a project or a folder |
static
String
|
getFilePath
(
IFile file)
Return the path of the given file |
IFolder
|
getFolder
(
IContainer parent,
String folderName)
Get a folder whose parent is either a project or a folder |
String
|
getFolderPath
(
IFolder folder)
Return the path of the given folder |
IFolder
|
getOrCreateFolder
(
IContainer parentFolder,
String folderName)
Create a folder, if it does not already exist. |
IFolder
|
getRenamedFolder
(
IFolder oldFolder,
String newFolderName)
Re-get a folder which has been renamed. |
static
SystemResourceHelpers
|
getResourceHelpers
()
Return common instance if unique instance not required. |
IFile[]
|
listFiles
(
IContainer projectOrFolder)
Return a list of child files in the given container |
String[]
|
listFiles
(
IFolder folder,
String namePrefix,
String nameSuffix)
Return a list of names of files in the given container |
IFolder[]
|
listFolders
(
IContainer projectOrFolder)
Return a list of child folders in the given container |
IFolder[]
|
listFolders
(
IContainer projectOrFolder,
String fileName)
Return a list of child folders in the given container,
which contain a file of the given name. |
String[]
|
listFolders
(
IFolder folder,
String namePrefix,
String nameSuffix)
Return a list of names of folders in the given container |
void
|
logException
(
String msg,
Exception exc)
|
void
|
logMessage
(
String msg)
|
boolean
|
moveFile
(
IFolder newParent,
IFile file)
Move a file |
boolean
|
moveFolder
(
IFolder newParent,
IFolder folder)
Move a folder |
void
|
refreshResource
(
IResource fileOrFolder)
Refresh a resource from disk. |
void
|
refreshResourceShallow
(
IResource fileOrFolder)
Refresh a resource from disk. |
boolean
|
renameFile
(
IFile file,
String newName)
Rename a file |
boolean
|
renameFolder
(
IFolder folder,
String newName)
Rename a folder |
void
|
renameResource
(
IResource fileOrFolder,
String newName)
Method to rename a folder or file and absorb the exception |
void
|
setListValues
(boolean filesOnly,
boolean foldersOnly,
String namePrefix,
String nameSuffix)
Method to set variables to affect the folder content subsetting |
static boolean
|
testIfResourceInUse
(
IResource resource)
Test if a resource is in use, prior to attempting to rename or delete it. |
Methods inherited from class java.lang.
Object
|
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
|
SystemResourceHelpers
public SystemResourceHelpers()
- Constructor
getResourceHelpers
public static
SystemResourceHelpers getResourceHelpers()
- Return common instance if unique instance not required.
-
-
deleteResource
public void deleteResource(
IResource fileOrFolder)
- Method to delete a folder or file and absorb the exception
-
-
renameResource
public void renameResource(
IResource fileOrFolder,
String newName)
- Method to rename a folder or file and absorb the exception
-
-
refreshResource
public void refreshResource(
IResource fileOrFolder)
- Refresh a resource from disk. Turns off resource event listening to avoid recursion.
Does a DEPTH_INFINITE refresh.
-
-
refreshResourceShallow
public void refreshResourceShallow(
IResource fileOrFolder)
- Refresh a resource from disk. Turns off resource event listening to avoid recursion.
Does a DEPTH_ZERO refresh, so children are not refreshed. Should be more efficient than
deep refresh.
-
-
testIfResourceInUse
public static boolean testIfResourceInUse(
IResource resource)
- Test if a resource is in use, prior to attempting to rename or delete it.
-
-
-
Returns:
- true if it is in use or read only, false if it is not.
getOrCreateFolder
public
IFolder getOrCreateFolder(
IContainer parentFolder,
String folderName)
- Create a folder, if it does not already exist.
-
-
ensureFolderExists
public boolean ensureFolderExists(
IFolder folder)
- Create a folder, if it does not already exist.
-
-
getFolder
public
IFolder getFolder(
IContainer parent,
String folderName)
- Get a folder whose parent is either a project or a folder
-
-
getRenamedFolder
public
IFolder getRenamedFolder(
IFolder oldFolder,
String newFolderName)
- Re-get a folder which has been renamed.
-
-
createFolder
public boolean createFolder(
IFolder folder)
- Create new folder
-
-
deleteFolder
public boolean deleteFolder(
IFolder folder)
throws
Exception
- Delete a folder
-
-
-
Throws:
-
Exception
renameFolder
public boolean renameFolder(
IFolder folder,
String newName)
throws
Exception
- Rename a folder
-
-
-
Throws:
-
Exception
moveFolder
public boolean moveFolder(
IFolder newParent,
IFolder folder)
throws
Exception
- Move a folder
-
-
-
Throws:
-
Exception
getFolderPath
public
String getFolderPath(
IFolder folder)
- Return the path of the given folder
-
-
listFolders
public
IFolder[] listFolders(
IContainer projectOrFolder)
- Return a list of child folders in the given container
-
-
-
Parameters:
-
projectOrFolder
- The parent container to search.
-
Returns:
- an array of IFolder objects
listFolders
public
IFolder[] listFolders(
IContainer projectOrFolder,
String fileName)
- Return a list of child folders in the given container,
which contain a file of the given name.
-
-
-
Parameters:
-
projectOrFolder
- The parent container to search. -
fileName
- The name of the file which must exist
in the folder in order to be included in the returned list
-
Returns:
- an array of IFolder objects
listFolders
public
String[] listFolders(
IFolder folder,
String namePrefix,
String nameSuffix)
- Return a list of names of folders in the given container
-
-
-
Parameters:
-
folder
- The folder to query -
namePrefix
- Optional prefix all names should match. Can be null. -
nameSuffix
- Optional suffix all names should match. Can be null.
getFile
public
IFile getFile(
IContainer parent,
String fileName)
- Get a file whose parent is either a project or a folder
-
-
fileExists
public boolean fileExists(
IFile file)
- Check if a file exists in the file system.
For some reason, the exists() method of IFile cannot be trusted to
report actual file system existence.
-
-
deleteFile
public boolean deleteFile(
IFile file)
throws
Exception
- Delete a file
-
-
-
Throws:
-
Exception
renameFile
public boolean renameFile(
IFile file,
String newName)
throws
Exception
- Rename a file
-
-
-
Parameters:
-
newName
- - the name name for the file, unqualified!
-
Throws:
-
Exception
moveFile
public boolean moveFile(
IFolder newParent,
IFile file)
throws
Exception
- Move a file
-
-
-
Throws:
-
Exception
getFilePath
public static
String getFilePath(
IFile file)
- Return the path of the given file
-
-
listFiles
public
IFile[] listFiles(
IContainer projectOrFolder)
- Return a list of child files in the given container
-
-
-
Parameters:
-
projectOrFolder
- The parent container to search.
-
Returns:
- an array of IFile objects
listFiles
public
String[] listFiles(
IFolder folder,
String namePrefix,
String nameSuffix)
- Return a list of names of files in the given container
-
-
-
Parameters:
-
folder
- The folder to query -
namePrefix
- Optional prefix all names should match. Can be null. -
nameSuffix
- Optional suffix all names should match. Can be null.
convertToFolderArray
public
IFolder[] convertToFolderArray(
Vector vector)
- Convert a vector of IFolder objects to an array of IFolder.
Result is only null if input is null.
-
-
convertToFileArray
public
IFile[] convertToFileArray(
Vector vector)
- Convert a vector of IFile objects to an array of IFile.
Result is only null if input is null.
-
-
convertToVector
public
Vector convertToVector(
String[] array)
- Convert a name array to a vector. If array is null or empty, an empty vector is returned.
-
-
convertToVectorAndStrip
public
Vector convertToVectorAndStrip(
String[] array,
String namePrefix,
String nameSuffix)
- Convert a name array to a vector. As each name is copied
to the vector, its prefix and suffix are stripped off.
If array is null or empty, an empty vector is returned.
-
-
setListValues
public void setListValues(boolean filesOnly,
boolean foldersOnly,
String namePrefix,
String nameSuffix)
- Method to set variables to affect the folder content subsetting
-
-
accept
public boolean accept(
File file)
- Method required by FilenameFilter interface, used by java.io.File.list()
-
-
Specified by:
-
accept
in interface
FileFilter
-
logMessage
public void logMessage(
String msg)
-
-
logException
public void logException(
String msg,
Exception exc)
-
-
exists
public boolean exists(
IResource resource)
- For some reason the exists() method on IResource is fundamentally not reliable.
Because of this, we resort to the looking ourselves at the file system.
-
-
Copyright (c) IBM Corporation and others 2000, 2008. All Rights Reserved.