Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-03

oracle.jdeveloper.java
Class JavaManager

java.lang.Object
  extended by oracle.jdeveloper.java.JavaModel
      extended by oracle.jdeveloper.java.JavaManager
All Implemented Interfaces:
JavaProvider, JavaFileProvider

public class JavaManager
extends JavaModel

A JavaManager is an implementation of the JavaFileProvider interface. It provides structured access to the contents of Java class and source files visible through a Project or through a set of source and classpaths.

There is also access to a JavaClassLocator instance for searching for the classes and subpackages contained in a package, and for finding an URL associated with a Java source or class file.

By default, the JavaFile and JavaClass (as well as SourceFile and SourceClass) instances retrieved through this API saved in a cache. Clients are encouraged to use the provided CacheSupport API to provide indication as to when the cache is used, and when it is no longer in use (and can be flushed). Clients can also force a cache flush to occur.


Nested Class Summary
protected  class JavaManager.TransactionCommand
          A Command implementation that wraps a committed transaction.
 
Nested classes/interfaces inherited from class oracle.jdeveloper.java.JavaModel
JavaModel.CacheTracker
 
Field Summary
protected  Project _project
          The project associated with this JavaManager (if it is project based and not URL based.)
 
Fields inherited from class oracle.jdeveloper.java.JavaModel
_cacheSupport, _classLocator, _fileProvider
 
Constructor Summary
protected JavaManager(CachedFileProvider provider)
          Protected constructor purposely.
 
Method Summary
 SourceTransaction beginTransaction(SourceFile sourceFile)
          Starts a transaction on the given sourceFile.
 boolean commitTransaction(SourceTransaction openTransaction)
          Commit the specified open transaction.
 boolean commitTransaction(SourceTransaction openTransaction, java.lang.String undoText)
          Commit the specified open transaction.
 boolean commitTransaction(SourceTransaction openTransaction, TransactionDescriptor txnDescriptor)
          Commit the specified open transaction.
 boolean commitTransactionNoUndo(SourceTransaction openTransaction)
          Commit the specified open transaction.
static JavaManager getAnyInstance(Project project)
          Fetch a JavaManager instance in a fail-safe manner.
static JavaManager getAnyJavaManager(Project project)
          Fetch a JavaManager instance in a fail-safe manner.
static Project getDefiningProject(Context context, java.net.URL url)
          Finds the project that defines the specified URL.
The method searches the currentProject, the jdk libraries, the project's libraries, it will repeat the same search for the upstream dependencies and if it still not found, it will search all the other projects in the workspace.
static java.util.List<Project> getDependencies(Project project)
           
static JavaManager getInstance(Project project)
          Fetch a JavaManager instance for the given project.
static JavaManager getInstance(URLPath sourcePath, URLPath classPath)
          Fetch a JavaManager instance for the given source and class paths.
static JavaManager getJavaManager(Project project)
          Fetch a JavaManager instance for the given project.
static JavaManager getJavaManager(URLPath sourcePath, URLPath classPath)
          Fetch a JavaManager instance for the given source and class paths.
static boolean isDefinedIn(Project project, java.net.URL url)
           
 
Methods inherited from class oracle.jdeveloper.java.JavaModel
createSourceFile, finalize, getArrayType, getCacheSupport, getClass, getClass, getClassByVMName, getClassLoader, getClassLoader, getFile, getJavaClassLocator, getPackage, getSourceClass, getSourceFile, getSourceFile, getTextBuffer
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_project

protected Project _project
The project associated with this JavaManager (if it is project based and not URL based.)

Constructor Detail

JavaManager

protected JavaManager(CachedFileProvider provider)
Protected constructor purposely. Clients are forced to use the static factory methods in case this class becomes abstract in the future.

Parameters:
provider - the provider that we wrap
Method Detail

getInstance

public static JavaManager getInstance(Project project)
Fetch a JavaManager instance for the given project.

Parameters:
project - the project to use for locating Java source and class files
Returns:
the JavaManager instance for the specified project
Throws:
java.lang.NullPointerException - if project is null

getInstance

public static JavaManager getInstance(URLPath sourcePath,
                                      URLPath classPath)
Fetch a JavaManager instance for the given source and class paths.

