KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > corext > refactoring > participants > JavaProcessors


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.participants;
12
13 import java.util.HashSet JavaDoc;
14 import java.util.Set JavaDoc;
15
16 import org.eclipse.core.runtime.CoreException;
17
18 import org.eclipse.jdt.core.IJavaElement;
19 import org.eclipse.jdt.core.IJavaProject;
20 import org.eclipse.jdt.core.IMember;
21
22 import org.eclipse.jdt.internal.corext.util.JdtFlags;
23
24 /**
25  * Utility class to deal with Java element processors.
26  */

27 public class JavaProcessors {
28
29     public static String JavaDoc[] computeAffectedNatures(IJavaElement element) throws CoreException {
30         if (element instanceof IMember) {
31             IMember member= (IMember)element;
32             if (JdtFlags.isPrivate(member)) {
33                 return element.getJavaProject().getProject().getDescription().getNatureIds();
34             }
35         }
36         IJavaProject project= element.getJavaProject();
37         return ResourceProcessors.computeAffectedNatures(project.getProject());
38     }
39     
40     public static String JavaDoc[] computeAffectedNaturs(IJavaElement[] elements) throws CoreException {
41         Set JavaDoc result= new HashSet JavaDoc();
42         for (int i= 0; i < elements.length; i++) {
43             String JavaDoc[] natures= computeAffectedNatures(elements[i]);
44             for (int j= 0; j < natures.length; j++) {
45                 result.add(natures[j]);
46             }
47         }
48         return (String JavaDoc[])result.toArray(new String JavaDoc[result.size()]);
49     }
50 }
51
Popular Tags