Class DataStore
java.lang.Object
org.apache.derby.impl.io.vfmem.DataStore
A virtual data store, keeping track of all the virtual files existing and
offering a set of high-level operations on virtual files.
A newly created data store doesn't contain a single existing directory.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringThe name of the database this store serves, expected to be the absolute path of the service root (i.e.private booleanTells if this store is scheduled for deletion.private static final String[]Constant for the empty String array.private final Map<String, DataStoreEntry> The files exsiting in the store.private final ObjectLock object for the file map.private static final charThe path separator used.private final ObjectLock object for the temporary file counter.private longCounter used to generate unique temporary file names. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean_deleteAll(String prefixPath) Deletes every child of the root path specified.booleancreateAllParents(String path) Creates all the parents of the specified path.createEntry(String iPath, boolean isDir) Creates a new entry in the data store.booleanDeletes the specified entry and all its children.booleandeleteEntry(String iPath) Deletes the specified entry.Returns the database name, which is expected to equal the path of the service root.Returns the entry with the specified path.private String[]getParentList(String path) Returns the list of parents for the specified path.longReturns an identifier for a temporary file.String[]listChildren(String iPath) Lists the childen of the specified path.booleanmove(StorageFile currentFile, StorageFile newFile) Moves / renames a file.voidpurge()Purges the database and releases all files associated with it.booleanTells if this data store is scheduled for deletion.
-
Field Details
-
SEP
private static final char SEPThe path separator used. -
EMPTY_STR_ARR
Constant for the empty String array. -
LOCK
Lock object for the file map. -
TMP_COUNTER_LOCK
Lock object for the temporary file counter. -
files
The files exsiting in the store.The initial size is set to the number of initial files of a Derby database, pluss a few more.
-
databaseName
The name of the database this store serves, expected to be the absolute path of the service root (i.e. /tmp/myDB if the database myDB is created in /tmp). -
tmpFileCounter
private long tmpFileCounterCounter used to generate unique temporary file names. -
deleteMe
private boolean deleteMeTells if this store is scheduled for deletion.
-
-
Constructor Details
-
DataStore
Creates a new data store.- Parameters:
databaseName- the name of the assoicated database, expected to be the absolute path of the service root.
-
-
Method Details
-
getDatabaseName
Returns the database name, which is expected to equal the path of the service root.- Returns:
- The database name.
-
scheduledForDeletion
public boolean scheduledForDeletion()Tells if this data store is scheduled for deletion.- Returns:
trueif the store is awaiting deletion,falseotherwise.
-
createEntry
Creates a new entry in the data store.This method returns
nullif the path already exists, if one of the parent directories doesn't exist, or if one of the parents is a file instead of a directory.- Parameters:
iPath- the path of the entryisDir- tells if the new entry shall be directory or a file- Returns:
- A
DataStoreEntry-instance if the entry was successfully created,nullotherwise
-
createAllParents
Creates all the parents of the specified path.- Returns:
trueif all parents either already existed as directories or were created,falseotherwise
-
deleteEntry
Deletes the specified entry.If the specified entry is a directory, it is only deleted if it is empty. Read-only entries are deleted.
- Parameters:
iPath- path of the entry to delete- Returns:
trueif the entry was deleted,falseotherwise.
-
getEntry
Returns the entry with the specified path.- Parameters:
iPath- path of the entry to fetch- Returns:
nullif the entry doesn't exist, theDataStoreEntry-object otherwise.
-
deleteAll
Deletes the specified entry and all its children.- Parameters:
iPath- the root entry- Returns:
trueif the entry and all its children were deleted,falseif the root doesn't exist.
-
listChildren
-
move
Moves / renames a file.- Parameters:
currentFile- the current filenewFile- the new file- Returns:
trueif the file was moved,falseif the new file already existed or the existing file doesn't exist.
-
purge
public void purge()Purges the database and releases all files associated with it. -
_deleteAll
Deletes every child of the root path specified.Note that the root itself must be removed outside of this method.
- Parameters:
prefixPath- the normalized root path to start deleting from- Returns:
trueif all children of the root path were deleted,falseotherwise.
-
getTempFileCounter
public long getTempFileCounter()Returns an identifier for a temporary file.- Returns:
- An integer uniquely identifying a temporary file.
-
getParentList
Returns the list of parents for the specified path.The lowest level parent is listed first in the list, so all absolute paths will have the root listed as the last element.
- Parameters:
path- the normalized path to create a parent list for- Returns:
- A list of parents.
-