Parameters:
sourcePath - the source path to use for locating Java source files
classPath - the class path to use for locating Java class files
Returns:
the JavaManager instance for the specified paths

getAnyInstance

public static JavaManager getAnyInstance(Project project)
Fetch a JavaManager instance in a fail-safe manner. This method will check the given project, the active project, and the default project in that order, and return a JavaManager on the first of those projects that is not null; if there is no valid project, a JavaManager based on empty paths is returned.

Parameters:
project - the project to use, which can be null
Returns:
a JavaManager instance that is guaranteed to not be null

getJavaManager

public static JavaManager getJavaManager(Project project)
Fetch a JavaManager instance for the given project.

Parameters:
project - the project to use for locating Java source and class files
Returns:
the JavaManager instance for the specified project
Throws:
java.lang.NullPointerException - if project is null

getJavaManager

public static JavaManager getJavaManager(URLPath sourcePath,
                                         URLPath classPath)
Fetch a JavaManager instance for the given source and class paths.

Parameters:
sourcePath - the source path to use for locating Java source files
classPath - the class path to use for locating Java class files
Returns:
the JavaManager instance for the specified paths

getAnyJavaManager

public static JavaManager getAnyJavaManager(Project project)
Fetch a JavaManager instance in a fail-safe manner. This method will check the given project, the active project, and the default project in that order, and return a JavaManager on the first of those projects that is not null; if there is no valid project, a JavaManager based on empty paths is returned.

Parameters:
project - the project to use, which can be null
Returns:
a JavaManager instance that is guaranteed to not be null

beginTransaction

public SourceTransaction beginTransaction(SourceFile sourceFile)
Starts a transaction on the given sourceFile. Transactions started and committed through this JavaManager will have IDE integration, such as undo registration and notifications.

Parameters:
sourceFile - the source file to start a transaction on
Returns:
the source transaction that was opened

commitTransaction

public boolean commitTransaction(SourceTransaction openTransaction)
Commit the specified open transaction. This causes an undoable transaction to be committed, using a default undo description.

Parameters:
openTransaction - the source transaction that is to be committed
Returns:
true upon success.
Throws:
java.lang.NullPointerException - if the openTransaction is null

commitTransaction

public boolean commitTransaction(SourceTransaction openTransaction,
                                 java.lang.String undoText)
Commit the specified open transaction. This causes an undoable transaction to be committed, using the given undoText.

Parameters:
openTransaction - the source transaction that is to be committed
undoText - the (translateable) undo text to use for undo
Returns:
true upon success.
Throws:
java.lang.NullPointerException - if the openTransaction is null

commitTransactionNoUndo

public boolean commitTransactionNoUndo(SourceTransaction openTransaction)
Commit the specified open transaction. This causes a non-undoable transaction to be committed to the SourceFile, flushing the IDE's undo stack for the affected file.

Parameters:
openTransaction - the source transaction that is to be committed
Returns:
true upon success.
Throws:
java.lang.NullPointerException - if the openTransaction is null

commitTransaction

public boolean commitTransaction(SourceTransaction openTransaction,
                                 TransactionDescriptor txnDescriptor)
Commit the specified open transaction. This will additionally take care of the IDE integration tasks of handling Undo/Redo registration via a Command implementation, and notifying Observers of the model change.

The txnDescriptor is required, and provides additional information describing the transaction, such as a human-readable (translated) edit name to use for "Edit->Undo ". Refer to the JavaDoc for TransactionDescriptor for more details.

Parameters:
openTransaction - the source transaction that is to be committed
txnDescriptor - the descriptor describing the transaction that is being committed
Returns:
true upon success.
Throws:
java.lang.NullPointerException - if the openTransaction is null

getDefiningProject

public static Project getDefiningProject(Context context,
                                         java.net.URL url)
Finds the project that defines the specified URL.
The method searches the currentProject, the jdk libraries, the project's libraries, it will repeat the same search for the upstream dependencies and if it still not found, it will search all the other projects in the workspace.

Parameters:
url - The url to find can be a source file, a class file or even a resource
Returns:
The project where the URL is first found, null if it was not found.

getDependencies

public static java.util.List<Project> getDependencies(Project project)

isDefinedIn

public static boolean isDefinedIn(Project project,
                                  java.net.URL url)

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-03

Copyright © 1997, 2009, Oracle. All rights reserved.