站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

JavaSource (Java Source) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.java.source 0.13.0 1

org.netbeans.api.java.source
Class JavaSource

java.lang.Object
  extended by org.netbeans.api.java.source.JavaSource

public final class JavaSource
extends Object

Class representing Java source file opened in the editor.


Nested Class Summary
static class JavaSource.InsufficientMemoryException
          This specialization of IOException signals that a runUserActionTask(org.netbeans.api.java.source.CancellableTask, boolean) or runModificationTask(org.netbeans.api.java.source.CancellableTask) failed due to lack of memory.
static class JavaSource.Phase
           
static class JavaSource.Priority
           
 
Method Summary
static JavaSource create(ClasspathInfo cpInfo, Collection<? extends FileObject> files)
          Returns a JavaSource instance representing given FileObjects and classpath represented by given ClasspathInfo.
static JavaSource create(ClasspathInfo cpInfo, FileObject... files)
          Returns a JavaSource instance representing given FileObjects and classpath represented by given ClasspathInfo.
static JavaSource forDocument(Document doc)
          Returns a JavaSource instance associated to FileObject the Document was created from, it returns null if the Document is not associanted with data type providing the JavaSource.
static JavaSource forFileObject(FileObject fileObject)
          Returns a JavaSource instance associated to given FileObject, it returns null if the Document is not associanted with data type providing the JavaSource.
 ClasspathInfo getClasspathInfo()
          Returns the classpaths (ClasspathInfo) used by this JavaSource
 Collection<FileObject> getFileObjects()
          Returns unmodifiable Collection of FileObjects used by this JavaSource
 ModificationResult runModificationTask(CancellableTask<WorkingCopy> task)
          Runs a task which permits for modifying the sources.
 void runUserActionTask(CancellableTask<CompilationController> task, boolean shared)
          Runs a task which permits for controlling phases of the parsing process.
 Future<Void> runWhenScanFinished(CancellableTask<CompilationController> task, boolean shared)
          Performs the given task when the scan finished.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static JavaSource create(ClasspathInfo cpInfo,
                                Collection<? extends FileObject> files)
                         throws IllegalArgumentException
Returns a JavaSource instance representing given FileObjects and classpath represented by given ClasspathInfo.

Parameters:
cpInfo - the classpaths to be used.
files - for which the JavaSource should be created
Returns:
a new JavaSource
Throws:
{@link - IllegalArgumentException} if fileObject or cpInfo is null
IllegalArgumentException

create

public static JavaSource create(ClasspathInfo cpInfo,
                                FileObject... files)
                         throws IllegalArgumentException
Returns a JavaSource instance representing given FileObjects and classpath represented by given ClasspathInfo.

Parameters:
cpInfo - the classpaths to be used.
files - for which the JavaSource should be created
Returns:
a new JavaSource
Throws:
{@link - IllegalArgumentException} if fileObject or cpInfo is null
IllegalArgumentException

forFileObject

public static JavaSource forFileObject(FileObject fileObject)
                                throws IllegalArgumentException
Returns a JavaSource instance associated to given FileObject, it returns null if the Document is not associanted with data type providing the JavaSource.

Parameters:
fileObject - for which the JavaSource should be found/created.
Returns:
JavaSource or null
Throws:
{@link - IllegalArgumentException} if fileObject is null
IllegalArgumentException

forDocument

public static JavaSource forDocument(Document doc)
                              throws IllegalArgumentException
Returns a JavaSource instance associated to FileObject the Document was created from, it returns null if the Document is not associanted with data type providing the JavaSource.

Parameters:
doc - Document for which the JavaSource should be found/created.
Returns:
JavaSource or null
Throws:
{@link - IllegalArgumentException} if doc is null
IllegalArgumentException

runUserActionTask

public void runUserActionTask(CancellableTask<CompilationController> task,
                              boolean shared)
                       throws IOException
Runs a task which permits for controlling phases of the parsing process. You probably do not want to call this method unless you are reacting to some user's GUI input which requires immediate action (e.g. code completion popup). In all other cases use JavaSourceTaskFactory.
Call to this method will cancel processig of all the phase completion tasks until this task does not finish.

Parameters:
task - The task which.
shared - if true the java compiler may be reused by other org.netbeans.api.java.source.CancellableTasks, the value false may have negative impact on the IDE performance.
Throws:
IOException
See Also:
for information about implementation requirements

runWhenScanFinished

public Future<Void> runWhenScanFinished(CancellableTask<CompilationController> task,
                                        boolean shared)
                                 throws IOException
Performs the given task when the scan finished. When no background scan is running it performs the given task synchronously. When the background scan is active it queues the given task and returns, the task is performed when the background scan completes by the thread doing the background scan.

Parameters:
task - to be performed
shared - if true the java compiler may be reused by other org.netbeans.api.java.source.CancellableTasks, the value false may have negative impact on the IDE performance.
Returns:
Future which can be used to find out the sate of the task Future.isDone() or Future.isCancelled(). The caller may cancel the task using Future.cancel(boolean) or wait until the task is performed Future.get().
Throws:
IOException - encapsulating the exception thrown by CancellableTasks#run
Since:
0.12

runModificationTask

public ModificationResult runModificationTask(CancellableTask<WorkingCopy> task)
                                       throws IOException
Runs a task which permits for modifying the sources. Call to this method will cancel processig of all the phase completion tasks until this task does not finish.

Parameters:
task - The task which.
Throws:
IOException
See Also:
for information about implementation requirements

getClasspathInfo

public ClasspathInfo getClasspathInfo()
Returns the classpaths (ClasspathInfo) used by this JavaSource

Returns:
ClasspathInfo, never returns null.

getFileObjects

public Collection<FileObject> getFileObjects()
Returns unmodifiable Collection of FileObjects used by this JavaSource

Returns:
the FileObjects

org.netbeans.modules.java.source 0.13.0 1

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.