Enum Approximation
- java.lang.Object
-
- java.lang.Enum<Approximation>
-
- engineering.swat.watch.Approximation
-
- All Implemented Interfaces:
Serializable,Comparable<Approximation>
public enum Approximation extends Enum<Approximation>
Constants to indicate for which regular files/directories in the scope of the watch an approximation of synthetic events (of kindsWatchEvent.Kind.CREATED,WatchEvent.Kind.MODIFIED, and/orWatchEvent.Kind.DELETED) should be issued when an overflow event happens. These synthetic events, as well as the overflow event itself, are subsequently passed to the user-defined event handler of the watch. Typically, the user-defined event handler can ignore the original overflow event (i.e., handling the synthetic events is sufficient to address the overflow issue), but it doesn't have to (e.g., it may carry out additional overflow bookkeeping).
-
-
Enum Constant Summary
Enum Constants Enum Constant Description ALLSynthetic events of kindsWatchEvent.Kind.CREATEDandWatchEvent.Kind.MODIFIED, but notWatchEvent.Kind.DELETED, are issued for all regular files/directories in the scope of the watch.DIFFSynthetic events of kindsWatchEvent.Kind.CREATED,WatchEvent.Kind.MODIFIED, andWatchEvent.Kind.DELETEDare issued for regular files/directories in the scope of the watch, when their current versions are different from their previous versions, as determined using last-modified-times.NONESynthetic events are issued for no regular files/directories in the scope of the watch.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ApproximationvalueOf(String name)Returns the enum constant of this type with the specified name.static Approximation[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
NONE
public static final Approximation NONE
Synthetic events are issued for no regular files/directories in the scope of the watch. Thus, the user-defined event handler is fully responsible to handle overflow events.
-
ALL
public static final Approximation ALL
Synthetic events of kinds
WatchEvent.Kind.CREATEDandWatchEvent.Kind.MODIFIED, but notWatchEvent.Kind.DELETED, are issued for all regular files/directories in the scope of the watch. Specifically, when an overflow event happens:- CREATED events are issued for all regular files/directories (overapproximation).
- MODIFIED events are issued for all non-empty, regular files (overapproximation) but for no directories (underapproximation).
- DELETED events are issued for no regular files/directories (underapproximation).
This approach is relatively cheap in terms of memory usage (cf.
DIFF), but it results in a large over/underapproximation of the actual events (cf. DIFF).
-
DIFF
public static final Approximation DIFF
Synthetic events of kinds
WatchEvent.Kind.CREATED,WatchEvent.Kind.MODIFIED, andWatchEvent.Kind.DELETEDare issued for regular files/directories in the scope of the watch, when their current versions are different from their previous versions, as determined using last-modified-times. Specifically, when an overflow event happens:- CREATED events are issued for all regular files/directories when the previous last-modified-time is unknown, but the current last-modified-time is known (i.e., the file started existing).
- MODIFIED events are issued for all regular files/directories when the previous last-modified-time is before the current last-modified-time.
- DELETED events are issued for all regular files/directories when the previous last-modified-time is known, but the current last-modified-time is unknown (i.e., the file stopped existing).
To keep track of last-modified-times, an internal index is populated with last-modified-times of all regular files/directories in the scope of the watch when the watch is started. Each time when any event happens, the index is updated accordingly, so when an overflow event happens, last-modified-times can be compared as described above.
This approach results in a small overapproximation (cf.
ALL), but it is relatively expensive in terms of memory usage (cf. ALL), as the watch needs to keep track of last-modified-times.
-
-
Method Detail
-
values
public static Approximation[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Approximation c : Approximation.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Approximation valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
-