org.apache.lucene.store

## Class BaseDirectory

- java.lang.Object
- - org.apache.lucene.store.Directory
  - - org.apache.lucene.store.BaseDirectory

- All Implemented Interfaces:
    Closeable, AutoCloseable
  Direct Known Subclasses:
    FSDirectory, RAMDirectory

      public abstract class BaseDirectory
      extends Directory

  Base implementation for a concrete `Directory` that uses a `LockFactory` for locking.
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `isOpen`
    `protected LockFactory` | `lockFactory` Holds the LockFactory instance (implements locking for this Directory instance).

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `BaseDirectory(LockFactory lockFactory)` Sole constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `ensureOpen()`
    `Lock` | `obtainLock(String name)` Returns an obtained `Lock`.
    `String` | `toString()`

    - ### Methods inherited from class org.apache.lucene.store.Directory

      `close, copyFrom, createOutput, createTempOutput, deleteFile, fileLength, listAll, openChecksumInput, openInput, rename, renameFile, sync, syncMetaData`

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

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

- - ### Field Detail

    - #### isOpen

          protected volatile boolean isOpen

    - #### lockFactory

          protected final LockFactory lockFactory

      Holds the LockFactory instance (implements locking for this Directory instance).

  - ### Constructor Detail

    - #### BaseDirectory

          protected BaseDirectory(LockFactory lockFactory)

      Sole constructor.

  - ### Method Detail

    - #### obtainLock

          public final Lock obtainLock(String name)
                                throws IOException

      Description copied from class: `Directory`
      Returns an obtained `Lock`.
      Specified by:
        `obtainLock` in class `Directory`
      Parameters:
        `name` - the name of the lock file
      Throws:
        `LockObtainFailedException` - (optional specific exception) if the lock could not be obtained because it is currently held elsewhere.
        `IOException` - if any i/o error occurs attempting to gain the lock

    - #### ensureOpen

          protected final void ensureOpen()
                                   throws AlreadyClosedException

      Overrides:
        `ensureOpen` in class `Directory`
      Throws:
        `AlreadyClosedException` - if this Directory is closed

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Directory`

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