public class ProviderContext extends java.lang.Object implements ProviderConstants
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.
Modifier and Type | Field and Description |
---|---|
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.
|
CLASS_TYPE, EMPTY_COLLECTION, SOURCE_TYPE, UNKNOWN_TYPE
Constructor and Description |
---|
ProviderContext() |
Modifier and Type | Method and Description |
---|---|
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) |
JavaFile |
getLightSourceFile(java.net.URL url, int j2se)
Gets a new "light" SourceFile for the (existing) file at the given URL, packaged as a JavaFile.
|
BaseFileProvider |
getProvider()
Get the provider.
|
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.
|
protected static final java.lang.String CLASS_SUFFIX
protected static final java.lang.String SOURCE_SUFFIX
protected BaseFileProvider provider
public void setProvider(BaseFileProvider providerIn)
public BaseFileProvider getProvider()
protected int getFileType(java.net.URL url)
protected SourcePreferences getSourcePreferences()
public SourceFile createSourceFile(java.net.URL url, int j2se) throws java.io.IOException, java.lang.IllegalArgumentException
url
- The source URL to create a new Java file for.java.io.IOException
- if the new file cannot be created.java.lang.IllegalArgumentException
- if the URL is not recognized as a Java source file.public SourceFile getSourceFile(java.net.URL url, int j2se) throws java.lang.IllegalArgumentException
url
- The source URL to create a new Java file for.java.lang.IllegalArgumentException
- if the URL is not recognized as a Java source file.protected SourceFile getSourceFileImpl(java.net.URL url, int j2se) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public JavaFile getLightSourceFile(java.net.URL url, int j2se) throws java.lang.IllegalArgumentException
url
- The source URL for which to create a "light" SourceFilejava.lang.IllegalArgumentException
- if the URL is not recognized as a Java source file.public boolean writeSourceFile(SourceFile file)
protected final SourceFile getSourceFile(TextBuffer textBuffer, int j2se)
protected TextBuffer getTextBuffer(java.net.URL url) throws java.io.FileNotFoundException
The caller is responsible for checking to see that the file exists before calling.
If any IO exception occurs, null gets returned.
java.io.FileNotFoundException
protected void startTracking(java.net.URL url)
If a change is made to the given URL, then this should call BaseFileProvider.notifyOfChange(URL)
.
public void clearTracking()