Package acdp.tools

Class Settings

java.lang.Object
acdp.tools.Settings

public final class Settings extends Object
Lets you view all settings of a WR database and enables you to safely modify some of them.

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 Details

  • Method Details

    • getName

      public final String getName()
      Returns the name of the database.
      Returns:
      The name of the database.
    • setName

      public final Settings setName(String value) throws IllegalArgumentException
      Sets the name of the database to the specified value.
      Parameters:
      value - The new name of the database, not allowed to be null and not allowed to be an empty string.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - If value is null or an empty string.
    • getVersion

      public final 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

      public final Settings setVersion(String value)
      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

      public final Settings setConsistencyNumber(int value)
      Sets the consistency number to the specified value.
      Parameters:
      value - The new consistency number.
      Returns:
      This object.
    • getCipherChallenge

      public final String 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

      public final Settings setForceWriteCommit(boolean value)
      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

      public final String 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

      public final Settings setRecFile(String value) throws IllegalArgumentException
      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 be null or an empty string.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - If value is null or an empty string.
    • getTableNames

      public final 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

      public final Settings setTableName(String tableName, String value) throws IllegalArgumentException
      Sets the name of the specified table to the specified new value.
      Parameters:
      tableName - The name of the table, not allowed to be null or an empty string.
      value - The new name of the table, not allowed to be null or an empty string and not allowed to start with the number sign ('#') character.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - If one of the arguments is null or an empty string or if the database has no table with a name equal to the tableName argument or if the value argument starts with the number sign ('#') character or if a table with a name equal to the value argument already exists.
    • getNobsRowRef

      public final int getNobsRowRef(String tableName) throws IllegalArgumentException
      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 and nobsRefCount 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 be null or an empty string.
      Returns:
      The value of the nobsRowRef table property.
      Throws:
      IllegalArgumentException - If tableName is null or an empty string or if the database has no table with such a name.
    • getNobsOutrowPtr

      public final int getNobsOutrowPtr(String tableName) throws IllegalArgumentException
      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 and nobsRefCount 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 be null 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 - If tableName is null or an empty string or if the database has no table with such a name.
    • getNobsRefCount

      public final int getNobsRefCount(String tableName) throws IllegalArgumentException
      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 and nobsRefCount 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 be null 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 - If tableName is null or an empty string or if the database has no table with such a name.
    • getFlDataFile

      public final String getFlDataFile(String tableName) throws IllegalArgumentException
      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 be null or an empty string.
      Returns:
      The path (including the file name) of the FL data file.
      Throws:
      IllegalArgumentException - If tableName is null or an empty string or if the database has no table with such a name.
    • setFlDataFile

      public final Settings setFlDataFile(String tableName, String value) throws IllegalArgumentException
      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 be null or an empty string.
      value - The new path (including the file name) of the table's FL data file, not allowed to be null or an empty string.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - If one of the arguments is null or an empty string or if the database has no table with the specified name.
    • getVlDataFile

      public final String getVlDataFile(String tableName) throws IllegalArgumentException
      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 be null 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 - If tableName is null or an empty string or if the database has no table with the specified name.
    • setVlDataFile

      public final Settings setVlDataFile(String tableName, String value) throws IllegalArgumentException
      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 be null or an empty string.
      value - The new path (including the file name) of the table's VL data file, not allowed to be null or an empty string.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - If one of the arguments is null 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

      public final String[] getColumnNames(String tableName) throws IllegalArgumentException
      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 be null or an empty string.
      Returns:
      The names of the table's columns, never null.
      Throws:
      IllegalArgumentException - If tableName is null 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 be null or an empty string.
      columnName - The name of the column, not allowed to be null or an empty string.
      value - The new name of the column, not allowed to be null or an empty string.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - If one of the arguments is null 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 the value 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 be null or an empty string.
      columnName - The name of the column, not allowed to be null or an empty string.
      Returns:
      The column's type descriptor.
      Throws:
      IllegalArgumentException - If one of the arguments is null 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 be null or an empty string.
      columnName - The name of the column, not allowed to be null 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 is null 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 be null or an empty string.
      columnName - The name of the column, not allowed to be null 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 is null 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 be null or an empty string.
      columnName - The name of the column, not allowed to be null or an empty string.
      value - The extra classpath of the column's type factory.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - If tableName or columnName is null 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 of RefType or ArrayOfRefType.
      Parameters:
      tableName - The name of the table, not allowed to be null or an empty string.
      columnName - The name of the column, not allowed to be null or an empty string.
      Returns:
      The name of the referenced table or null if the column is neither of RefType nor ArrayOfRefType.
      Throws:
      IllegalArgumentException - If one of the arguments is null 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

      public final Settings save() throws IOFailureException
      Saves the settings.
      Returns:
      This object.
      Throws:
      IOFailureException - If an I/O error occurs.