KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > core > _RetoucheUtil


1 /*
2  * _RetoucheUtil.java
3  *
4  * Created on December 3, 2006, 3:19 PM
5  *
6  * To change this template, choose Tools | Template Manager
7  * and open the template in the editor.
8  */

9
10 package org.netbeans.modules.websvc.core;
11
12 import java.io.IOException JavaDoc;
13 import org.netbeans.api.java.source.CompilationController;
14 import org.netbeans.api.java.source.JavaSource;
15 import org.netbeans.modules.j2ee.common.source.AbstractTask;
16 import org.netbeans.modules.j2ee.common.source.SourceUtils;
17 import org.openide.filesystems.FileObject;
18
19 /**
20  *
21  * @author Martin Adamek
22  */

23 public final class _RetoucheUtil {
24     
25     private _RetoucheUtil() {}
26     
27     /** never call this from javac task */
28     public static String JavaDoc getMainClassName(final FileObject classFO) throws IOException JavaDoc {
29         JavaSource javaSource = JavaSource.forFileObject(classFO);
30         final String JavaDoc[] result = new String JavaDoc[1];
31         javaSource.runUserActionTask(new AbstractTask<CompilationController>() {
32             public void run(CompilationController controller) throws IOException JavaDoc {
33                 controller.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
34                 SourceUtils sourceUtils = SourceUtils.newInstance(controller);
35                 result[0] = sourceUtils.getTypeElement().getQualifiedName().toString();
36             }
37         }, true);
38         return result[0];
39     }
40
41 }
42
Popular Tags