Package name.pachler.nio.file.ext

# Class Bootstrapper

java.lang.Object
name.pachler.nio.file.ext.Bootstrapper

public class Bootstrapper extends Object
The Bootstrapper is used to instantiate WatchService and Path instances. Because jpathwatch does not implement all the underlying infrastructure of JDK7's nio implementation, the non-standard Bootstrapper class is used for these chores.

## Constructor Summary

Constructors
Constructor
Description
`Bootstrapper()`

## Method Summary

Modifier and Type
Method
Description
`static long`
`getDefaultPollingInterval()`
Retrieves the default polling interval.
`static boolean`
`isForcePollingEnabled()`
`static Path`
`newPath(File file)`
Creates a new Path instance for a given File.
`static WatchService`
`newWatchService()`
Creates a new WatchService.
`static File`
`pathToFile(Path path)`
Gets the File that corresponds to the given path.
`static void`
`setDefaultPollingInterval(long pollInterval)`
This method allows to set the default polling time interval for new WatchService implementations that use polling.
`static void`
`setForcePollingEnabled(boolean forcePollingEnabled)`
When force polling is enabled, the Bootstrapper's `newWatchService()` method will only produce polling watch services.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Bootstrapper

public Bootstrapper()

## Method Details

### newWatchService

public static WatchService newWatchService()
Creates a new WatchService. This is a shortcut for calling `FileSystems.getDefault().newWatchService()` and is not source-compatible to JDK7

Returns:
  a new WatchService implementation instance.
See Also:
  - `FileSystem.newWatchService()`
  - `FileSystems.getDefault()`

### newPath

public static Path newPath(File file)
Creates a new Path instance for a given File.

Parameters:
  `file` - that a new Path is created for
Returns:
  a new Path() corresponding to the given File

### pathToFile

public static File pathToFile(Path path)
Gets the File that corresponds to the given path.

Parameters:
  `path` - Path for with to retreive the corresponding File
Returns:
  The file which corresponds to the given Path instance.

### isForcePollingEnabled

public static boolean isForcePollingEnabled()

Returns:
  whether polling is enforced.

### setForcePollingEnabled

public static void setForcePollingEnabled(boolean forcePollingEnabled)
When force polling is enabled, the Bootstrapper's `newWatchService()` method will only produce polling watch services. This feature is mostly useful for testing and debugging (and not not much else really).

Parameters:
  `forcePollingEnabled` - true to enable force polling

### setDefaultPollingInterval

public static void setDefaultPollingInterval(long pollInterval)

This method allows to set the default polling time interval for new WatchService implementations that use polling. Note that polling is only used on a few supported platforms when certain event kinds are used or on unsupported platforms (fallback implementation).

The polling interval determines how often a thread that calls `WatchService.take()` will wake up to check if files in the watched directory have changed. Longer time intervals will make a polling service less accurate, but costs less in CPU and disk resources, while shorter time intervals lead to higher accuracy but more consumed resources (up to the point where polling takes longer than the set interval in which case the machine will become very slow).

Parameters:
  `pollInterval` - the polling time interval in milliseconds

### getDefaultPollingInterval

public static long getDefaultPollingInterval()
Retrieves the default polling interval.

Returns:
  the default polling interval, in milliseconds
See Also:
  - `setDefaultPollingInterval(long)`