KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > corext > refactoring > changes > Utils


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.corext.refactoring.changes;
12
13 import org.eclipse.core.resources.IFile;
14 import org.eclipse.core.resources.IFolder;
15 import org.eclipse.core.resources.IProject;
16 import org.eclipse.core.resources.IResource;
17 import org.eclipse.core.resources.ResourcesPlugin;
18 import org.eclipse.core.runtime.IPath;
19
20 class Utils {
21     
22     //no instances
23
private Utils(){
24     }
25     
26     static IPath getResourcePath(IResource resource){
27         return resource.getFullPath().removeFirstSegments(ResourcesPlugin.getWorkspace().getRoot().getFullPath().segmentCount());
28     }
29     
30     static IFile getFile(IPath path){
31         return ResourcesPlugin.getWorkspace().getRoot().getFile(path);
32     }
33     
34     static IFolder getFolder(IPath path){
35         return ResourcesPlugin.getWorkspace().getRoot().getFolder(path);
36     }
37     
38     static IProject getProject(IPath path){
39         return (IProject)ResourcesPlugin.getWorkspace().getRoot().findMember(path);
40     }
41     
42 }
43
44
Popular Tags