Class Settings
The settings of an ACDP WR database are stored in the layout file
which is identical to the main file passed as first argument to
the Database.open(java.nio.file.Path, int, boolean, acdp.design.ICipherFactory)
and CustomDatabase.open(Path, int, boolean, ICipherFactory, int, CustomTable...)
methods.
The settings can also be obtained by a call to the Database.info()
method, however, this requires the database to be opened and the settings
can't be modified that way.
On the other hand, the meaning of a particular setting may be better
explained in the method descriptions of the Information.DatabaseInfo
, Information.TableInfo
, Information.WRStoreInfo
and Information.ColumnInfo
interfaces rather
than in the method descriptions of this class.
Editing the layout file manually or with the help of the Layout
class carries the risk of corrupting the layout file and can even lead to
data integrity being destroyed.
This class allows you to safely modify some settings without corrupting the
layout file and without the risk of harming data integrity.
The modifications take effect as soon as the database is opened.
Don't forget to invoke the save()
method to save your modifications
to the layout file.
You may want to apply method chaining like this:
new Settings(Paths.get("layoutFile")).setVersion("7.0").setConsistencyNumber(4).save();The methods of this class assume that the layout file is such that the database can be opened without throwing an exception.
Check the Refactor
class in case you miss a method.
- Author:
- Beat Hörmann
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal String
Returns the cipher challenge, if any is specified in the layout.final String[]
getColumnNames
(String tableName) Returns the names of the columns of the specified table.final int
Returns the consistency number.final String
getFlDataFile
(String tableName) Returns the path (including the file name) of the specified table's FL data file.final boolean
Indicates whether "force write on commit" is turned on or off.final String
getName()
Returns the name of the database.final int
getNobsOutrowPtr
(String tableName) Returns the number of bytes required for referencing any outrow data in the specified table.final int
getNobsRefCount
(String tableName) Returns the number of bytes used by the reference counter in the header of a row in the specified table.final int
getNobsRowRef
(String tableName) Returns the number of bytes required for referencing a row in the specified table.final String
Returns the path (including the file name) of the database's recorder file.final String
getRefdTable
(String tableName, String columnName) Returns the name of the table referenced by the specified column, provided that the column is ofRefType
orArrayOfRefType
.final String[]
Returns the names of the tables in the database.final String
getTypeDesc
(String tableName, String columnName) Returns the type descriptor of the specified column.final String
getTypeFactoryClassName
(String tableName, String columnName) Returns the type factory class name of the specified column, if any is specified in the column layout.final String
getTypeFactoryClasspath
(String tableName, String columnName) Returns the extra classpath of the specified column's type factory, if any is specified in the column layout.final String
Returns the version of the database, if any is specified in the layout.final String
getVlDataFile
(String tableName) Returns the path (including the file name) of the specified table's VL data file, provided that the path is specified in the table layout.final Settings
save()
Saves the settings.final Settings
setColumnName
(String tableName, String columnName, String value) Sets the name of the specified column to the specified new value.final Settings
setConsistencyNumber
(int value) Sets the consistency number to the specified value.final Settings
setFlDataFile
(String tableName, String value) Sets the path (including the file name) of the specified table's FL data file to the specified value.final Settings
setForceWriteCommit
(boolean value) Sets the value of the "force write on commit" database property.final Settings
Sets the name of the database to the specified value.final Settings
setRecFile
(String value) Sets the path (including the file name) of the database's recorder file to the specified value.final Settings
setTableName
(String tableName, String value) Sets the name of the specified table to the specified new value.final Settings
setTypeFactoryClasspath
(String tableName, String columnName, String value) Sets the extra classpath of the specified column's type factory to the specified value.final Settings
setVersion
(String value) Sets the version of the database to the specified value.final Settings
setVlDataFile
(String tableName, String value) Sets the path (including the file name) of the specified table's VL data file to the specified value, provided that the path is specified in the table layout.
-
Constructor Details
-
Settings
Creates a database settings object based on the layout saved in the specified file.- Parameters:
layoutFile
- The layout file.- Throws:
NullPointerException
- IflayoutFile
isnull
.IOFailureException
- If the specified file does not exist or if another I/O error occurs.
-
-
Method Details
-
getName
Returns the name of the database.- Returns:
- The name of the database.
-
setName
Sets the name of the database to the specified value.- Parameters:
value
- The new name of the database, not allowed to benull
and not allowed to be an empty string.- Returns:
- This object.
- Throws:
IllegalArgumentException
- Ifvalue
isnull
or an empty string.
-
getVersion
Returns the version of the database, if any is specified in the layout.- Returns:
- The version of the database or
null
if this database has no version.
-
setVersion
Sets the version of the database to the specified value.If the layout already contains a version number and the specified value is
null
or an empty string then the version field is removed from the layout.- Parameters:
value
- The version of the database.- Returns:
- This object.
-
getConsistencyNumber
public final int getConsistencyNumber()Returns the consistency number.- Returns:
- The consistency number.
-
setConsistencyNumber
Sets the consistency number to the specified value.- Parameters:
value
- The new consistency number.- Returns:
- This object.
-
getCipherChallenge
Returns the cipher challenge, if any is specified in the layout.- Returns:
- The cipher challenge, or
null
if no cipher challenge is specified in the layout.
-
getForceWriteCommit
public final boolean getForceWriteCommit()Indicates whether "force write on commit" is turned on or off.Consult the chapter "Durability" of the
Database
interface description to learn more about this database property.- Returns:
- The boolean value
true
if and only if "force write on commit" is turned on.
-
setForceWriteCommit
Sets the value of the "force write on commit" database property.Consult the chapter "Durability" of the
Database
interface description to learn more about this database property.- Parameters:
value
- The new value of "force write on commit".- Returns:
- This object.
-
getRecFile
Returns the path (including the file name) of the database's recorder file.- Returns:
- The path (including the file name) of the recorder file.
-
setRecFile
Sets the path (including the file name) of the database's recorder file to the specified value.Note that this method does not check whether the specified value is a valid path and whether the recorder file actually exists. Opening the database will throw an exception if the specified value is not a valid path or if the recorder file does not exist.
- Parameters:
value
- The new path (including the file name) of the recorder file, not allowed to benull
or an empty string.- Returns:
- This object.
- Throws:
IllegalArgumentException
- Ifvalue
isnull
or an empty string.
-
getTableNames
Returns the names of the tables in the database.The order of the returned array is identical to the order in which the tables appear in the layout.
- Returns:
- The names of the database's table, never
null
.
-
setTableName
Sets the name of the specified table to the specified new value.- Parameters:
tableName
- The name of the table, not allowed to benull
or an empty string.value
- The new name of the table, not allowed to benull
or an empty string and not allowed to start with the number sign ('#') character.- Returns:
- This object.
- Throws:
IllegalArgumentException
- If one of the arguments isnull
or an empty string or if the database has no table with a name equal to thetableName
argument or if thevalue
argument starts with the number sign ('#') character or if a table with a name equal to thevalue
argument already exists.
-
getNobsRowRef
Returns the number of bytes required for referencing a row in the specified table.See the description of the Setup Tool for further information about the
nobsRowRef
,nobsOutrowPtr
andnobsRefCount
properties.This value can be changed by invoking the
Refactor.nobsRowRef(java.nio.file.Path, java.lang.String, int)
method.- Parameters:
tableName
- The name of the table, not allowed to benull
or an empty string.- Returns:
- The value of the
nobsRowRef
table property. - Throws:
IllegalArgumentException
- IftableName
isnull
or an empty string or if the database has no table with such a name.
-
getNobsOutrowPtr
Returns the number of bytes required for referencing any outrow data in the specified table.See the description of the Setup Tool for further information about the
nobsRowRef
,nobsOutrowPtr
andnobsRefCount
properties.This value can be changed by invoking the
Refactor.nobsOutrowPtr(java.nio.file.Path, java.lang.String, int)
method.- Parameters:
tableName
- The name of the table, not allowed to benull
or an empty string.- Returns:
- The value of the
nobsOutrowPtr
table property. If the table has no such property then this value is zero. - Throws:
IllegalArgumentException
- IftableName
isnull
or an empty string or if the database has no table with such a name.
-
getNobsRefCount
Returns the number of bytes used by the reference counter in the header of a row in the specified table.See the description of the Setup Tool for further information about the
nobsRowRef
,nobsOutrowPtr
andnobsRefCount
properties.This value can be changed by invoking the
Refactor.nobsRefCount(java.nio.file.Path, java.lang.String, int)
method.- Parameters:
tableName
- The name of the table, not allowed to benull
or an empty string.- Returns:
- The value of the
nobsRefCount
table property. If the table has no such property then this value is zero. - Throws:
IllegalArgumentException
- IftableName
isnull
or an empty string or if the database has no table with such a name.
-
getFlDataFile
Returns the path (including the file name) of the specified table's FL data file.- Parameters:
tableName
- The name of the table, not allowed to benull
or an empty string.- Returns:
- The path (including the file name) of the FL data file.
- Throws:
IllegalArgumentException
- IftableName
isnull
or an empty string or if the database has no table with such a name.
-
setFlDataFile
Sets the path (including the file name) of the specified table's FL data file to the specified value.Note that this method does not check whether the specified value is a valid path and whether the FL data file actually exists. Opening the database will throw an exception if the specified value is not a valid path or if the FL data file does not exist.
- Parameters:
tableName
- The name of the table, not allowed to benull
or an empty string.value
- The new path (including the file name) of the table's FL data file, not allowed to benull
or an empty string.- Returns:
- This object.
- Throws:
IllegalArgumentException
- If one of the arguments isnull
or an empty string or if the database has no table with the specified name.
-
getVlDataFile
Returns the path (including the file name) of the specified table's VL data file, provided that the path is specified in the table layout.- Parameters:
tableName
- The name of the table, not allowed to benull
or an empty string.- Returns:
- The path (including the file name) of the VL data file or
null
if no such path is specified in the table layout. - Throws:
IllegalArgumentException
- IftableName
isnull
or an empty string or if the database has no table with the specified name.
-
setVlDataFile
Sets the path (including the file name) of the specified table's VL data file to the specified value, provided that the path is specified in the table layout.Note that this method does not check whether the specified value is a valid path and whether the VL data file actually exists. Opening the database will throw an exception if the specified value is not a valid path or if the VL data file does not exist.
- Parameters:
tableName
- The name of the table, not allowed to benull
or an empty string.value
- The new path (including the file name) of the table's VL data file, not allowed to benull
or an empty string.- Returns:
- This object.
- Throws:
IllegalArgumentException
- If one of the arguments isnull
or an empty string or if the database has no table with the specified name or if the table layout does not contain such a path.
-
getColumnNames
Returns the names of the columns of the specified table.The order of the returned array is identical to the order in which the columns appear in the table layout.
- Parameters:
tableName
- The name of the table, not allowed to benull
or an empty string.- Returns:
- The names of the table's columns, never
null
. - Throws:
IllegalArgumentException
- IftableName
isnull
or an empty string or if the database has no table with such a name.
-
setColumnName
public final Settings setColumnName(String tableName, String columnName, String value) throws IllegalArgumentException Sets the name of the specified column to the specified new value.- Parameters:
tableName
- The name of the table, not allowed to benull
or an empty string.columnName
- The name of the column, not allowed to benull
or an empty string.value
- The new name of the column, not allowed to benull
or an empty string.- Returns:
- This object.
- Throws:
IllegalArgumentException
- If one of the arguments isnull
or an empty string or if the database has no table with the specified name or if the table has no column with the specified name or if the table already has a column with a name equal to thevalue
argument.
-
getTypeDesc
public final String getTypeDesc(String tableName, String columnName) throws IllegalArgumentException Returns the type descriptor of the specified column.Invoke the
Refactor.modifyColumn(java.nio.file.Path, acdp.design.ICipherFactory, java.lang.String, java.lang.String, acdp.Column<T>, acdp.Table.ValueSwitcher<T>)
method to change the type of a column.- Parameters:
tableName
- The name of the table, not allowed to benull
or an empty string.columnName
- The name of the column, not allowed to benull
or an empty string.- Returns:
- The column's type descriptor.
- Throws:
IllegalArgumentException
- If one of the arguments isnull
or an empty string or if the database has no table with the specified name or if the table has no column with the specified name.
-
getTypeFactoryClassName
public final String getTypeFactoryClassName(String tableName, String columnName) throws IllegalArgumentException Returns the type factory class name of the specified column, if any is specified in the column layout.Invoke the
Refactor.modifyColumn(java.nio.file.Path, acdp.design.ICipherFactory, java.lang.String, java.lang.String, acdp.Column<T>, acdp.Table.ValueSwitcher<T>)
method to change the type of a column.- Parameters:
tableName
- The name of the table, not allowed to benull
or an empty string.columnName
- The name of the column, not allowed to benull
or an empty string.- Returns:
- The column's type factory class name or
null
if no type factory class name is specified in the column layout. - Throws:
IllegalArgumentException
- If one of the arguments isnull
or an empty string or if the database has no table with the specified name or if the table has no column with the specified name.
-
getTypeFactoryClasspath
public final String getTypeFactoryClasspath(String tableName, String columnName) throws IllegalArgumentException Returns the extra classpath of the specified column's type factory, if any is specified in the column layout.Invoke the
Refactor.modifyColumn(java.nio.file.Path, acdp.design.ICipherFactory, java.lang.String, java.lang.String, acdp.Column<T>, acdp.Table.ValueSwitcher<T>)
method to change the type of a column.- Parameters:
tableName
- The name of the table, not allowed to benull
or an empty string.columnName
- The name of the column, not allowed to benull
or an empty string.- Returns:
- The extra classpath of the column's type factory or
null
if no extra type factory classpath is specified in the column layout. - Throws:
IllegalArgumentException
- If one of the arguments isnull
or an empty string or if the database has no table with the specified name or if the table has no column with the specified name.
-
setTypeFactoryClasspath
public final Settings setTypeFactoryClasspath(String tableName, String columnName, String value) throws IllegalArgumentException Sets the extra classpath of the specified column's type factory to the specified value.If the column layout already contains an extra type factory classpath and the specified value is
null
or an empty string then the extra type factory classpath is removed from the column layout.Note that this method does not check whether the specified value is a valid path and whether the path actually exists. Opening the database will throw an exception if the specified value is illegal.
Invoke the
Refactor.modifyColumn(java.nio.file.Path, acdp.design.ICipherFactory, java.lang.String, java.lang.String, acdp.Column<T>, acdp.Table.ValueSwitcher<T>)
method to change the type of a column.- Parameters:
tableName
- The name of the table, not allowed to benull
or an empty string.columnName
- The name of the column, not allowed to benull
or an empty string.value
- The extra classpath of the column's type factory.- Returns:
- This object.
- Throws:
IllegalArgumentException
- IftableName
orcolumnName
isnull
or an empty string or if the database has no table with the specified name or if the table has no column with the specified name.
-
getRefdTable
public final String getRefdTable(String tableName, String columnName) throws IllegalArgumentException Returns the name of the table referenced by the specified column, provided that the column is ofRefType
orArrayOfRefType
.- Parameters:
tableName
- The name of the table, not allowed to benull
or an empty string.columnName
- The name of the column, not allowed to benull
or an empty string.- Returns:
- The name of the referenced table or
null
if the column is neither ofRefType
norArrayOfRefType
. - Throws:
IllegalArgumentException
- If one of the arguments isnull
or an empty string or if the database has no table with the specified name or if the table has no column with the specified name.
-
save
Saves the settings.- Returns:
- This object.
- Throws:
IOFailureException
- If an I/O error occurs.
-