Package 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:
  `ByteBuffersDirectory`, `FSDirectory`

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
Description
`protected boolean`
`isOpen`
`protected final LockFactory`
`lockFactory`
Holds the LockFactory instance (implements locking for this Directory instance).

## Constructor Summary

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

## Method Summary

Modifier and Type
Method
Description
`protected final void`
`ensureOpen()`
Ensures this directory is still open.
`final Lock`
`obtainLock(String name)`
Acquires and returns a `Lock` for a file with the given name.
`String`
`toString()`

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

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

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

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

## Field Details

### isOpen

protected volatile boolean isOpen

### lockFactory

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

## Constructor Details

### BaseDirectory

protected BaseDirectory(LockFactory lockFactory)
Sole constructor.

## Method Details

### obtainLock

public final Lock obtainLock(String name) throws IOException
Description copied from class: `Directory`
Acquires and returns a `Lock` for a file with the given name.

Specified by:
  `obtainLock` in class `Directory`
Parameters:
  `name` - the name of the lock file
Throws:
  `IOException` - if any i/o error occurs attempting to gain the lock

### ensureOpen

protected final void ensureOpen() throws AlreadyClosedException
Description copied from class: `Directory`
Ensures this directory is still open.

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

### toString

public String toString()

Overrides:
  `toString` in class `Directory`