TPTP 4.5.0 Platform Project
Public API Specification

org.eclipse.hyades.models.common.util
Class ResourceUtil

java.lang.Object
  extended by org.eclipse.hyades.models.common.util.ResourceUtil

public class ResourceUtil
extends java.lang.Object

Contains utility methods to manipulate the Eclipse resources.


Nested Class Summary
static interface ResourceUtil.IGetFilesVisitor
          Interface to define a visitor for the getFile(...)
 
Field Summary
static java.util.Map RESOURCE_OPTIONS
           
 
Constructor Summary
ResourceUtil()
           
 
Method Summary
static void createContainer(org.eclipse.core.resources.IContainer container, org.eclipse.core.runtime.IProgressMonitor progressMonitor)
          Creates the given container and it's parent if necessary.
static java.util.Map getFiles(org.eclipse.core.resources.IResource resource, java.lang.String[] fileExtensions, ResourceUtil.IGetFilesVisitor visitor)
          Returns a map with all the "files" that are "related" to a given resource and that have their file extension listed in the file extensions array.
static java.util.Map getFiles(org.eclipse.core.resources.IWorkspaceRoot workspaceRoot, java.lang.String[] fileExtensions, ResourceUtil.IGetFilesVisitor visitor)
          Returns a map with all the "files" from all the projects in a given workspace root that have their file extension listed in the file extensions array.
static java.io.File getPluginDirectory(java.lang.String pluginId)
          Returns a File handle to the directory of a plugin or null if the directory was not found.
static org.eclipse.emf.ecore.resource.Resource.Factory getResourceFactory(java.lang.String fileExtension)
          Returns the resource factory associated with a given file extension.
static org.eclipse.emf.ecore.EObject[] load(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.core.resources.IFile file)
          Loads the specified file returning all the root EObjects.
static org.eclipse.emf.ecore.EObject[] load(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, java.lang.String fullPath)
          Loads the specified file returning all the root EObjects.
static void logError(java.lang.Throwable e)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE_OPTIONS

public static final java.util.Map RESOURCE_OPTIONS
Constructor Detail

ResourceUtil

public ResourceUtil()
Method Detail

createContainer

public static void createContainer(org.eclipse.core.resources.IContainer container,
                                   org.eclipse.core.runtime.IProgressMonitor progressMonitor)
                            throws org.eclipse.core.runtime.CoreException
Creates the given container and it's parent if necessary.

Parameters:
container -
progressMonitor -
Throws:
org.eclipse.core.runtime.CoreException

getFiles

public static java.util.Map getFiles(org.eclipse.core.resources.IWorkspaceRoot workspaceRoot,
                                     java.lang.String[] fileExtensions,
                                     ResourceUtil.IGetFilesVisitor visitor)
Returns a map with all the "files" from all the projects in a given workspace root that have their file extension listed in the file extensions array.

This method looks for files recursively if the resource is a project or a folder.

In order to be added to the map the file must exists and must belong to an open project.

Clients can specify a visitor to be used by this method. The visitor is able to defined the object that added to the map - that's the reason the word file is between quotes in the paragraphs above. If the visitor is null then the file is added to the map

Parameters:
workspaceRoot -
fileExtensions. -
visitor -
Returns:
a Map with a List of instances of IFile or with the values defined by the visitor for each file extension.

getFiles

public static java.util.Map getFiles(org.eclipse.core.resources.IResource resource,
                                     java.lang.String[] fileExtensions,
                                     ResourceUtil.IGetFilesVisitor visitor)
Returns a map with all the "files" that are "related" to a given resource and that have their file extension listed in the file extensions array.

This method looks for files recursively if the resource is a project or a folder.

In order to be added to the map the file must exists and must belong to an open project.

Clients can specify a visitor to be used by this method. The visitor is able to defined the object that added to the map - that's the reason the word file is between quotes in the paragraphs above. If the visitor is null then the file is added to the map

Parameters:
resource -
fileExtensions. -
Returns:
a Map with a List of instances of IFile or with the values defined by the visitor for each file extension.

load

public static org.eclipse.emf.ecore.EObject[] load(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
                                                   org.eclipse.core.resources.IFile file)
Loads the specified file returning all the root EObjects. If the resource set argument is null then this method tries to find a registered resource factory.

If the load attempt fails this method adds an entry to the log and returns an empty array.

Parameters:
resourceSet -
file -
Returns:
EObject[]

load

public static org.eclipse.emf.ecore.EObject[] load(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
                                                   java.lang.String fullPath)
Loads the specified file returning all the root EObjects. If the resource set argument is null then this method tries to find a registered resource factory.

If the load attempt fails this method adds an entry to the log and returns an empty array.

Parameters:
resourceSet -
fullPath -
Returns:
EObject[]

getResourceFactory

public static org.eclipse.emf.ecore.resource.Resource.Factory getResourceFactory(java.lang.String fileExtension)
Returns the resource factory associated with a given file extension. If the file extension is null or if there isn't a specifc factory for the file extension, the this method returns the generic factory.

Parameters:
fileExtension -
Returns:
the Resource.Factory or null if none.

logError

public static final void logError(java.lang.Throwable e)
Parameters:
e -

getPluginDirectory

public static java.io.File getPluginDirectory(java.lang.String pluginId)
Returns a File handle to the directory of a plugin or null if the directory was not found.

Parameters:
pluginId -
Returns:
File

TPTP 4.5.0 Platform Project
Public API Specification