public class FileIndexContainer extends Object implements IndexContainer
Modifier and Type | Field and Description |
---|---|
static String |
EXTENSION
Standard filename extension for indexes in this format.
|
static int |
MAGIC
Magic number used in the index file header.
|
static int |
VERSION
Version number of the index format.
|
Constructor and Description |
---|
FileIndexContainer(File _indexfile,
boolean _editMode)
Create a new file index container or open an existing file in edit or access mode.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canAccess()
Return if the index container is in
access mode. |
boolean |
canEdit()
Return if the index container is in
edit mode. |
void |
close()
Close this index container.
|
void |
createIndex(int indexType,
ByteBuffer data)
Add index data for a particular index type to the container.
|
void |
deleteIndex(int indexType)
Delete the index data of a particular index type from the container.
|
void |
endEditing()
Switch the index container from
edit mode to access mode. |
ByteOrder |
getIndexByteOrder()
Return the byte order used by this index container for
ByteBuffers . |
ByteBuffer |
getIndexData(int indexType)
Fetch the index data for a particular index type for read access.
|
boolean |
hasIndex(int indexType)
Test if the index data of the particular index type is stored in this container.
|
public static final String EXTENSION
public static final int MAGIC
public static final int VERSION
public FileIndexContainer(File _indexfile, boolean _editMode) throws FileNotFoundException, IOException, IndexException
FileNotFoundException
- if the index container is opened in access mode and the index file does not
already exist.IndexException
- if the selected file exists but does not contain a valid index structure.IOException
public boolean hasIndex(int indexType)
IndexContainer
hasIndex
in interface IndexContainer
public ByteBuffer getIndexData(int indexType) throws IndexException, IllegalStateException
IndexContainer
Index
instances will call this method to get at their data.getIndexData
in interface IndexContainer
close
is called.IllegalStateException
- if the index container is not in access
mode.IndexException
public ByteOrder getIndexByteOrder()
IndexContainer
ByteBuffers
.
Indexes
and IndexBuilders
should use this byte order
to guarantee that the index file is portable. ByteBuffers
returned by
getIndexData
are set to the byte order returned by this method.getIndexByteOrder
in interface IndexContainer
public void createIndex(int indexType, ByteBuffer data) throws IndexException, IllegalStateException
IndexContainer
edit
mode.createIndex
in interface IndexContainer
indexType
- Index type of the data added.data
- Buffer containing the index data. The format of the data stored in the buffer
is dependent on the index used, not on the index container.IndexException
- if index data of the selected type already exists or an error
occurrs while storing the data.IllegalStateException
- if the index container is not in edit
mode.public boolean canAccess()
IndexContainer
access
mode.canAccess
in interface IndexContainer
public boolean canEdit()
IndexContainer
edit
mode.canEdit
in interface IndexContainer
public void deleteIndex(int indexType) throws IndexException, IllegalStateException
IndexContainer
deleteIndex
in interface IndexContainer
indexType
- Index type of the data to delete.IndexException
- if an error occurrs while deleting the data.IllegalStateException
- if the index container is not in edit
mode.public void endEditing() throws IndexException, IllegalStateException
IndexContainer
edit
mode to access
mode.endEditing
in interface IndexContainer
IndexException
IllegalStateException
public void close()
IndexContainer
getIndexData
are invalid.close
in interface IndexContainer
Copyright © 2001-2013 the JGloss developers. All Rights Reserved.