|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK 11g Release 2 (11.1.2.1.0) E17493-02 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.ide.file.FileTable
public abstract class FileTable
Persistently stores information about a set of files, and provides a mapping from each file to an integer ID.
Nested Class Summary | |
---|---|
protected class |
FileTable.FileChangeImpl
Implementation of the FileChange interface. |
Field Summary | |
---|---|
static int |
FIRST_VERSION
The first version of a file table. |
static int |
INVALID_FILE_ID
Constant used to mark an invalid file ID. |
protected static boolean |
IS_KAVA_TEST
Whether we are running in the Kava tests. |
protected java.util.List<FileChangeListener> |
listeners
The listeners for this file table. |
protected static java.util.logging.Logger |
LOGGER
The logger for file table messages. |
static int |
REMOVED_VERSION
Version constant used to deliver removed events for all files in the file table. |
protected Storage |
storage
The storage this file table is stored in. |
Constructor Summary | |
---|---|
protected |
FileTable(Storage storage)
|
Method Summary | |
---|---|
void |
activate()
Activate this file table. |
protected void |
activateImpl()
Called when a file table is activated. |
void |
addFileChangeListener(FileChangeListener listener)
Add a file change listener to receive events about the files in this scope. |
abstract void |
adjustTimestamps()
Adjust the timestamps stored in this file table. |
void |
deactivate()
Deactivate this file table. |
protected void |
deactivateImpl()
Called when a file is deactivated. |
abstract void |
delete()
Delete the file table from storage. |
abstract void |
getChangesSince(int version,
long cookie,
FileChangeListener listener)
Get the changes since an older version of the file data. |
FileTable |
getFileTable(java.net.URL url)
Get the file table in this scope containing a particular URL. |
java.util.Collection<FileTable> |
getFileTables()
Get the file tables currently used by this scope. |
abstract int |
getId(java.net.URL url)
Get the ID of a file in this table. |
abstract long |
getLastModified(int id)
Get the last modified time of a file in this file table. |
abstract long |
getLength(int id)
Get the length of a file in this file table. |
protected static boolean |
getRefreshAutomatically()
Determine whether file tables should be refreshed automatically when there are external changes. |
protected static boolean |
getRefreshOnStartup()
Determine whether file tables should be refreshed the first time they are used in an IDE session. |
abstract java.lang.String |
getRelativePath(java.net.URL url)
Get the path of a URL relative to the root of this file table. |
Storage |
getStorage()
Get underlying storage used to store the file data. |
abstract java.lang.String |
getStorageKey()
Get a unique identifier for this file table. |
abstract java.net.URL |
getURL(int id)
Get the URL for a file ID in this file table. |
abstract void |
invalidate()
Invalidates the file table. |
static void |
invalidateAllJars()
Invalidate all file tables that have data for JAR files. |
static void |
invalidateDirectory(java.net.URL directory,
boolean includeSubdirectories)
Invalidate all active file tables that have data for a directory. |
static void |
invalidateDirectory(java.net.URL directory,
java.net.URL renameHintOldURL,
java.net.URL renameHintNewURL)
Invalidate all active file tables that have data for a directory, due to a file being renamed. |
protected abstract void |
invalidateDirectoryImpl(java.net.URL directory,
boolean includeSubdirectories,
java.net.URL renameHintOldURL,
java.net.URL renameHintNewURL)
Invalidates a directory in this file table. |
static void |
invalidateFile(java.net.URL file,
boolean isBufferChange)
Invalidate all active file tables that have data for a specific file. |
protected abstract void |
invalidateFileImpl(java.net.URL file,
boolean isBufferChange)
Invalidates a file in this file table. |
static void |
invalidateJar(java.net.URL jar)
Invalidate all active file tables that have data for a specific JAR file. |
protected void |
invokeListener(FileChangeListener listener,
FileChanges changes)
Invoke a specific listener with a set of changes. |
protected void |
invokeListeners(FileChanges changes)
Invoke the listeners on this file table with a set of changes. |
void |
refresh()
Refresh this scope. |
protected abstract void |
refreshDirectory(java.net.URL directory,
boolean includeSubdirectories,
java.net.URL renameHintOldURL,
java.net.URL renameHintNewURL)
Synchronously refresh the file table data for a specific directory. |
protected abstract void |
refreshFile(java.net.URL file,
boolean isBufferChange)
Synchronously refresh the file table data for a specific file. |
void |
removeFileChangeListener(FileChangeListener listener)
Remove a file change listener from this scope. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface oracle.ide.file.FileScope |
---|
contains, getDirectories, getFiles, locate, refresh, update |
Field Detail |
---|
public static final int FIRST_VERSION
getChangesSince(int, long, oracle.ide.file.FileChangeListener)
,
Constant Field Valuespublic static final int REMOVED_VERSION
getChangesSince(int, long, oracle.ide.file.FileChangeListener)
,
Constant Field Valuespublic static final int INVALID_FILE_ID
protected static final java.util.logging.Logger LOGGER
protected static final boolean IS_KAVA_TEST
protected final Storage storage
protected final java.util.List<FileChangeListener> listeners
Constructor Detail |
---|
protected FileTable(Storage storage)
Method Detail |
---|
public static void invalidateDirectory(@NotNull java.net.URL directory, boolean includeSubdirectories)
directory
- the directory to invalidateincludeSubdirectories
- whether to also invalidate subdirectoriespublic static void invalidateDirectory(@NotNull java.net.URL directory, @NotNull java.net.URL renameHintOldURL, @NotNull java.net.URL renameHintNewURL)
directory
- the directory to invalidaterenameHintOldURL
- the new location of the file if the directory
invalidation is due to a file being renamedrenameHintNewURL
- the old location of the file if the directory
invalidation is due to a file being renamedpublic static void invalidateFile(@NotNull java.net.URL file, boolean isBufferChange)
file
- the file being invalidatedisBufferChange
- true
if the changes are only in memory and
not saved to disk, false
otherwisepublic static void invalidateJar(@NotNull java.net.URL jar)
jar
- the JAR file being invalidatedpublic static void invalidateAllJars()
protected static boolean getRefreshAutomatically()
true
if file tables should be refreshed automatically,
false
otherwiseprotected static boolean getRefreshOnStartup()
true
if file tables should be refreshed the first time
they are used in an IDE session, false
otherwisepublic void addFileChangeListener(FileChangeListener listener)
FileScope
addFileChangeListener
in interface FileScope
listener
- the listener to be addedpublic void removeFileChangeListener(FileChangeListener listener)
FileScope
removeFileChangeListener
in interface FileScope
listener
- the listener to be removedpublic void activate()
protected void activateImpl()
public void deactivate()
protected void deactivateImpl()
public Storage getStorage()
public abstract java.lang.String getStorageKey()
public abstract void getChangesSince(int version, long cookie, @NotNull FileChangeListener listener) throws java.lang.InterruptedException, FileChangesExpiredException, java.io.IOException
FIRST_VERSION
, the listener will be
invoked with FileChange.Type.ADDED
changes for every file. If the
version passed to this method is REMOVED_VERSION
, the listener
will be invoked with FileChange.Type.REMOVED
changes for every
file.
The cookie parameter is used to ensure that the version number from the
caller is consistent with the data stored in the table. For example, if
the file table data was deleted and regenerated since the last time the
method was called, the cookie will be different. If the cookie from the
caller does not match the current cookie, the method will throw
FileChangesExpiredException
. The client can then delete and
regenerate their own data so it matches the current state of the file
table. The cookie parameter is ignored if the version is
FIRST_VERSION
, and can be any value in that case.
This method will never throw FileChangesExpiredException
if the
version passed into the method is FIRST_VERSION
.
In certain cases, if there have been multiple changes to a file since the version being queried, the listener may receive unexpected events. Specifically:
Calls to this method may require updating the file data, which can take some time.
WARNING: This can be a long running operation. Callers of this method must take steps to ensure that the event thread is not blocked waiting for this method to return. Just making this call on a background thread is not sufficient. Callers must also ensure that no locks are held at the time this call is made, which could cause the event thread to block if it needs the same lock.
version
- the file table versioncookie
- the file table cookielistener
- the listener to be called with changes
java.lang.InterruptedException
- if the calling thread is interrupted
FileChangesExpiredException
- if the file change data for the file
system version has expired
java.io.IOException
- if the file table could not be readFileChanges.getVersion()
,
FileChanges.getCookie()
public abstract int getId(@NotNull java.net.URL url) throws java.lang.InterruptedException, java.io.IOException
INVALID_FILE_ID
if
the URL is not in this table.
url
- the URL of the file
INVALID_FILE_ID
if the URL is not
in this table
java.lang.InterruptedException
- if the calling thread is interrupted
java.io.IOException
- if the file table could not be readpublic abstract java.net.URL getURL(int id) throws java.lang.InterruptedException, java.io.IOException
null
if
the ID does not exist in this file table. This may occur for IDs that
were formerly in the table, but whose file has since been deleted.
id
- the file ID
null
if the ID does not exist in
this table
java.lang.InterruptedException
- if the calling thread is interrupted
java.io.IOException
- if the file table could not be readpublic abstract long getLength(int id) throws java.lang.InterruptedException, java.io.IOException
id
- the file ID
-1
if not known
java.lang.InterruptedException
- if the calling thread is interrupted
java.io.IOException
- if the file table could not be readpublic abstract long getLastModified(int id) throws java.lang.InterruptedException, java.io.IOException
id
- the file ID
-1
if not known
java.lang.InterruptedException
- if the calling thread is interrupted
java.io.IOException
- if the file table could not be readpublic abstract java.lang.String getRelativePath(java.net.URL url)
url
- the URL
null
if the URL cannot be made
relative to this file tablepublic abstract void delete()
public void refresh() throws java.lang.InterruptedException, java.io.IOException
FileScope
refresh
in interface FileScope
java.lang.InterruptedException
- if the calling thread is interrupted
java.io.IOException
- if the refresh failspublic abstract void invalidate()
public abstract void adjustTimestamps() throws java.lang.InterruptedException, java.io.IOException
java.lang.InterruptedException
java.io.IOException
protected abstract void invalidateFileImpl(java.net.URL file, boolean isBufferChange)
file
- the file to be invalidatedisBufferChange
- whether the change is in memory onlyprotected abstract void invalidateDirectoryImpl(java.net.URL directory, boolean includeSubdirectories, java.net.URL renameHintOldURL, java.net.URL renameHintNewURL)
directory
- the directory to be invalidatedincludeSubdirectories
- whether to invalidate subdirectories recursivelyrenameHintOldURL
- the new location of the file if the directory
invalidation is due to a file being renamedrenameHintNewURL
- the old location of the file if the directory
invalidation is due to a file being renamedprotected abstract void refreshFile(java.net.URL file, boolean isBufferChange) throws java.lang.InterruptedException, java.io.IOException
refreshDirectory(java.net.URL, boolean, java.net.URL, java.net.URL)
on the parent
directory instead.
file
- the file to refreshisBufferChange
- whether the file change is known to be in memory
only and not saved to disk
java.lang.InterruptedException
- if the calling thread is interrupted
java.io.IOException
- if the file table could not be refreshedprotected abstract void refreshDirectory(java.net.URL directory, boolean includeSubdirectories, java.net.URL renameHintOldURL, java.net.URL renameHintNewURL) throws java.lang.InterruptedException, java.io.IOException
directory
- the directory to refreshincludeSubdirectories
- whether to recursively refresh subdirectoriesrenameHintOldURL
- the file being renamed in this directory, if the refresh is due to a file being renamedrenameHintNewURL
- the new location of the renamed file, if the refresh is due to a file being renamed
java.lang.InterruptedException
- if the calling thread is interrupted
java.io.IOException
- if the file table could not be refreshedprotected void invokeListeners(FileChanges changes)
changes
- the changesprotected void invokeListener(FileChangeListener listener, FileChanges changes)
listener
- the listenerchanges
- the changespublic java.util.Collection<FileTable> getFileTables()
FileScope
getFileTables
in interface FileScope
public FileTable getFileTable(java.net.URL url)
FileScope
getFileTable
in interface FileScope
url
- the URL
null
if no storages
contain that URL
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK 11g Release 2 (11.1.2.1.0) E17493-02 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |