org.apache.lucene.mockfile

## Class HandleTrackingFS

- java.lang.Object
- - java.nio.file.spi.FileSystemProvider
  - - org.apache.lucene.mockfile.FilterFileSystemProvider
    - - org.apache.lucene.mockfile.HandleTrackingFS

- Direct Known Subclasses:
    HandleLimitFS, LeakFS, WindowsFS

      public abstract class HandleTrackingFS
      extends FilterFileSystemProvider

  Base class for tracking file handles.

  This class adds tracking to all streams/channels and provides two hooks to handle file management:

  - `onOpen(Path, Object)`
  - `onClose(Path, Object)`

- - ### Field Summary

    - ### Fields inherited from class org.apache.lucene.mockfile.FilterFileSystemProvider

      `delegate, fileSystem, scheme`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HandleTrackingFS(String scheme, FileSystem delegate)` Create a new instance, identified by `scheme` and passing through operations to `delegate`.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `AsynchronousFileChannel` | `newAsynchronousFileChannel(Path path, Set<? extends OpenOption> options, ExecutorService executor, FileAttribute<?>... attrs)`
    `SeekableByteChannel` | `newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs)`
    `DirectoryStream<Path>` | `newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter)`
    `FileChannel` | `newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs)`
    `InputStream` | `newInputStream(Path path, OpenOption... options)`
    `OutputStream` | `newOutputStream(Path path, OpenOption... options)`
    `protected abstract void` | `onClose(Path path, Object stream)` Called when `path` is closed via `stream`.
    `protected abstract void` | `onOpen(Path path, Object stream)` Called when `path` is opened via `stream`.

    - ### Methods inherited from class org.apache.lucene.mockfile.FilterFileSystemProvider

      `checkAccess, copy, createDirectory, createLink, createSymbolicLink, delete, deleteIfExists, getFileAttributeView, getFileStore, getFileSystem, getPath, getScheme, isHidden, isSameFile, move, newFileSystem, newFileSystem, onClose, readAttributes, readAttributes, readSymbolicLink, setAttribute, toDelegate, toString`

    - ### Methods inherited from class java.nio.file.spi.FileSystemProvider

      `installedProviders`

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

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

- - ### Constructor Detail

    - #### HandleTrackingFS

          public HandleTrackingFS(String scheme,
                                  FileSystem delegate)

      Create a new instance, identified by `scheme` and passing through operations to `delegate`.
      Parameters:
        `scheme` - URI scheme for this provider
        `delegate` - delegate filesystem to wrap.

  - ### Method Detail

    - #### onOpen

          protected abstract void onOpen(Path path,
                                         Object stream)
                                  throws IOException

      Called when `path` is opened via `stream`.
      Parameters:
        `path` - Path that was opened
        `stream` - Stream or Channel opened against the path.
      Throws:
        `IOException` - if an I/O error occurs.

    - #### onClose

          protected abstract void onClose(Path path,
                                          Object stream)
                                   throws IOException

      Called when `path` is closed via `stream`.
      Parameters:
        `path` - Path that was closed
        `stream` - Stream or Channel closed against the path.
      Throws:
        `IOException` - if an I/O error occurs.

    - #### newInputStream

          public InputStream newInputStream(Path path,
                                            OpenOption... options)
                                     throws IOException

      Overrides:
        `newInputStream` in class `FilterFileSystemProvider`
      Throws:
        `IOException`

    - #### newOutputStream

          public OutputStream newOutputStream(Path path,
                                              OpenOption... options)
                                       throws IOException

      Overrides:
        `newOutputStream` in class `FilterFileSystemProvider`
      Throws:
        `IOException`

    - #### newFileChannel

          public FileChannel newFileChannel(Path path,
                                            Set<? extends OpenOption> options,
                                            FileAttribute<?>... attrs)
                                     throws IOException

      Overrides:
        `newFileChannel` in class `FilterFileSystemProvider`
      Throws:
        `IOException`

    - #### newAsynchronousFileChannel

          public AsynchronousFileChannel newAsynchronousFileChannel(Path path,
                                                                    Set<? extends OpenOption> options,
                                                                    ExecutorService executor,
                                                                    FileAttribute<?>... attrs)
                                                             throws IOException

      Overrides:
        `newAsynchronousFileChannel` in class `FilterFileSystemProvider`
      Throws:
        `IOException`

    - #### newByteChannel

          public SeekableByteChannel newByteChannel(Path path,
                                                    Set<? extends OpenOption> options,
                                                    FileAttribute<?>... attrs)
                                             throws IOException

      Overrides:
        `newByteChannel` in class `FilterFileSystemProvider`
      Throws:
        `IOException`

    - #### newDirectoryStream

          public DirectoryStream<Path> newDirectoryStream(Path dir,
                                                          DirectoryStream.Filter<? super Path> filter)
                                                   throws IOException

      Overrides:
        `newDirectoryStream` in class `FilterFileSystemProvider`
      Throws:
        `IOException`

Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.