Package org.eclipse.ui.ide

# Class ResourceUtil

java.lang.Object
org.eclipse.ui.ide.ResourceUtil

public final class ResourceUtil extends Object
Utility class for manipulating resources and determining correspondences between resources and workbench objects.

This class provides all its functionality via static methods. It is not intended to be instantiated or subclassed.

Since:
  3.1

## Method Summary

Modifier and Type
Method
Description
`static IEditorPart`
`findEditor(IWorkbenchPage page, IFile file)`
Returns the editor in the given page whose input represents the given file, or `null` if there is no such editor.
`static <T> T`
`getAdapter(Object element, Class<T> adapterType, boolean forceLoad)`
Deprecated.
Use `Adapters.adapt(Object, Class, boolean)` instead.
`static IFile`
`getFile(Object element)`
Returns the file corresponding to the given model element, or `null` if there is no applicable file.
`static IFile`
`getFile(IEditorInput editorInput)`
Returns the file corresponding to the given editor input, or `null` if there is no applicable file.
`static IResource`
`getResource(Object element)`
Returns the resource corresponding to the given model element, or `null` if there is no applicable resource.
`static IResource`
`getResource(IEditorInput editorInput)`
Returns the resource corresponding to the given editor input, or `null` if there is no applicable resource.
`static ResourceMapping`
`getResourceMapping(Object element)`
Returns the resource mapping corresponding to the given model element, or `null` if there is no applicable resource mapping.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### getFile

public static IFile getFile(IEditorInput editorInput)
Returns the file corresponding to the given editor input, or `null` if there is no applicable file. Returns `null` if the given editor input is `null`.

Parameters:
  `editorInput` - the editor input, or `null`
Returns:
  the file corresponding to the editor input, or `null`

### getResource

public static IResource getResource(IEditorInput editorInput)
Returns the resource corresponding to the given editor input, or `null` if there is no applicable resource. Returns `null` if the given editor input is `null`.

Parameters:
  `editorInput` - the editor input
Returns:
  the file corresponding to the editor input, or `null`

### findEditor

public static IEditorPart findEditor(IWorkbenchPage page, IFile file)
Returns the editor in the given page whose input represents the given file, or `null` if there is no such editor.

Parameters:
  `page` - the workbench page
  `file` - the file
Returns:
  the matching editor, or `null`

### getResource

public static IResource getResource(Object element)
Returns the resource corresponding to the given model element, or `null` if there is no applicable resource.

Parameters:
  `element` - the model element, or `null`
Returns:
  the resource corresponding to the model element, or `null`
Since:
  3.2

### getFile

public static IFile getFile(Object element)
Returns the file corresponding to the given model element, or `null` if there is no applicable file.

Parameters:
  `element` - the model element, or `null`
Returns:
  the resource corresponding to the model element, or `null`
Since:
  3.2

### getResourceMapping

public static ResourceMapping getResourceMapping(Object element)
Returns the resource mapping corresponding to the given model element, or `null` if there is no applicable resource mapping.

Parameters:
  `element` - the model element, or `null`
Returns:
  the resource mapping corresponding to the model element, or `null`
Since:
  3.2

### getAdapter

@Deprecated public static <T> T getAdapter(Object element, Class<T> adapterType, boolean forceLoad)
Deprecated.
Use `Adapters.adapt(Object, Class, boolean)` instead.
See Javadoc of `Adapters.adapt(Object, Class, boolean)`.

Since:
  3.2