org.openide.filesystems 7.32.1 1

org.openide.filesystems
Class FileEvent

java.lang.Object
  extended by java.util.EventObject
      extended by org.openide.filesystems.FileEvent
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
FileAttributeEvent, FileRenameEvent

public class FileEvent
extends EventObject

Event for listening on filesystem changes.

By calling getFile() the original file where the action occurred can be obtained.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
FileEvent(FileObject src)
          Creates new FileEvent.
FileEvent(FileObject src, FileObject file)
          Creates new FileEvent, specifying the action object.
FileEvent(FileObject src, FileObject file, boolean expected)
          Creates new FileEvent, specifying the action object.
 
Method Summary
 boolean firedFrom(FileSystem.AtomicAction run)
          Tests if FileEvent was fired from atomic action.
 FileObject getFile()
           
 long getTime()
          The time when this event has been created.
 boolean isExpected()
          Getter to test whether the change has been expected or not.
 void runWhenDeliveryOver(Runnable r)
          Support for batch processing of events.
 String toString()
           
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileEvent

public FileEvent(FileObject src)
Creates new FileEvent. The FileObject where the action occurred is assumed to be the same as the source object.

Parameters:
src - source file which sent this event

FileEvent

public FileEvent(FileObject src,
                 FileObject file)
Creates new FileEvent, specifying the action object.

Note that the two arguments of this method need not be identical in cases where it is reasonable that a different file object from the one affected would be listened to by other components. E.g., in the case of a file creation event, the event source (which listeners are attached to) would be the containing folder, while the action object would be the newly created file object.

Parameters:
src - source file which sent this event
file - FileObject where the action occurred

FileEvent

public FileEvent(FileObject src,
                 FileObject file,
                 boolean expected)
Creates new FileEvent, specifying the action object.

Note that the two arguments of this method need not be identical in cases where it is reasonable that a different file object from the one affected would be listened to by other components. E.g., in the case of a file creation event, the event source (which listeners are attached to) would be the containing folder, while the action object would be the newly created file object.

Parameters:
src - source file which sent this event
file - FileObject where the action occurred
expected - sets flag whether the value was expected
Method Detail

getFile

public final FileObject getFile()
Returns:
the original file where action occurred

getTime

public final long getTime()
The time when this event has been created.

Returns:
the milliseconds

isExpected

public final boolean isExpected()
Getter to test whether the change has been expected or not.


runWhenDeliveryOver

public final void runWhenDeliveryOver(Runnable r)
Support for batch processing of events. In some situations you may want to delay processing of received events until the last known one is delivered. For example if there is a lot of operations done inside FileUtil.runAtomicAction(java.lang.Runnable) action, there can be valid reason to do the processing only after all of them are delivered. In such situation attach your Runnable to provided event. Such Runnable is then guaranteed to be called once. Either immediately (if there is no batch delivery in progress) or some time later (if there is a batch delivery). You can attach single runnable multiple times, even to different events in the same batch section and its Runnable.run() method will still be called just once. Object.equals(java.lang.Object) is used to check equality of two Runnables.

Parameters:
r - the runnable to execute when batch event deliver is over (can be even executed immediately)
Since:
7.24

toString

public String toString()
Overrides:
toString in class EventObject

firedFrom

public boolean firedFrom(FileSystem.AtomicAction run)
Tests if FileEvent was fired from atomic action.

Parameters:
run - is tested atomic action.
Returns:
true if fired from run.
Since:
1.35

org.openide.filesystems 7.32.1 1

Built on March 26 2010.  |  Portions Copyright 1997-2010 Sun Microsystems, Inc. All rights reserved.