| Modifier and Type | Class and Description |
|---|---|
private class |
DatabaseImpl.DefaultTableFinder
Normal table lookup handler, using catalog table index.
|
private class |
DatabaseImpl.FallbackTableFinder
Fallback table lookup handler, using catalog table scans.
|
static class |
DatabaseImpl.FileFormatDetails
Internal details for each FileForrmat
|
private static class |
DatabaseImpl.LinkedTableInfo
Utility class for storing linked table info
|
private static class |
DatabaseImpl.TableCache
Cache of currently in-use tables, allows re-use of existing tables.
|
private class |
DatabaseImpl.TableFinder
Utility class for handling table lookups.
|
private static class |
DatabaseImpl.TableInfo
Utility class for storing table page number and actual name.
|
private class |
DatabaseImpl.TableIterator
Table iterator for this database, unmodifiable.
|
private static class |
DatabaseImpl.WeakTableReference
WeakReference for a Table which holds the table pageNumber (for later
cache purging).
|
Database.FileFormat| Modifier and Type | Field and Description |
|---|---|
private TableImpl |
_accessControlEntries
System access control entries table (initialized on first use)
|
private boolean |
_allowAutoNumInsert
whether or not auto numbers can be directly inserted by the user
|
private java.nio.ByteBuffer |
_buffer
Buffer to hold database pages
|
private java.util.Calendar |
_calendar
Calendar for use interpreting dates/times in Columns
|
private java.nio.charset.Charset |
_charset
charset to use when handling text
|
private Table.ColumnOrder |
_columnOrder
the ordering used for table columns
|
private TableImpl |
_complexCols
System complex columns table (initialized on first use)
|
private ErrorHandler |
_dbErrorHandler
optional error handler to use when row errors are encountered
|
private java.lang.Integer |
_dbParentId
ID of the Databases system object
|
private PropertyMaps |
_dbPropMaps
core database properties
|
private java.lang.Short |
_defaultCodePage
default code page to be used for textual columns (in some dbs)
|
private ColumnImpl.SortOrder |
_defaultSortOrder
language sort order to be used for textual columns
|
private boolean |
_enforceForeignKeys
whether or not enforcement of foreign-keys is enabled
|
private java.io.File |
_file
the File of the database
|
private Database.FileFormat |
_fileFormat
the file format of the database
|
private FKEnforcer.SharedState |
_fkEnforcerSharedState
shared state used when enforcing foreign keys
|
private JetFormat |
_format
Format that the containing database is in
|
private java.util.Map<java.lang.String,Database> |
_linkedDbs
any linked databases which have been opened
|
private LinkResolver |
_linkResolver
linked table resolver
|
private java.lang.String |
_name
the simple name of the database
|
private java.util.List<byte[]> |
_newTableSIDs
SIDs to use for the ACEs added for new tables
|
private PageChannel |
_pageChannel
Reads and writes database pages
|
private PropertyMaps.Handler |
_propsHandler
handler for reading/writing properteies
|
private TableImpl |
_queries
System queries table (initialized on first use)
|
private TableImpl |
_relationships
System relationships table (initialized on first use)
|
private PropertyMaps |
_summaryPropMaps
summary properties
|
private TableImpl |
_systemCatalog
System catalog table
|
private DatabaseImpl.TableCache |
_tableCache
cache of in-use tables
|
private DatabaseImpl.TableFinder |
_tableFinder
utility table finder
|
private java.util.Map<java.lang.String,DatabaseImpl.TableInfo> |
_tableLookup
Cache map of UPPERCASE table names to page numbers containing their
definition and their stored table name (max size
MAX_CACHED_LOOKUP_TABLES).
|
private java.util.Set<java.lang.String> |
_tableNames
set of table names as stored in the mdb file, created on demand
|
private java.lang.Integer |
_tableParentId
ID of the Tables system object
|
private java.util.TimeZone |
_timeZone
timezone to use when handling dates
|
private PropertyMaps |
_userDefPropMaps
user-defined properties
|
private ColumnValidatorFactory |
_validatorFactory
factory for ColumnValidators
|
private static java.lang.String |
ACE_COL_ACM
ACE table column name of the actual access control entry
|
private static java.lang.String |
ACE_COL_F_INHERITABLE
ACE table column name of the inheritable attributes flag
|
private static java.lang.String |
ACE_COL_OBJECT_ID
ACE table column name of the relevant objectId
|
private static java.lang.String |
ACE_COL_SID
ACE table column name of the relevant userId
|
(package private) static int |
ALT_SYSTEM_OBJECT_FLAG
this object is another type of "system" object
|
(package private) static boolean |
BROKEN_NIO
whether or not this jvm has "broken" nio support
|
private static java.lang.String |
CAT_COL_DATABASE
System catalog column name of the remote database
|
private static java.lang.String |
CAT_COL_DATE_CREATE
System catalog column name of the date a system object was created
|
private static java.lang.String |
CAT_COL_DATE_UPDATE
System catalog column name of the date a system object was updated
|
private static java.lang.String |
CAT_COL_FLAGS
System catalog column name of the flags column
|
private static java.lang.String |
CAT_COL_FOREIGN_NAME
System catalog column name of the remote table name
|
private static java.lang.String |
CAT_COL_ID
System catalog column name of the page on which system object definitions
are stored
|
private static java.lang.String |
CAT_COL_NAME
System catalog column name of the name of a system object
|
private static java.lang.String |
CAT_COL_OWNER |
private static java.lang.String |
CAT_COL_PARENT_ID
System catalog column name of a system object's parent's id
|
(package private) static java.lang.String |
CAT_COL_PROPS
System catalog column name of the properties column
|
private static java.lang.String |
CAT_COL_TYPE
System catalog column name of the type of a system object
|
private static int |
DB_PARENT_ID
top-level parentid for a database
|
static java.lang.String |
DEFAULT_RESOURCE_PATH
the default value for the resource path used to load classpath
resources.
|
private static java.util.Map<Database.FileFormat,DatabaseImpl.FileFormatDetails> |
FILE_FORMAT_DETAILS
additional internal details about each FileFormat
|
static int |
HIDDEN_OBJECT_FLAG
this object is hidden
|
private static java.util.regex.Pattern |
INVALID_IDENTIFIER_CHARS
regex matching characters which are invalid in identifier names
|
private static org.apache.commons.logging.Log |
LOG |
private static int |
MAX_CACHED_LOOKUP_TABLES
max number of table lookups to cache
|
private static long |
MAX_EMPTYDB_SIZE
the maximum size of any of the included "empty db" resources
|
private static java.lang.String |
OBJECT_NAME_DB_PROPS
Name of the main database properties object
|
private static java.lang.String |
OBJECT_NAME_SUMMARY_PROPS
Name of the summary properties object
|
private static java.lang.String |
OBJECT_NAME_USERDEF_PROPS
Name of the user-defined properties object
|
private static int |
PAGE_SYSTEM_CATALOG
System catalog always lives on page 2
|
private static java.lang.String |
REL_COL_COLUMN_COUNT
Relationship table column name of the column count
|
private static java.lang.String |
REL_COL_COLUMN_INDEX
Relationship table column name of the index of the columns
|
private static java.lang.String |
REL_COL_FLAGS
Relationship table column name of the flags
|
private static java.lang.String |
REL_COL_FROM_COLUMN
Relationship table column name of the "from" column name
|
private static java.lang.String |
REL_COL_FROM_TABLE
Relationship table column name of the "from" table name
|
private static java.lang.String |
REL_COL_NAME
Relationship table column name of the relationship
|
private static java.lang.String |
REL_COL_TO_COLUMN
Relationship table column name of the "to" column name
|
private static java.lang.String |
REL_COL_TO_TABLE
Relationship table column name of the "to" table name
|
(package private) static java.lang.String |
RESOURCE_PATH
the resource path to be used when loading classpath resources
|
static java.lang.String |
RO_CHANNEL_MODE
read-only channel access mode
|
static java.lang.String |
RW_CHANNEL_MODE
read/write channel access mode
|
private static byte[] |
SYS_DEFAULT_SID
this is the default "userId" used if we cannot find existing info.
|
private static java.lang.Integer |
SYS_FULL_ACCESS_ACM
this is the access control bit field for created tables.
|
private static java.util.Collection<java.lang.String> |
SYSTEM_CATALOG_COLUMNS
the columns to read when reading system catalog normally
|
private static java.util.Collection<java.lang.String> |
SYSTEM_CATALOG_PROPS_COLUMNS
the columns to read when getting object propertyes
|
private static java.util.Collection<java.lang.String> |
SYSTEM_CATALOG_TABLE_DETAIL_COLUMNS
the columns to read when finding table details
|
(package private) static int |
SYSTEM_OBJECT_FLAG
this object is a "system" object
|
(package private) static int |
SYSTEM_OBJECT_FLAGS
all flags which seem to indicate some type of system object
|
private static java.lang.String |
SYSTEM_OBJECT_NAME_DATABASES
Name of the system object that is the parent of all databases
|
private static java.lang.String |
SYSTEM_OBJECT_NAME_RELATIONSHIPS
Name of the system object that is the parent of all relationships
|
private static java.lang.String |
SYSTEM_OBJECT_NAME_TABLES
Name of the system object that is the parent of all tables
|
private static java.lang.String |
TABLE_SYSTEM_ACES
Name of the table that contains system access control entries
|
private static java.lang.String |
TABLE_SYSTEM_CATALOG
Name of the system catalog
|
private static java.lang.String |
TABLE_SYSTEM_COMPLEX_COLS
Name of the table that contains complex type information
|
private static java.lang.String |
TABLE_SYSTEM_QUERIES
Name of the table that contains queries
|
private static java.lang.String |
TABLE_SYSTEM_RELATIONSHIPS
Name of the table that contains table relationships
|
private static java.lang.Short |
TYPE_LINKED_TABLE
System object type for linked table definitions
|
private static java.lang.Short |
TYPE_QUERY
System object type for query definitions
|
(package private) static java.lang.Short |
TYPE_TABLE
System object type for table definitions
|
ALLOW_AUTONUM_INSERT_PROPERTY, BROKEN_NIO_PROPERTY, CHARSET_PROPERTY_PREFIX, COLUMN_ORDER_PROPERTY, DEFAULT_AUTO_SYNC, DEFAULT_COLUMN_ORDER, FK_ENFORCE_PROPERTY, RESOURCE_PATH_PROPERTY, TIMEZONE_PROPERTY| Modifier | Constructor and Description |
|---|---|
protected |
DatabaseImpl(java.io.File file,
java.nio.channels.FileChannel channel,
boolean closeChannel,
boolean autoSync,
Database.FileFormat fileFormat,
java.nio.charset.Charset charset,
java.util.TimeZone timeZone,
CodecProvider provider)
Create a new database by reading it in from a FileChannel.
|
| Modifier and Type | Method and Description |
|---|---|
private static void |
addFileFormatDetails(Database.FileFormat fileFormat,
java.lang.String emptyFileName,
JetFormat format) |
(package private) void |
addNewTable(java.lang.String name,
int tdefPageNumber,
java.lang.Short type,
java.lang.String linkedDbName,
java.lang.String linkedTableName)
Adds a newly created table to the relevant internal database structures.
|
private void |
addTable(java.lang.String tableName,
java.lang.Integer pageNumber,
java.lang.Short type,
java.lang.String linkedDbName,
java.lang.String linkedTableName)
Adds a table to the _tableLookup and resets the _tableNames set
|
private void |
addToAccessControlEntries(int pageNumber)
Add a new table to the system's access control entries
|
private void |
addToSystemCatalog(java.lang.String name,
int pageNumber,
java.lang.Short type,
java.lang.String linkedDbName,
java.lang.String linkedTableName)
Add a new table to the system catalog
|
void |
close()
Close the database file (and any linked databases).
|
private void |
collectRelationships(Cursor cursor,
TableImpl fromTable,
TableImpl toTable,
java.util.List<Relationship> relationships,
boolean includeSystemTables)
Finds the relationships matching the given from and to tables from the
given cursor and adds them to the given list.
|
static DatabaseImpl |
create(Database.FileFormat fileFormat,
java.io.File mdbFile,
java.nio.channels.FileChannel channel,
boolean autoSync,
java.nio.charset.Charset charset,
java.util.TimeZone timeZone)
Create a new Database for the given fileFormat
|
private Cursor |
createCursorWithOptionalIndex(TableImpl table,
java.lang.String colName,
java.lang.Object colValue)
Creates a Cursor restricted to the given column value if possible (using
an existing index), otherwise a simple table cursor.
|
void |
createLinkedTable(java.lang.String name,
java.lang.String linkedDbName,
java.lang.String linkedTableName)
Create a new table in this database
|
void |
createTable(java.lang.String name,
java.util.List<ColumnBuilder> columns)
Create a new table in this database
|
void |
createTable(java.lang.String name,
java.util.List<ColumnBuilder> columns,
java.util.List<IndexBuilder> indexes)
Create a new table in this database
|
private static DatabaseImpl.TableInfo |
createTableInfo(java.lang.String tableName,
java.lang.Integer pageNumber,
int flags,
java.lang.Short type,
java.lang.String linkedDbName,
java.lang.String linkedTableName)
Creates a TableInfo instance appropriate for the given table data.
|
void |
flush()
Flushes any current changes to the database file (and any linked
databases) to disk.
|
TableImpl |
getAccessControlEntries() |
(package private) java.util.Calendar |
getCalendar() |
java.nio.charset.Charset |
getCharset()
Gets currently configured Charset (always non-
null). |
Table.ColumnOrder |
getColumnOrder()
Gets currently configured
Table.ColumnOrder (always non-null). |
ColumnValidatorFactory |
getColumnValidatorFactory()
Gets currently configured ColumnValidatorFactory (always non-
null). |
java.lang.String |
getDatabasePassword() |
PropertyMap |
getDatabaseProperties() |
static boolean |
getDefaultAllowAutoNumberInsert()
Returns the default allow auto number insert policy.
|
static java.nio.charset.Charset |
getDefaultCharset(JetFormat format)
Returns the default Charset for the given JetFormat.
|
short |
getDefaultCodePage() |
static Table.ColumnOrder |
getDefaultColumnOrder()
Returns the default Table.ColumnOrder.
|
static boolean |
getDefaultEnforceForeignKeys()
Returns the default enforce foreign-keys policy.
|
ColumnImpl.SortOrder |
getDefaultSortOrder() |
static java.util.TimeZone |
getDefaultTimeZone()
Returns the default TimeZone.
|
ErrorHandler |
getErrorHandler()
Gets the currently configured ErrorHandler (always non-
null). |
java.io.File |
getFile()
Returns the File underlying this Database
|
Database.FileFormat |
getFileFormat()
Returns the FileFormat of this database (which may involve inspecting the
database itself).
|
static DatabaseImpl.FileFormatDetails |
getFileFormatDetails(Database.FileFormat fileFormat) |
(package private) FKEnforcer.SharedState |
getFKEnforcerSharedState() |
JetFormat |
getFormat() |
java.util.Map<java.lang.String,Database> |
getLinkedDatabases()
Returns an unmodifiable view of the currently loaded linked databases,
mapped from the linked database file name to the linked database.
|
LinkResolver |
getLinkResolver()
Gets the currently configured LinkResolver (always non-
null). |
java.lang.String |
getName() |
private static java.lang.String |
getName(java.io.File file) |
PageChannel |
getPageChannel() |
(package private) static byte[] |
getPasswordMask(java.nio.ByteBuffer buffer,
JetFormat format)
Returns the password mask retrieved from the given header page and
format, or
null if this format does not use a password mask. |
private PropertyMaps |
getPropertiesForDbObject(java.lang.String dbName) |
PropertyMaps |
getPropertiesForObject(int objectId) |
private PropertyMaps.Handler |
getPropsHandler() |
java.util.List<Query> |
getQueries()
Finds all the queries in the database.
|
java.util.List<Relationship> |
getRelationships()
Finds all the relationships in the database in non-system tables.
|
java.util.List<Relationship> |
getRelationships(Table table)
Finds all the relationships in the database for the given table.
|
java.util.List<Relationship> |
getRelationships(TableImpl table1,
TableImpl table2) |
java.util.List<Relationship> |
getRelationships(Table table1,
Table table2)
Finds all the relationships in the database between the given tables.
|
private java.util.List<Relationship> |
getRelationshipsImpl(TableImpl table1,
TableImpl table2,
boolean includeSystemTables) |
private TableImpl |
getRequiredSystemTable(java.lang.String tableName) |
(package private) static java.io.InputStream |
getResourceAsStream(java.lang.String resourceName) |
PropertyMap |
getSummaryProperties() |
TableImpl |
getSystemCatalog() |
TableImpl |
getSystemComplexColumns() |
java.util.List<Relationship> |
getSystemRelationships()
Finds all the relationships in the database, including system
tables.
|
TableImpl |
getSystemTable(java.lang.String tableName)
Returns a reference to any available table in this access
database, including system tables.
|
java.util.Set<java.lang.String> |
getSystemTableNames() |
TableImpl |
getTable(int tableDefPageNumber) |
TableImpl |
getTable(java.lang.String name) |
private TableImpl |
getTable(java.lang.String name,
boolean includeSystemTables) |
java.util.Set<java.lang.String> |
getTableNames() |
private java.util.Set<java.lang.String> |
getTableNames(boolean normalTables,
boolean systemTables,
boolean linkedTables) |
java.util.TimeZone |
getTimeZone()
Gets currently configured TimeZone (always non-
null). |
PropertyMap |
getUserDefinedProperties() |
private void |
initNewTableSIDs()
Determines the collection of SIDs which need to be added to new tables.
|
private void |
initRootPageInfo()
Reads various config info from the db page 0.
|
boolean |
isAllowAutoNumberInsert()
Gets current allow auto number insert policy.
|
static boolean |
isBlank(java.lang.String name)
Returns
true if the given string is null or all blank
space, false otherwise. |
boolean |
isEnforceForeignKeys()
Gets current foreign-key enforcement policy.
|
boolean |
isLinkedTable(Table table)
Returns
true if this Database links to the given Table, false otherwise. |
private static boolean |
isSystemObject(int flags) |
private static boolean |
isTableType(java.lang.Short objType) |
java.util.Iterator<Table> |
iterator() |
java.util.Iterator<Table> |
iterator(TableIterableBuilder builder) |
private DatabaseImpl.TableInfo |
lookupTable(java.lang.String tableName) |
private boolean |
matchesLinkedTable(Table table,
java.lang.String linkedTableName,
java.lang.String linkedDbName) |
TableIterableBuilder |
newIterable()
Convenience method for constructing a new TableIterableBuilder for this
cursor.
|
static DatabaseImpl |
open(java.io.File mdbFile,
boolean readOnly,
java.nio.channels.FileChannel channel,
boolean autoSync,
java.nio.charset.Charset charset,
java.util.TimeZone timeZone,
CodecProvider provider)
Open an existing Database.
|
(package private) static java.nio.channels.FileChannel |
openChannel(java.io.File mdbFile,
boolean readOnly)
Package visible only to support unit tests via DatabaseTest.openChannel().
|
PropertyMaps |
readProperties(byte[] propsBytes,
int objectId,
RowIdImpl rowId) |
private void |
readSystemCatalog()
Read the system catalog
|
private TableImpl |
readTable(java.lang.String name,
int pageNumber,
int flags)
Reads a table with the given name from the given pageNumber.
|
private void |
releaseSharedBuffer(java.nio.ByteBuffer buffer)
Relinquishes use of a page ByteBuffer returned by
takeSharedBuffer(). |
void |
setAllowAutoNumberInsert(java.lang.Boolean allowAutoNumInsert)
Sets the new auto number insert policy for the database (unless
overridden at the Table level).
|
void |
setCharset(java.nio.charset.Charset newCharset)
Sets a new Charset.
|
void |
setColumnOrder(Table.ColumnOrder newColumnOrder)
Sets a new Table.ColumnOrder.
|
void |
setColumnValidatorFactory(ColumnValidatorFactory newFactory)
Sets a new ColumnValidatorFactory.
|
void |
setEnforceForeignKeys(java.lang.Boolean newEnforceForeignKeys)
Sets a new foreign-key enforcement policy.
|
void |
setErrorHandler(ErrorHandler newErrorHandler)
Sets a new ErrorHandler.
|
void |
setLinkResolver(LinkResolver newLinkResolver)
Sets a new LinkResolver.
|
void |
setTimeZone(java.util.TimeZone newTimeZone)
Sets a new TimeZone.
|
private java.nio.ByteBuffer |
takeSharedBuffer() |
static java.lang.String |
toLookupName(java.lang.String name) |
java.lang.String |
toString() |
private static void |
transferFrom(java.nio.channels.FileChannel channel,
java.io.InputStream in)
Copies the given InputStream to the given channel using the most
efficient means possible.
|
static void |
validateIdentifierName(java.lang.String name,
int maxLength,
java.lang.String identifierType)
Validates an identifier name.
|
private static void |
validateName(java.lang.String name,
int maxLength,
java.lang.String nameType)
Validates a name.
|
private java.lang.String |
withErrorContext(java.lang.String msg) |
private static java.lang.String |
withErrorContext(java.lang.String msg,
java.lang.String dbName) |
private static final org.apache.commons.logging.Log LOG
private static final byte[] SYS_DEFAULT_SID
public static final java.lang.String DEFAULT_RESOURCE_PATH
static final java.lang.String RESOURCE_PATH
static final boolean BROKEN_NIO
private static final java.util.Map<Database.FileFormat,DatabaseImpl.FileFormatDetails> FILE_FORMAT_DETAILS
private static final int PAGE_SYSTEM_CATALOG
private static final java.lang.String TABLE_SYSTEM_CATALOG
private static final java.lang.Integer SYS_FULL_ACCESS_ACM
private static final java.lang.String ACE_COL_ACM
private static final java.lang.String ACE_COL_F_INHERITABLE
private static final java.lang.String ACE_COL_OBJECT_ID
private static final java.lang.String ACE_COL_SID
private static final java.lang.String REL_COL_COLUMN_COUNT
private static final java.lang.String REL_COL_FLAGS
private static final java.lang.String REL_COL_COLUMN_INDEX
private static final java.lang.String REL_COL_TO_COLUMN
private static final java.lang.String REL_COL_TO_TABLE
private static final java.lang.String REL_COL_FROM_COLUMN
private static final java.lang.String REL_COL_FROM_TABLE
private static final java.lang.String REL_COL_NAME
private static final java.lang.String CAT_COL_ID
private static final java.lang.String CAT_COL_NAME
private static final java.lang.String CAT_COL_OWNER
private static final java.lang.String CAT_COL_PARENT_ID
private static final java.lang.String CAT_COL_TYPE
private static final java.lang.String CAT_COL_DATE_CREATE
private static final java.lang.String CAT_COL_DATE_UPDATE
private static final java.lang.String CAT_COL_FLAGS
static final java.lang.String CAT_COL_PROPS
private static final java.lang.String CAT_COL_DATABASE
private static final java.lang.String CAT_COL_FOREIGN_NAME
private static final int DB_PARENT_ID
private static final long MAX_EMPTYDB_SIZE
static final int SYSTEM_OBJECT_FLAG
static final int ALT_SYSTEM_OBJECT_FLAG
public static final int HIDDEN_OBJECT_FLAG
static final int SYSTEM_OBJECT_FLAGS
public static final java.lang.String RO_CHANNEL_MODE
public static final java.lang.String RW_CHANNEL_MODE
private static final java.lang.String SYSTEM_OBJECT_NAME_TABLES
private static final java.lang.String SYSTEM_OBJECT_NAME_DATABASES
private static final java.lang.String SYSTEM_OBJECT_NAME_RELATIONSHIPS
private static final java.lang.String TABLE_SYSTEM_ACES
private static final java.lang.String TABLE_SYSTEM_RELATIONSHIPS
private static final java.lang.String TABLE_SYSTEM_QUERIES
private static final java.lang.String TABLE_SYSTEM_COMPLEX_COLS
private static final java.lang.String OBJECT_NAME_DB_PROPS
private static final java.lang.String OBJECT_NAME_SUMMARY_PROPS
private static final java.lang.String OBJECT_NAME_USERDEF_PROPS
static final java.lang.Short TYPE_TABLE
private static final java.lang.Short TYPE_QUERY
private static final java.lang.Short TYPE_LINKED_TABLE
private static final int MAX_CACHED_LOOKUP_TABLES
private static java.util.Collection<java.lang.String> SYSTEM_CATALOG_COLUMNS
private static java.util.Collection<java.lang.String> SYSTEM_CATALOG_TABLE_DETAIL_COLUMNS
private static java.util.Collection<java.lang.String> SYSTEM_CATALOG_PROPS_COLUMNS
private static final java.util.regex.Pattern INVALID_IDENTIFIER_CHARS
private final java.io.File _file
private final java.lang.String _name
private java.nio.ByteBuffer _buffer
private java.lang.Integer _tableParentId
private final JetFormat _format
private final java.util.Map<java.lang.String,DatabaseImpl.TableInfo> _tableLookup
private java.util.Set<java.lang.String> _tableNames
private final PageChannel _pageChannel
private TableImpl _systemCatalog
private DatabaseImpl.TableFinder _tableFinder
private TableImpl _accessControlEntries
private TableImpl _relationships
private TableImpl _queries
private TableImpl _complexCols
private final java.util.List<byte[]> _newTableSIDs
private ErrorHandler _dbErrorHandler
private Database.FileFormat _fileFormat
private java.nio.charset.Charset _charset
private java.util.TimeZone _timeZone
private ColumnImpl.SortOrder _defaultSortOrder
private java.lang.Short _defaultCodePage
private Table.ColumnOrder _columnOrder
private boolean _enforceForeignKeys
private boolean _allowAutoNumInsert
private ColumnValidatorFactory _validatorFactory
private final DatabaseImpl.TableCache _tableCache
private PropertyMaps.Handler _propsHandler
private java.lang.Integer _dbParentId
private PropertyMaps _dbPropMaps
private PropertyMaps _summaryPropMaps
private PropertyMaps _userDefPropMaps
private LinkResolver _linkResolver
private java.util.Map<java.lang.String,Database> _linkedDbs
private final FKEnforcer.SharedState _fkEnforcerSharedState
private java.util.Calendar _calendar
protected DatabaseImpl(java.io.File file,
java.nio.channels.FileChannel channel,
boolean closeChannel,
boolean autoSync,
Database.FileFormat fileFormat,
java.nio.charset.Charset charset,
java.util.TimeZone timeZone,
CodecProvider provider)
throws java.io.IOException
file - the File to which the channel is connectedchannel - File channel of the database. This needs to be a
FileChannel instead of a ReadableByteChannel because we need to
randomly jump around to various points in the file.autoSync - whether or not to enable auto-syncing on write. if
true, writes will be immediately flushed to disk.
This leaves the database in a (fairly) consistent state
on each write, but can be very inefficient for many
updates. if false, flushing to disk happens at
the jvm's leisure, which can be much faster, but may
leave the database in an inconsistent state if failures
are encountered during writing. Writes may be flushed at
any time using flush().fileFormat - version of new database (if known)charset - Charset to use, if null, uses defaulttimeZone - TimeZone to use, if null, uses defaultjava.io.IOExceptionpublic static DatabaseImpl open(java.io.File mdbFile, boolean readOnly, java.nio.channels.FileChannel channel, boolean autoSync, java.nio.charset.Charset charset, java.util.TimeZone timeZone, CodecProvider provider) throws java.io.IOException
true, the file will be opened read-only.mdbFile - File containing the databasereadOnly - iff true, force opening file in read-only
modechannel - pre-opened FileChannel. if provided explicitly, it will
not be closed by this Database instanceautoSync - whether or not to enable auto-syncing on write. if
true, writes will be immediately flushed to disk.
This leaves the database in a (fairly) consistent state
on each write, but can be very inefficient for many
updates. if false, flushing to disk happens at
the jvm's leisure, which can be much faster, but may
leave the database in an inconsistent state if failures
are encountered during writing. Writes may be flushed at
any time using flush().charset - Charset to use, if null, uses defaulttimeZone - TimeZone to use, if null, uses defaultprovider - CodecProvider for handling page encoding/decoding, may be
null if no special encoding is necessaryjava.io.IOExceptionpublic static DatabaseImpl create(Database.FileFormat fileFormat, java.io.File mdbFile, java.nio.channels.FileChannel channel, boolean autoSync, java.nio.charset.Charset charset, java.util.TimeZone timeZone) throws java.io.IOException
fileFormat - version of new database.mdbFile - Location to write the new database to. If this file
already exists, it will be overwritten.channel - pre-opened FileChannel. if provided explicitly, it will
not be closed by this Database instanceautoSync - whether or not to enable auto-syncing on write. if
true, writes will be immediately flushed to disk.
This leaves the database in a (fairly) consistent state
on each write, but can be very inefficient for many
updates. if false, flushing to disk happens at
the jvm's leisure, which can be much faster, but may
leave the database in an inconsistent state if failures
are encountered during writing. Writes may be flushed at
any time using flush().charset - Charset to use, if null, uses defaulttimeZone - TimeZone to use, if null, uses defaultjava.io.IOExceptionstatic java.nio.channels.FileChannel openChannel(java.io.File mdbFile,
boolean readOnly)
throws java.io.FileNotFoundException
mdbFile - file to openreadOnly - true if read-onlyjava.io.FileNotFoundException - if the mode is "r" but the given file object does
not denote an existing regular file, or if the mode begins
with "rw" but the given file object does not denote
an existing, writable regular file and a new regular file of
that name cannot be created, or if some other error occurs
while opening or creating the filepublic java.io.File getFile()
Databasepublic java.lang.String getName()
public PageChannel getPageChannel()
public JetFormat getFormat()
public TableImpl getSystemCatalog()
public TableImpl getAccessControlEntries() throws java.io.IOException
java.io.IOExceptionpublic TableImpl getSystemComplexColumns() throws java.io.IOException
java.io.IOExceptionpublic ErrorHandler getErrorHandler()
Databasenull).
This will be used to handle all errors unless overridden at the Table or
Cursor level.getErrorHandler in interface Databasepublic void setErrorHandler(ErrorHandler newErrorHandler)
Databasenull, resets to the
ErrorHandler.DEFAULT.setErrorHandler in interface Databasepublic LinkResolver getLinkResolver()
Databasenull).
This will be used to handle all linked database loading.getLinkResolver in interface Databasepublic void setLinkResolver(LinkResolver newLinkResolver)
Databasenull, resets to the
LinkResolver.DEFAULT.setLinkResolver in interface Databasepublic java.util.Map<java.lang.String,Database> getLinkedDatabases()
DatabasegetLinkedDatabases in interface Databasepublic boolean isLinkedTable(Table table) throws java.io.IOException
Databasetrue if this Database links to the given Table, false otherwise.isLinkedTable in interface Databasejava.io.IOExceptionprivate boolean matchesLinkedTable(Table table, java.lang.String linkedTableName, java.lang.String linkedDbName)
public java.util.TimeZone getTimeZone()
Databasenull).getTimeZone in interface Databasepublic void setTimeZone(java.util.TimeZone newTimeZone)
Databasenull, resets to the default value.setTimeZone in interface Databasepublic java.nio.charset.Charset getCharset()
Databasenull).getCharset in interface Databasepublic void setCharset(java.nio.charset.Charset newCharset)
Databasenull, resets to the default value.setCharset in interface Databasepublic Table.ColumnOrder getColumnOrder()
DatabaseTable.ColumnOrder (always non-null).getColumnOrder in interface Databasepublic void setColumnOrder(Table.ColumnOrder newColumnOrder)
Databasenull, resets to the default value.setColumnOrder in interface Databasepublic boolean isEnforceForeignKeys()
DatabaseisEnforceForeignKeys in interface Databasepublic void setEnforceForeignKeys(java.lang.Boolean newEnforceForeignKeys)
Databasenull, resets to
the default value.setEnforceForeignKeys in interface Databasepublic boolean isAllowAutoNumberInsert()
Databasetrue allows the caller to optionally set the value explicitly when
adding or updating rows (if a value is not provided, it will still be
handled internally by the Table). This value can be set database-wide
using Database.setAllowAutoNumberInsert(java.lang.Boolean) and/or on a per-table basis using
Table.setAllowAutoNumberInsert(java.lang.Boolean) (and/or on a jvm-wide using the
Database.ALLOW_AUTONUM_INSERT_PROPERTY system property). Note that
enabling this feature should be done with care to reduce the
chances of screwing up the database.isAllowAutoNumberInsert in interface Databasepublic void setAllowAutoNumberInsert(java.lang.Boolean allowAutoNumInsert)
Databasenull, resets to the default
value.setAllowAutoNumberInsert in interface Databasepublic ColumnValidatorFactory getColumnValidatorFactory()
Databasenull).getColumnValidatorFactory in interface Databasepublic void setColumnValidatorFactory(ColumnValidatorFactory newFactory)
Databasenull, resets to the
default value. The configured ColumnValidatorFactory will be used to
create ColumnValidator instances on any user tables loaded from
this point onward (this will not be used for system tables).setColumnValidatorFactory in interface DatabaseFKEnforcer.SharedState getFKEnforcerSharedState()
java.util.Calendar getCalendar()
private PropertyMaps.Handler getPropsHandler()
public Database.FileFormat getFileFormat() throws java.io.IOException
DatabasegetFileFormat in interface Databasejava.io.IOExceptionprivate java.nio.ByteBuffer takeSharedBuffer()
releaseSharedBuffer(java.nio.ByteBuffer) when no longer in useprivate void releaseSharedBuffer(java.nio.ByteBuffer buffer)
takeSharedBuffer().public ColumnImpl.SortOrder getDefaultSortOrder() throws java.io.IOException
java.io.IOExceptionpublic short getDefaultCodePage()
throws java.io.IOException
java.io.IOExceptionprivate void initRootPageInfo()
throws java.io.IOException
java.io.IOExceptionpublic PropertyMaps readProperties(byte[] propsBytes, int objectId, RowIdImpl rowId) throws java.io.IOException
null result).java.io.IOExceptionprivate void readSystemCatalog()
throws java.io.IOException
java.io.IOExceptionpublic java.util.Set<java.lang.String> getTableNames()
throws java.io.IOException
getTableNames in interface Databasejava.io.IOExceptionpublic java.util.Set<java.lang.String> getSystemTableNames()
throws java.io.IOException
getSystemTableNames in interface DatabaseDatabase.getSystemTable(java.lang.String).
Extreme care should be taken if modifying these tables
directly!.java.io.IOExceptionprivate java.util.Set<java.lang.String> getTableNames(boolean normalTables,
boolean systemTables,
boolean linkedTables)
throws java.io.IOException
java.io.IOExceptionpublic java.util.Iterator<Table> iterator()
public java.util.Iterator<Table> iterator(TableIterableBuilder builder)
public TableIterableBuilder newIterable()
DatabasenewIterable in interface Databasepublic TableImpl getTable(java.lang.String name) throws java.io.IOException
public TableImpl getTable(int tableDefPageNumber) throws java.io.IOException
tableDefPageNumber - the page number of a table definitionjava.io.IOExceptionprivate TableImpl getTable(java.lang.String name, boolean includeSystemTables) throws java.io.IOException
name - Table nameincludeSystemTables - whether to consider returning a system tablejava.io.IOExceptionpublic void createTable(java.lang.String name,
java.util.List<ColumnBuilder> columns)
throws java.io.IOException
name - Name of the table to createcolumns - List of Columns in the tablejava.io.IOExceptionpublic void createTable(java.lang.String name,
java.util.List<ColumnBuilder> columns,
java.util.List<IndexBuilder> indexes)
throws java.io.IOException
name - Name of the table to createcolumns - List of Columns in the tableindexes - List of IndexBuilders describing indexes for the tablejava.io.IOExceptionpublic void createLinkedTable(java.lang.String name,
java.lang.String linkedDbName,
java.lang.String linkedTableName)
throws java.io.IOException
DatabasecreateLinkedTable in interface Databasename - Name of the table to create in this databaselinkedDbName - path to the linked databaselinkedTableName - name of the table in the linked databasejava.io.IOExceptionvoid addNewTable(java.lang.String name,
int tdefPageNumber,
java.lang.Short type,
java.lang.String linkedDbName,
java.lang.String linkedTableName)
throws java.io.IOException
java.io.IOExceptionpublic java.util.List<Relationship> getRelationships(Table table1, Table table2) throws java.io.IOException
DatabasegetRelationships in interface Databasejava.io.IOExceptionpublic java.util.List<Relationship> getRelationships(TableImpl table1, TableImpl table2) throws java.io.IOException
java.io.IOExceptionpublic java.util.List<Relationship> getRelationships(Table table) throws java.io.IOException
DatabasegetRelationships in interface Databasejava.io.IOExceptionpublic java.util.List<Relationship> getRelationships() throws java.io.IOException
DatabasegetRelationships in interface Databasejava.io.IOExceptionpublic java.util.List<Relationship> getSystemRelationships() throws java.io.IOException
DatabasegetSystemRelationships in interface Databasejava.io.IOExceptionprivate java.util.List<Relationship> getRelationshipsImpl(TableImpl table1, TableImpl table2, boolean includeSystemTables) throws java.io.IOException
java.io.IOExceptionpublic java.util.List<Query> getQueries() throws java.io.IOException
DatabasegetQueries in interface Databasejava.io.IOExceptionpublic TableImpl getSystemTable(java.lang.String tableName) throws java.io.IOException
DatabaseWarning, this method is not designed for common use, only for the occassional time when access to a system table is necessary. Messing with system tables can strip the paint off your house and give your whole family a permanent, orange afro. You have been warned.
getSystemTable in interface DatabasetableName - Table name, may be a system tablenull if it doesn't existjava.io.IOExceptionprivate TableImpl getRequiredSystemTable(java.lang.String tableName) throws java.io.IOException
java.io.IOExceptionpublic PropertyMap getDatabaseProperties() throws java.io.IOException
getDatabaseProperties in interface Databasejava.io.IOExceptionpublic PropertyMap getSummaryProperties() throws java.io.IOException
getSummaryProperties in interface Databasejava.io.IOExceptionpublic PropertyMap getUserDefinedProperties() throws java.io.IOException
getUserDefinedProperties in interface Databasejava.io.IOExceptionpublic PropertyMaps getPropertiesForObject(int objectId) throws java.io.IOException
java.io.IOExceptionprivate PropertyMaps getPropertiesForDbObject(java.lang.String dbName) throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getDatabasePassword()
throws java.io.IOException
getDatabasePassword in interface Databasenull if none set.java.io.IOExceptionprivate void collectRelationships(Cursor cursor, TableImpl fromTable, TableImpl toTable, java.util.List<Relationship> relationships, boolean includeSystemTables) throws java.io.IOException
java.io.IOExceptionprivate void addToSystemCatalog(java.lang.String name,
int pageNumber,
java.lang.Short type,
java.lang.String linkedDbName,
java.lang.String linkedTableName)
throws java.io.IOException
name - Table namepageNumber - Page number that contains the table definitionjava.io.IOExceptionprivate void addToAccessControlEntries(int pageNumber)
throws java.io.IOException
pageNumber - Page number that contains the table definitionjava.io.IOExceptionprivate void initNewTableSIDs()
throws java.io.IOException
java.io.IOExceptionprivate TableImpl readTable(java.lang.String name, int pageNumber, int flags) throws java.io.IOException
java.io.IOExceptionprivate Cursor createCursorWithOptionalIndex(TableImpl table, java.lang.String colName, java.lang.Object colValue) throws java.io.IOException
java.io.IOExceptionpublic void flush()
throws java.io.IOException
Databasepublic void close()
throws java.io.IOException
Databasepublic static void validateIdentifierName(java.lang.String name,
int maxLength,
java.lang.String identifierType)
private static void validateName(java.lang.String name,
int maxLength,
java.lang.String nameType)
public static boolean isBlank(java.lang.String name)
true if the given string is null or all blank
space, false otherwise.public java.lang.String toString()
toString in class java.lang.Objectprivate void addTable(java.lang.String tableName,
java.lang.Integer pageNumber,
java.lang.Short type,
java.lang.String linkedDbName,
java.lang.String linkedTableName)
private static DatabaseImpl.TableInfo createTableInfo(java.lang.String tableName, java.lang.Integer pageNumber, int flags, java.lang.Short type, java.lang.String linkedDbName, java.lang.String linkedTableName)
private DatabaseImpl.TableInfo lookupTable(java.lang.String tableName) throws java.io.IOException
java.io.IOExceptionpublic static java.lang.String toLookupName(java.lang.String name)
private static boolean isSystemObject(int flags)
true if the given flags indicate that an object is some
sort of system object, false otherwise.public static java.util.TimeZone getDefaultTimeZone()
TimeZone.getDefault(), but can be
overridden using the system property
"com.healthmarketscience.jackcess.timeZone".public static java.nio.charset.Charset getDefaultCharset(JetFormat format)
"com.healthmarketscience.jackcess.charset.VERSION_3".public static Table.ColumnOrder getDefaultColumnOrder()
Database.DEFAULT_COLUMN_ORDER, but can be overridden using the system
property "com.healthmarketscience.jackcess.columnOrder".public static boolean getDefaultEnforceForeignKeys()
true, but can be overridden using the system
property "com.healthmarketscience.jackcess.enforceForeignKeys".public static boolean getDefaultAllowAutoNumberInsert()
false, but can be overridden using the system
property "com.healthmarketscience.jackcess.allowAutoNumberInsert".private static void transferFrom(java.nio.channels.FileChannel channel,
java.io.InputStream in)
throws java.io.IOException
java.io.IOExceptionstatic byte[] getPasswordMask(java.nio.ByteBuffer buffer,
JetFormat format)
null if this format does not use a password mask.static java.io.InputStream getResourceAsStream(java.lang.String resourceName)
throws java.io.IOException
java.io.IOExceptionprivate static boolean isTableType(java.lang.Short objType)
public static DatabaseImpl.FileFormatDetails getFileFormatDetails(Database.FileFormat fileFormat)
private static void addFileFormatDetails(Database.FileFormat fileFormat, java.lang.String emptyFileName, JetFormat format)
private static java.lang.String getName(java.io.File file)
private java.lang.String withErrorContext(java.lang.String msg)
private static java.lang.String withErrorContext(java.lang.String msg,
java.lang.String dbName)