public class FileObserver
extends java.lang.Object
implements java.lang.Runnable
Modifier and Type | Class and Description |
---|---|
class |
FileObserver.FireThread
The runnable that calls the listener.
|
Modifier and Type | Field and Description |
---|---|
protected java.lang.Object |
arrLock |
static int |
FILE_NOTIFY_CHANGE_ATTRIBUTES
Any attribute change in the watched directory or subtree causes
a change notification wait operation to return.
|
static int |
FILE_NOTIFY_CHANGE_CREATION |
static int |
FILE_NOTIFY_CHANGE_DIR_NAME
Any directory-name change in the watched directory or subtree
causes a change notification wait operation to return.
|
static int |
FILE_NOTIFY_CHANGE_FILE_NAME
Any file name change in the watched directory or subtree causes
a change notification wait operation to return.
|
static int |
FILE_NOTIFY_CHANGE_LAST_ACCESS |
static int |
FILE_NOTIFY_CHANGE_LAST_WRITE
Any change to the last write-time of files in the watched directory or
subtree causes a change notification wait operation to return.
|
static int |
FILE_NOTIFY_CHANGE_SECURITY
Any security-descriptor change in the watched directory or
subtree causes a change notification wait operation to return.
|
static int |
FILE_NOTIFY_CHANGE_SIZE
Any file-size change in the watched directory or subtree causes a
change notification wait operation to return.
|
protected int |
flags |
protected static boolean |
libLoaded |
static java.lang.String |
LIBRARY_NAME |
protected java.lang.Object |
listenerLock |
protected javax.swing.event.EventListenerList |
listeners |
protected long |
nativeContext |
protected java.lang.String[] |
observables |
protected java.lang.Thread |
thread |
protected int |
timeout |
protected boolean |
watchSubTree |
Constructor and Description |
---|
FileObserver()
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
add(int index,
java.lang.String observable)
Add an observable.
|
int |
add(java.lang.String observable)
Add an observable.
|
void |
addFileObserverListener(FilePollerListenerInterface listener)
Add an event listener.
|
protected void |
finalize()
Release the native pointer.
|
void |
fireIndexEvent(int index)
Fire an index event.
|
java.lang.String |
get(int index)
Get an observable.
|
static int |
getAllFlags()
Get all flags.
|
static int |
getAttributeFlag()
Get the native flag to observe the file attributes.
|
static int |
getCreationFlag()
Get the native flag to observe file creation.
|
static int |
getDirectoryFlag()
Get the native flag to observe the creation, renames and deletion of directories.
|
static int |
getFilenameFlag()
Get the native flag to observe the creation, renames and deletion of filenames.
|
int |
getFlags()
Get the classification flags.
|
static int |
getLastAccessFlag()
Get the native flag to observe the last access.
|
static int |
getLastWriteFlag()
Get the native flag to observe the last write.
|
static int |
getMaxCount()
Get the maximum observation count.
|
static int |
getSecurityFlag()
Get the native flag to observe the security attribute.
|
static int |
getSizeFlag()
Get the native flag to observe the filesize.
|
java.lang.Thread |
getThread()
Returns the thread that observes.
|
int |
getTimeout()
Get the timeout in milliseconds.
|
boolean |
getWatchSubTree()
Get the subtree flag.
|
static boolean |
isLibraryLoaded()
This method returns the library load state.
|
boolean |
isStopped()
Return a boolean whether the thread is stopped.
|
static void |
main(java.lang.String[] args)
The main testing routine.
|
void |
release()
Release the notifications.
|
java.lang.String |
remove(int index)
Remove an entry.
|
void |
removeFileObserverListener(FilePollerListenerInterface listener)
Remove an event listener.
|
void |
run()
The run method.
|
void |
setFlags(int flags)
Set the flags that classify the observer.
|
void |
setTimeout(int timeout)
Set the observer timeout.
|
void |
setWatchSubTree(boolean flag)
Set the flag to obtain subtrees.
|
int |
size()
Get the size of observable array.
|
void |
start()
Called by the main program, the hosting frame,
or the hosting applet to inform this application
that it should start its execution.
|
void |
startObservation(java.lang.Thread thread)
Initialize the observation.
|
void |
stop()
Called by the main program, the hosting frame,
or the hosting applet to inform this application
that it should stop its execution.
|
public static final java.lang.String LIBRARY_NAME
public static final int FILE_NOTIFY_CHANGE_FILE_NAME
public static final int FILE_NOTIFY_CHANGE_DIR_NAME
public static final int FILE_NOTIFY_CHANGE_ATTRIBUTES
public static final int FILE_NOTIFY_CHANGE_SIZE
public static final int FILE_NOTIFY_CHANGE_LAST_WRITE
public static final int FILE_NOTIFY_CHANGE_LAST_ACCESS
public static final int FILE_NOTIFY_CHANGE_CREATION
public static final int FILE_NOTIFY_CHANGE_SECURITY
protected static boolean libLoaded
protected long nativeContext
protected boolean watchSubTree
protected int flags
protected int timeout
protected java.lang.String[] observables
protected java.lang.Thread thread
protected java.lang.Object arrLock
protected java.lang.Object listenerLock
protected javax.swing.event.EventListenerList listeners
public static int getFilenameFlag()
public static int getDirectoryFlag()
public static int getAttributeFlag()
public static int getSizeFlag()
public static int getLastWriteFlag()
public static int getLastAccessFlag()
public static int getCreationFlag()
public static int getSecurityFlag()
public static int getMaxCount()
public void release()
public void startObservation(java.lang.Thread thread)
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public static int getAllFlags()
public static boolean isLibraryLoaded()
public void setWatchSubTree(boolean flag)
flag
- if true the observer will watch the subtree.public boolean getWatchSubTree()
public void setFlags(int flags)
FILE_NOTIFY_CHANGE_FILE_NAME | 0x00000001 |
FILE_NOTIFY_CHANGE_DIR_NAME | 0x00000002 |
FILE_NOTIFY_CHANGE_ATTRIBUTES | 0x00000004 |
FILE_NOTIFY_CHANGE_SIZE | 0x00000008 |
FILE_NOTIFY_CHANGE_LAST_WRITE | 0x00000010 |
FILE_NOTIFY_CHANGE_LAST_ACCESS | 0x00000020 |
FILE_NOTIFY_CHANGE_CREATION | 0x00000040 |
FILE_NOTIFY_CHANGE_SECURITY | 0x00000100 |
flags
- Can be one or more of the native flags combined by a logical OR.public int getFlags()
public void setTimeout(int timeout)
timeout
- time in milliseconds (default 10000).public int getTimeout()
public int add(int index, java.lang.String observable)
index
- the array position.path
- the observable.public int add(java.lang.String observable)
path
- the observable.public java.lang.String get(int index)
public java.lang.String remove(int index)
index
- the index of the entry to be removed.public void addFileObserverListener(FilePollerListenerInterface listener)
listener
- the event listener.public void removeFileObserverListener(FilePollerListenerInterface listener)
listener
- the event listener.public int size()
public void fireIndexEvent(int index)
index
- The index into the observable array.public void run()
run
in interface java.lang.Runnable
public void start()
public void stop()
public java.lang.Thread getThread()
public boolean isStopped()
public static void main(java.lang.String[] args)