com.sleepycat.persist

## Interface DatabaseNamer

    public interface DatabaseNamer

Determines the file names to use for primary and secondary databases.

Each `PrimaryIndex` and `SecondaryIndex` is represented internally as a Berkeley DB `Database`. The file names of primary and secondary indices must be unique within the environment, so that each index is stored in a separate database file.

By default, the file names of primary and secondary databases are defined as follows.

The syntax of a primary index database file name is:

       STORE_NAME-ENTITY_CLASS

Where STORE_NAME is the name parameter passed to `EntityStore` and ENTITY_CLASS is name of the class passed to `getPrimaryIndex`.

The syntax of a secondary index database file name is:

       STORE_NAME-ENTITY_CLASS-KEY_NAME

Where KEY_NAME is the secondary key name passed to `getSecondaryIndex`.

The default naming described above is implemented by the built-in `DEFAULT` object. An application may supply a custom `DatabaseNamer` to overrride the default naming scheme. For example, a custom namer could place all database files in a subdirectory with the name of the store. A custom namer could also be used to name files according to specific file system restrictions.

The custom namer object must be an instance of the `DatabaseNamer` interface and is configured using `setDatabaseNamer`.

When copying or removing all databases in a store, there is one further consideration. There are two internal databases that must be kept with the other databases in the store in order for the store to be used. These contain the data formats and sequences for the store. Their entity class names are:

       com.sleepycat.persist.formats

       com.sleepycat.persist.sequences

With default database naming, databases with the following names will be present each store.

       STORE_NAME-com.sleepycat.persist.formats

       STORE_NAME-com.sleepycat.persist.sequences

These databases must normally be included with copies of other databases in the store. They should not be modified by the application.

### Field Summary

Fields
`static DatabaseNamer` `DEFAULT` The default database namer.

### Method Summary

All Methods Instance Methods Abstract Methods
`java.lang.String` `getFileName(java.lang.String storeName, java.lang.String entityClassName, java.lang.String keyName)` Returns the name of the file to be used to store the dataabase for the given store, entity class and key.

### Field Detail

#### DEFAULT

    static final DatabaseNamer DEFAULT

The default database namer.

The `getFileName` method of this namer returns the `storeName`, `entityClassName` and `keyName` parameters as follows:

     if (keyName != null) {
         return storeName + '-' + entityClassName + '-' + keyName;
     } else {
         return storeName + '-' + entityClassName;
     }

### Method Detail

#### getFileName

    java.lang.String getFileName(java.lang.String storeName,
                                 java.lang.String entityClassName,
                                 java.lang.String keyName)

Returns the name of the file to be used to store the dataabase for the given store, entity class and key. This method may not return null.

Parameters:
  `storeName` - the name of the `EntityStore`.
  `entityClassName` - the complete name of the entity class for a primary or secondary index.
  `keyName` - the key name identifying a secondary index, or null for a primary index.
Returns:
  the file name.