Package net.ontopia.infoset.content
Class FileContentStore
- java.lang.Object
-
- net.ontopia.infoset.content.FileContentStore
-
- All Implemented Interfaces:
ContentStoreIF
public class FileContentStore extends Object implements ContentStoreIF
INTERNAL: A content store implementation based on the file system. It uses a two-level structure where inside the root directory is a set of directories, each of which contains a fixed number of files (N). A key is mapped to a file name (key modulo N) and a directory name (key divided by N). The next free key is stored in a file in the top directory, and keys are allocated in blocks.
-
-
Field Summary
Fields Modifier and Type Field Description static int
FILES_PER_DIRECTORY
static int
KEY_BLOCK_SIZE
static int
MAX_SPINS
static int
SPIN_TIMEOUT
-
Constructor Summary
Constructors Constructor Description FileContentStore(File store_root)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
add(InputStream data, int length)
INTERNAL: Creates an entry for the specified data value.int
add(ContentInputStream data)
INTERNAL: Creates an entry for the specified data value.void
close()
INTERNAL: Closes the content store.boolean
containsKey(int key)
INTERNAL: Returns true if the content store contains an entry with the specified key.ContentInputStream
get(int key)
INTERNAL: Gets the data value associated with the specified key.boolean
remove(int key)
INTERNAL: Removes the entry associated with the key.
-
-
-
Field Detail
-
FILES_PER_DIRECTORY
public static final int FILES_PER_DIRECTORY
- See Also:
- Constant Field Values
-
KEY_BLOCK_SIZE
public static final int KEY_BLOCK_SIZE
- See Also:
- Constant Field Values
-
MAX_SPINS
public static final int MAX_SPINS
- See Also:
- Constant Field Values
-
SPIN_TIMEOUT
public static final int SPIN_TIMEOUT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FileContentStore
public FileContentStore(File store_root) throws ContentStoreException
- Throws:
ContentStoreException
-
-
Method Detail
-
containsKey
public boolean containsKey(int key) throws ContentStoreException
Description copied from interface:ContentStoreIF
INTERNAL: Returns true if the content store contains an entry with the specified key.- Specified by:
containsKey
in interfaceContentStoreIF
- Throws:
ContentStoreException
-
get
public ContentInputStream get(int key) throws ContentStoreException
Description copied from interface:ContentStoreIF
INTERNAL: Gets the data value associated with the specified key.- Specified by:
get
in interfaceContentStoreIF
- Throws:
ContentStoreException
-
add
public int add(ContentInputStream data) throws ContentStoreException
Description copied from interface:ContentStoreIF
INTERNAL: Creates an entry for the specified data value.- Specified by:
add
in interfaceContentStoreIF
- Throws:
ContentStoreException
-
add
public int add(InputStream data, int length) throws ContentStoreException
Description copied from interface:ContentStoreIF
INTERNAL: Creates an entry for the specified data value.- Specified by:
add
in interfaceContentStoreIF
- Throws:
ContentStoreException
-
remove
public boolean remove(int key) throws ContentStoreException
Description copied from interface:ContentStoreIF
INTERNAL: Removes the entry associated with the key. If the key is not present the call has no effect.- Specified by:
remove
in interfaceContentStoreIF
- Returns:
- true if the key was present; false otherwise
- Throws:
ContentStoreException
-
close
public void close() throws ContentStoreException
Description copied from interface:ContentStoreIF
INTERNAL: Closes the content store. This allows all internal resources to be released.- Specified by:
close
in interfaceContentStoreIF
- Throws:
ContentStoreException
-
-