Skip navigation links

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

E13403-06


oracle.jdeveloper.java.provider
Class ProviderContext

java.lang.Object
  extended by oracle.jdeveloper.java.provider.ProviderContext

All Implemented Interfaces:
ProviderConstants
Direct Known Subclasses:
JdevProviderContext

public class ProviderContext
extends java.lang.Object
implements ProviderConstants

Defines various aspects of the context for the FileProvider implementations. Subclasses may override various aspects for different behavior.

One aspect is the filesystem interface for creating, getting, and writing SourceFiles. The default implementation reads and writes files directly to the file system.

One aspect is an interface for determining what file type (source file or class file) a particular input URL is. The default implementation checks the file suffix.

One aspect is an interface for retrieving user-defined preferences (mostly related to formatting). The default implementation returns nothing since there are no user-defined preferences in the base implementation.

One aspect is an interface for tracking changes made to a set of URLs. The default implementation does nothing since there is no tracking ability in the base implementation.


Field Summary
protected static java.lang.String CLASS_SUFFIX
          The default suffix of a Java class file.
protected  BaseFileProvider provider
          Provider cookie used for new SourceFiles.
protected static java.lang.String SOURCE_SUFFIX
          The default suffix of a Java source file.

 

Fields inherited from interface oracle.jdeveloper.java.provider.ProviderConstants
CLASS_TYPE, EMPTY_COLLECTION, SOURCE_TYPE, UNKNOWN_TYPE

 

Constructor Summary
ProviderContext()
           

 

Method Summary
protected  void clearTracking()
          Stops all tracking.
 SourceFile createSourceFile(java.net.URL url, int j2se)
          Creates a new file at the given URL (*.java) and creates a SourceFile object for it.
protected  int getFileType(java.net.URL url)
           
protected  SourceFile getSourceFile(TextBuffer textBuffer, int j2se)
          Creates a new SourceFile for the given TextBuffer.
 SourceFile getSourceFile(java.net.URL url, int j2se)
          Gets a new SourceFile object for the (existing) file at the given URL.
protected  SourceFile getSourceFileImpl(java.net.URL url, int j2se)
           
protected  SourcePreferences getSourcePreferences()
          Gets the user-defined preferences.
protected  TextBuffer getTextBuffer(java.net.URL url)
          Reads the contents of the given URL into a new TextBuffer.
 void setProvider(BaseFileProvider providerIn)
          Sets the provider cookie that will be used for new SourceFile instances and will also be notified when URLs have been changed.
protected  void startTracking(java.net.URL url)
          Starts tracking changes made to the given URL.
 boolean writeSourceFile(SourceFile file)
          Called when SourceTransaction.commit() is called for the given file.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

CLASS_SUFFIX

protected static final java.lang.String CLASS_SUFFIX
The default suffix of a Java class file.
See Also:
Constant Field Values

SOURCE_SUFFIX

protected static final java.lang.String SOURCE_SUFFIX
The default suffix of a Java source file.
See Also:
Constant Field Values

provider

protected BaseFileProvider provider
Provider cookie used for new SourceFiles.

Constructor Detail

ProviderContext

public ProviderContext()

Method Detail

setProvider

public void setProvider(BaseFileProvider providerIn)
Sets the provider cookie that will be used for new SourceFile instances and will also be notified when URLs have been changed.

getFileType

protected int getFileType(java.net.URL url)
Returns:
The type of the URL: CLASS_TYPE, SOURCE_TYPE, or UNKNOWN_TYPE.

getSourcePreferences

protected SourcePreferences getSourcePreferences()
Gets the user-defined preferences.
Returns:
The SourcePreferences for user-defined preferences, null if none.

createSourceFile

public SourceFile createSourceFile(java.net.URL url,
                                   int j2se)
                            throws java.io.IOException,
                                   java.lang.IllegalArgumentException
Creates a new file at the given URL (*.java) and creates a SourceFile object for it. If the file already exists on disk, then this will return null.
Parameters:
url - The source URL to create a new Java file for.
Returns:
The new source file for the source URL, or null if the file already exists.
Throws:
java.io.IOException - if the new file cannot be created.
java.lang.IllegalArgumentException - if the URL is not recognized as a Java source file.

getSourceFile

public SourceFile getSourceFile(java.net.URL url,
                                int j2se)
                         throws java.lang.IllegalArgumentException
Gets a new SourceFile object for the (existing) file at the given URL. If no file exists at the given URL, null is returned.
Parameters:
url - The source URL to create a new Java file for.
Returns:
The new source file for the source URL, or null if the file did not exist.
Throws:
java.lang.IllegalArgumentException - if the URL is not recognized as a Java source file.

getSourceFileImpl

protected SourceFile getSourceFileImpl(java.net.URL url,
                                       int j2se)
                                throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

writeSourceFile

public boolean writeSourceFile(SourceFile file)
Called when SourceTransaction.commit() is called for the given file.
Returns:
False if an error occurred.

getSourceFile

protected final SourceFile getSourceFile(TextBuffer textBuffer,
                                         int j2se)
Creates a new SourceFile for the given TextBuffer.
Returns:
A newly created SourceFile for the given TextBuffer.

getTextBuffer

protected TextBuffer getTextBuffer(java.net.URL url)
                            throws java.io.FileNotFoundException
Reads the contents of the given URL into a new TextBuffer.

The caller is responsible for checking to see that the file exists before calling.

If any IO exception occurs, null gets returned.

Returns:
A newly created TextBuffer if successful, null otherwise.
Throws:
java.io.FileNotFoundException

startTracking

protected void startTracking(java.net.URL url)
Starts tracking changes made to the given URL.

If a change is made to the given URL, then this should call BaseFileProvider.notifyOfChange(URL).


clearTracking

protected void clearTracking()
Stops all tracking.

Skip navigation links

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

E13403-06


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