Class DataStore
- Direct Known Subclasses:
H2Store
,MariaDBStore
,MySQLStore
,SqliteStore
- Author:
- gmt2001
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Creates a new tablevoid
Backs up the database to the specified filename in thedbbackup
folderboolean
Indicates if this database type supports generating backup filesboolean
Tests if the connection to the database succeedsvoid
Deprecated, for removal: This API element is subject to removal in a future version.void
Decreases the value of thevalue
column as an integer in the default section of the given table and keyvoid
Decreases the value of thevalue
column as an integer in the given table, section, and keyvoid
Decreases the value of thevalue
column as a long in the default section of the given table and keyvoid
Decreases the value of thevalue
column as a long in the given table, section, and keyvoid
Decreases the value of thevalue
column as a long in the default section of the given table and keyvoid
Decreases the value of thevalue
column as a long in the given table, section, and keyvoid
Decreases the value of thevalue
column as a long in the default section of the given table and keyvoid
Decreases the value of thevalue
column as a long in the given table, section, and keyvoid
Deletes the row from the default section that matches the given table and keyvoid
dispose()
Deprecated, for removal: This API element is subject to removal in a future version.Please instead callDatastore2.dispose()
void
Deprecated, for removal: This API element is subject to removal in a future version.Indexes are dropped automatically uponDROP TABLE
dsl()
Shortcut forDatastore2.dslContext()
String[][]
executeSql
(String sql, String[] replacements) Executes an SQL queryboolean
Indicates if the given table contains a row matching the given keyAttempts to find the named field case-insensitivelyboolean
FileExists
(String fName) Indicates if the given table already existsAttempts to find the named table case-insensitivelyReturns the value of thevalue
column from the default section of the given table and key as a stringboolean
GetBoolean
(String fName, String section, String key) Returns the value of thevalue
column for the given table, section, and key as a booleanboolean
GetBoolean
(String fName, String section, String key, boolean fallback) Returns the value of thevalue
column for the given table, section, and key as a booleanString[]
GetCategoryList
(String fName) Returns a list of all values in thesection
column within the tabledouble
Returns the value of thevalue
column for the given table, section, and key as a doubledouble
Returns the value of thevalue
column for the given table, section, and key as a doubleString[]
Returns a list of tables in the database.float
Returns the value of thevalue
column for the given table, section, and key as a floatfloat
Returns the value of thevalue
column for the given table, section, and key as a floatint
GetInteger
(String fName, String section, String key) Returns the value of thevalue
column for the given table, section, and key as an integerint
GetInteger
(String fName, String section, String key, int fallback) Returns the value of thevalue
column for the given table, section, and key as an integerGetKeyByValue
(String fName, String section, String value) Returns the value of thevariable
column for the given table, section, and valueString[]
GetKeyList
(String fName, String section) Returns a list of all values in thevariable
column within the table and sectionString[]
GetKeysByLikeKeys
(String fName, String section, String search) Returns a list of values in thevariable
column within the table and section, where the value of thevariable
column contains the search phraseString[]
GetKeysByLikeKeysOrder
(String fName, String search) Returns a list of all values in thevariable
column within the default section of the table, where the value of thevariable
column contains the search phrase, sorted naturally DescendingString[]
GetKeysByLikeKeysOrder
(String fName, String section, String search) Returns a list of all values in thevariable
column within the table and section, where the value of thevariable
column contains the search phrase, sorted naturally DescendingString[]
GetKeysByLikeKeysOrder
(String fName, String section, String search, String order) Returns a list of all values in thevariable
column within the table and section, where the value of thevariable
column contains the search phrase, sorted naturallyString[]
GetKeysByLikeKeysOrder
(String fName, String section, String search, String order, String limit, String offset) Returns a list of values in thevariable
column within the table and section, where the value of thevariable
column contains the search phrase, sorted naturallyString[]
GetKeysByLikeValues
(String fName, String section, String search) Returns a list of values in thevariable
column within the table and section, where the value of thevalue
column contains the search phraseString[]
GetKeysByNumberOrder
(String fName) Returns a list of all values in thevariable
column within the default section of the table, sorted naturally Descending as integersString[]
GetKeysByNumberOrder
(String fName, String section) Returns a list of all values in thevariable
column within the table and section, sorted naturally Descending as integersString[]
GetKeysByNumberOrder
(String fName, String section, String order) Returns a list of all values in thevariable
column within the table and section, sorted naturally as integersString[]
Returns a list of values in thevariable
column within the table and section, sorted naturally as integersString[]
GetKeysByNumberOrderValue
(String fName) Returns a list of all values in thevariable
column within the default section of the table, sorted naturally Descending by thevalue
column as integersString[]
GetKeysByNumberOrderValue
(String fName, String section) Returns a list of all values in thevariable
column within the table and section, sorted naturally Descending by thevalue
column as integersString[]
GetKeysByNumberOrderValue
(String fName, String section, String order) Returns a list of all values in thevariable
column within the table and section, sorted naturally by thevalue
column as integersString[]
Returns a list of values in thevariable
column within the table and section, sorted naturally by thevalue
column as integersString[]
GetKeysByOrder
(String fName) Returns a list of all values in thevariable
column within the default section of the table, sorted naturally in Descending orderString[]
GetKeysByOrder
(String fName, String section) Returns a list of all values in thevariable
column within the table and section, sorted naturally in Descending orderString[]
GetKeysByOrder
(String fName, String section, String order) Returns a list of all values in thevariable
column within the table and section, sorted naturallyString[]
Returns a list of values in thevariable
column within the table and section, sorted naturallyString[]
GetKeysByOrderValue
(String fName) Returns a list of all values in thevariable
column within the default section of the table, sorted naturally Descending by thevalue
columnString[]
GetKeysByOrderValue
(String fName, String section) Returns a list of all values in thevariable
column within the table and section, sorted naturally Descending by thevalue
columnString[]
GetKeysByOrderValue
(String fName, String section, String order) Returns a list of all values in thevariable
column within the table and section, sorted naturally by thevalue
columnString[]
Returns a list of values in thevariable
column within the table and section, sorted naturally by thevalue
columnKeyValue[]
GetKeyValueList
(String fName, String section) Returns a list of allvariable/value
pairs within the table and sectionlong
Returns the value of thevalue
column for the given table, section, and key as a longlong
Returns the value of thevalue
column for the given table, section, and key as a longReturns the value of thevalue
column for the given table, section, and key as a stringReturns the value of thevalue
column for the given table, section, and key as a stringboolean
Indicates if the given table contains a row matching the given section and keyvoid
Increases the value of thevalue
column as an integer in the default section of the given table and keyvoid
Increases the value of thevalue
column as an integer in the given table, section, and keyvoid
Increases the value of thevalue
column as an integer in the default section of the given table and keyvoid
Increases the value of thevalue
column as an integer in the given table, section, and keyvoid
IncreaseBatchString
(String fName, String section, String[] keys, String value) Increases the value of thevalue
column as an integer for all keys of the given table and sectionvoid
Increases the value of thevalue
column as an integer in the default section of the given table and keyvoid
Increases the value of thevalue
column as an integer in the given table, section, and keyvoid
Increases the value of thevalue
column as a long in the default section of the given table and keyvoid
Increases the value of thevalue
column as a long in the given table, section, and keyvoid
InsertString
(String fName, String section, String key, String value) Sets the value of thevalue
column for the given table, section, and key as a stringstatic DataStore
instance()
Provides an instance ofDataStore
OptBoolean
(String fName, String section, String key) Returns the value of thevalue
column for the given table, section, and key as a booleanReturns the value of thevalue
column for the given table, section, and key as a doubleReturns the value of thevalue
column for the given table, section, and key as a floatOptInteger
(String fName, String section, String key) Returns the value of thevalue
column for the given table, section, and key as an integerReturns the value of thevalue
column for the given table, section, and key as a longOptRecord
(SectionVariableValueTable table, String section, String key) Returns the record for the given table, section, and keyReturns the record for the given table, section, and keyReturns the value of thevalue
column for the given table, section, and key as a stringExecutes an SQL queryvoid
RemoveFile
(String fName) Deletes the tablevoid
Deletes the row that matches the given table, section, and keyvoid
RemoveSection
(String fName, String section) Deletes all rows that match the given table and sectionvoid
RenameFile
(String fNameSource, String fNameDest) Renames the tablestatic String
resolveClassname
(String classname) Converts Datastore1 driver names to Datastore2 driver namesString[]
searchByKey
(String fName, String search) Returns a list of values in thevariable
column within the default section of the table, where the value of thevariable
column contains the search phraseString[]
searchByValue
(String fName, String search) Returns a list of values in thevariable
column within the default section of the table, where the value of thevalue
column contains the search phrasevoid
Sets the value of thevalue
column for the default section of the given table and key as a stringvoid
Performs a bulkset(String, String, String)
operation, using available database features to do so more efficiently.void
SetBatchString
(String fName, String section, String[] keys, String[] values) Performs a bulkSetString(String, String, String, String)
operation, using available database features to do so more efficiently.void
SetBoolean
(String fName, String section, String key, boolean value) Sets the value of thevalue
column for the given table, section, and key as a booleanvoid
Sets the value of thevalue
column for the given table, section, and key as a doublevoid
Sets the value of thevalue
column for the given table, section, and key as a floatvoid
SetInteger
(String fName, String section, String key, int value) Sets the value of thevalue
column for the given table, section, and key as an integervoid
Sets the value of thevalue
column for the given table, section, and key as a longvoid
Sets the value of thevalue
column for the given table, section, and key as a string
-
Constructor Details
-
DataStore
Constructor- Parameters:
unused
- only used by old classes
-
-
Method Details
-
instance
Provides an instance ofDataStore
- Returns:
- an instance of
DataStore
-
resolveClassname
Converts Datastore1 driver names to Datastore2 driver names- Parameters:
classname
- the classname of the driver- Returns:
- the converted classname
-
findTable
Attempts to find the named table case-insensitivelyThe
phantombot_
prefix is automatically prefixed to the table name -
field
Attempts to find the named field case-insensitively -
dsl
Shortcut forDatastore2.dslContext()
- Returns:
- the active
DSLContext
-
GetFileList
Returns a list of tables in the database.Only tables with the
phantombot_
prefix are returned. The prefix is removed- Returns:
- an array of table names
-
GetCategoryList
Returns a list of all values in thesection
column within the table- Parameters:
fName
- a table name, without thephantombot_
prefix- Returns:
- an array of sections
-
GetKeyList
Returns a list of all values in thevariable
column within the table and section- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sections- Returns:
- an array of variables
-
GetKeyValueList
Returns a list of allvariable/value
pairs within the table and section- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sections- Returns:
- an array of
KeyValue
pairs denoting the variables and values
-
GetKeysByOrder
Returns a list of all values in thevariable
column within the default section of the table, sorted naturally in Descending order- Parameters:
fName
- a table name, without thephantombot_
prefix- Returns:
- a sorted list of variables
-
GetKeysByOrder
Returns a list of all values in thevariable
column within the table and section, sorted naturally in Descending order- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sections- Returns:
- a sorted list of variables
-
GetKeysByOrder
Returns a list of all values in thevariable
column within the table and section, sorted naturally- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionsorder
- sort order. Valid values:"ASC"
(Ascending) or"DESC"
(Descending)- Returns:
- a sorted list of variables
-
GetKeysByOrder
public String[] GetKeysByOrder(String fName, String section, String order, String limit, String offset) Returns a list of values in thevariable
column within the table and section, sorted naturally- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionsorder
- sort order. Valid values:"ASC"
(Ascending) or"DESC"
(Descending)limit
- the maximum number of results to return from this queryoffset
- the offset to start reading from- Returns:
- a sorted list of variables
-
GetKeysByNumberOrder
Returns a list of all values in thevariable
column within the default section of the table, sorted naturally Descending as integers- Parameters:
fName
- a table name, without thephantombot_
prefix- Returns:
- a sorted list of variables
-
GetKeysByNumberOrder
Returns a list of all values in thevariable
column within the table and section, sorted naturally Descending as integers- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sections- Returns:
- a sorted list of variables
-
GetKeysByNumberOrder
Returns a list of all values in thevariable
column within the table and section, sorted naturally as integers- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionsorder
- sort order. Valid values:"ASC"
(Ascending) or"DESC"
(Descending)- Returns:
- a sorted list of variables
-
GetKeysByNumberOrder
public String[] GetKeysByNumberOrder(String fName, String section, String order, String limit, String offset) Returns a list of values in thevariable
column within the table and section, sorted naturally as integers- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionsorder
- sort order. Valid values:"ASC"
(Ascending) or"DESC"
(Descending)limit
- the maximum number of results to return from this queryoffset
- the offset to start reading from- Returns:
- a sorted list of variables
-
GetKeysByOrderValue
Returns a list of all values in thevariable
column within the default section of the table, sorted naturally Descending by thevalue
column- Parameters:
fName
- a table name, without thephantombot_
prefix- Returns:
- a sorted list of variables
-
GetKeysByOrderValue
Returns a list of all values in thevariable
column within the table and section, sorted naturally Descending by thevalue
column- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sections- Returns:
- a sorted list of variables
-
GetKeysByOrderValue
Returns a list of all values in thevariable
column within the table and section, sorted naturally by thevalue
column- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionsorder
- sort order. Valid values:"ASC"
(Ascending) or"DESC"
(Descending)- Returns:
- a sorted list of variables
-
GetKeysByOrderValue
public String[] GetKeysByOrderValue(String fName, String section, String order, String limit, String offset) Returns a list of values in thevariable
column within the table and section, sorted naturally by thevalue
column- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionsorder
- sort order. Valid values:"ASC"
(Ascending) or"DESC"
(Descending)limit
- the maximum number of results to return from this queryoffset
- the offset to start reading from- Returns:
- a sorted list of variables
-
GetKeysByNumberOrderValue
Returns a list of all values in thevariable
column within the default section of the table, sorted naturally Descending by thevalue
column as integers- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sections- Returns:
- a sorted list of variables
-
GetKeysByNumberOrderValue
Returns a list of all values in thevariable
column within the table and section, sorted naturally Descending by thevalue
column as integers- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sections- Returns:
- a sorted list of variables
-
GetKeysByNumberOrderValue
Returns a list of all values in thevariable
column within the table and section, sorted naturally by thevalue
column as integers- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionsorder
- sort order. Valid values:"ASC"
(Ascending) or"DESC"
(Descending)- Returns:
- a sorted list of variables
-
GetKeysByNumberOrderValue
public String[] GetKeysByNumberOrderValue(String fName, String section, String order, String limit, String offset) Returns a list of values in thevariable
column within the table and section, sorted naturally by thevalue
column as integers- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionsorder
- sort order. Valid values:"ASC"
(Ascending) or"DESC"
(Descending)limit
- the maximum number of results to return from this queryoffset
- the offset to start reading from- Returns:
- a sorted list of variables
-
GetKeyByValue
Returns the value of thevariable
column for the given table, section, and value- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionsvalue
- the value of thevalue
column- Returns:
- the variable;
null
if not found
-
GetKeysByLikeValues
Returns a list of values in thevariable
column within the table and section, where the value of thevalue
column contains the search phrase- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionssearch
- the partial value of thevalue
column to match against- Returns:
- a list of variables
-
GetKeysByLikeKeys
Returns a list of values in thevariable
column within the table and section, where the value of thevariable
column contains the search phrase- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionssearch
- the partial value of thevariable
column to match against- Returns:
- a list of variables
-
GetKeysByLikeKeysOrder
Returns a list of all values in thevariable
column within the default section of the table, where the value of thevariable
column contains the search phrase, sorted naturally Descending- Parameters:
fName
- a table name, without thephantombot_
prefixsearch
- the partial value of thevariable
column to match against- Returns:
- a sorted list of variables
-
GetKeysByLikeKeysOrder
Returns a list of all values in thevariable
column within the table and section, where the value of thevariable
column contains the search phrase, sorted naturally Descending- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionssearch
- the partial value of thevariable
column to match against- Returns:
- a sorted list of variables
-
GetKeysByLikeKeysOrder
Returns a list of all values in thevariable
column within the table and section, where the value of thevariable
column contains the search phrase, sorted naturally- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionssearch
- the partial value of thevariable
column to match againstorder
- sort order. Valid values:"ASC"
(Ascending) or"DESC"
(Descending)- Returns:
- a sorted list of variables
-
GetKeysByLikeKeysOrder
public String[] GetKeysByLikeKeysOrder(String fName, String section, String search, String order, String limit, String offset) Returns a list of values in thevariable
column within the table and section, where the value of thevariable
column contains the search phrase, sorted naturally- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionssearch
- the partial value of thevariable
column to match againstorder
- sort order. Valid values:"ASC"
(Ascending) or"DESC"
(Descending)limit
- the maximum number of results to return from this queryoffset
- the offset to start reading from- Returns:
- a sorted list of variables
-
OptRecord
Returns the record for the given table, section, and key- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrieve- Returns:
- an
Optional
that may contain aSectionVariableValueRecord
if the row exists
-
OptRecord
public Optional<SectionVariableValueRecord> OptRecord(SectionVariableValueTable table, String section, String key) Returns the record for the given table, section, and key- Parameters:
table
- the table to searchsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrieve- Returns:
- an
Optional
that may contain aSectionVariableValueRecord
if the row exists
-
OptString
Returns the value of thevalue
column for the given table, section, and key as a stringIt is not possible to distinguish between the SQL value
NULL
and the table/row not being found with this method- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrieve- Returns:
- an
Optional
that may contain the value
-
GetString
Returns the value of thevalue
column for the given table, section, and key as a stringA return value of
null
may denote that the table/row is not found, or that the actual stored value is SQLNULL
. UseHasKey(String, String, String)
to verify if the row exists- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrieve- Returns:
- the value
-
GetString
Returns the value of thevalue
column for the given table, section, and key as a string- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrievefallback
- the fallback String; returned if the key is not present or the string isnull
- Returns:
- the value;
fallback
if not found or the value beingnull
-
SetString
Sets the value of thevalue
column for the given table, section, and key as a string- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to updatevalue
- the new value of thevalue
column
-
InsertString
Sets the value of thevalue
column for the given table, section, and key as a string- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to updatevalue
- the new value of thevalue
column
-
IncreaseBatchString
Increases the value of thevalue
column as an integer for all keys of the given table and section- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskeys
- the values of thevariable
column to updatevalue
- the new value to increase thevalue
column by
-
SetBatchString
Performs a bulkSetString(String, String, String, String)
operation, using available database features to do so more efficiently.The array index of the keys and value params are linked
- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskeys
- the values of thevariable
column to updatevalues
- the new values to set thevalue
column to
-
OptLong
Returns the value of thevalue
column for the given table, section, and key as a long- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrieve- Returns:
- an
Optional
that may contain the value as a long
-
GetLong
Returns the value of thevalue
column for the given table, section, and key as a long- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrieve- Returns:
- the value as a long;
0L
if the conversion fails
-
GetLong
Returns the value of thevalue
column for the given table, section, and key as a long- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrievefallback
- the fallback int; returned if the key is not present- Returns:
- the value as a long;
fallback
if the conversion fails
-
SetLong
Sets the value of thevalue
column for the given table, section, and key as a long- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrievevalue
- the new value of thevalue
column
-
OptInteger
Returns the value of thevalue
column for the given table, section, and key as an integer- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrieve- Returns:
- an
Optional
that may contain the value as an integer
-
GetInteger
Returns the value of thevalue
column for the given table, section, and key as an integer- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrieve- Returns:
- the value as an integer;
0
if the conversion fails
-
GetInteger
Returns the value of thevalue
column for the given table, section, and key as an integer- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrievefallback
- the fallback integer; returned if the key is not present- Returns:
- the value as an integer;
fallback
if the conversion fails
-
SetInteger
Sets the value of thevalue
column for the given table, section, and key as an integer- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrievevalue
- the new value of thevalue
column
-
OptFloat
Returns the value of thevalue
column for the given table, section, and key as a float- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrieve- Returns:
- an
Optional
that may contain the value as a float
-
GetFloat
Returns the value of thevalue
column for the given table, section, and key as a float- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrieve- Returns:
- the value as a float;
0.0f
if the conversion fails
-
GetFloat
Returns the value of thevalue
column for the given table, section, and key as a float- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrievefallback
- the fallback float; returned if the key is not present- Returns:
- the value as a float;
fallback
if the conversion fails
-
SetFloat
Sets the value of thevalue
column for the given table, section, and key as a float- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrievevalue
- the new value of thevalue
column
-
OptDouble
Returns the value of thevalue
column for the given table, section, and key as a double- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrieve- Returns:
- an
Optional
that may contain the value as a double
-
GetDouble
Returns the value of thevalue
column for the given table, section, and key as a double- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrieve- Returns:
- the value as a double;
0.0
if the conversion fails
-
GetDouble
Returns the value of thevalue
column for the given table, section, and key as a double- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrievefallback
- the fallback double; returned if the key is not present- Returns:
- the value as a double;
fallback
if the conversion fails
-
SetDouble
Sets the value of thevalue
column for the given table, section, and key as a double- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrievevalue
- the new value of thevalue
column
-
OptBoolean
Returns the value of thevalue
column for the given table, section, and key as a boolean- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrieve- Returns:
- an
Optional
that may contain the value as a boolean;true
if the value as a string is"1"
,"true"
, or"yes"
;false
otherwise
-
GetBoolean
Returns the value of thevalue
column for the given table, section, and key as a boolean- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrieve- Returns:
true
if the value as a string is"1"
,"true"
, or"yes"
;false
otherwise
-
GetBoolean
Returns the value of thevalue
column for the given table, section, and key as a boolean- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrievefallback
- the fallback boolean; returned if the key is not present- Returns:
true
if the value as a string is"1"
,"true"
, or"yes"
;fallback
otherwise
-
SetBoolean
Sets the value of thevalue
column for the given table, section, and key as a boolean- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column to retrievevalue
- the new value of thevalue
column
-
RemoveKey
Deletes the row that matches the given table, section, and keyIf
section
is null, deletes all rows with a matching table and key, regardless of section- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
column
-
RemoveSection
Deletes all rows that match the given table and section- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section
-
AddFile
Creates a new table- Parameters:
fName
- a table name, without thephantombot_
prefix
-
RemoveFile
Deletes the table- Parameters:
fName
- a table name, without thephantombot_
prefix
-
RenameFile
Renames the table- Parameters:
fNameSource
- a table name for an existing table, without thephantombot_
prefixfNameDest
- a new table name that does not yet exist, without thephantombot_
prefix
-
FileExists
Indicates if the given table already exists- Parameters:
fName
- a table name, without thephantombot_
prefix- Returns:
true
if the table exists
-
HasKey
Indicates if the given table contains a row matching the given section and key- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) ornull
for all sectionskey
- the value of thevariable
column- Returns:
true
if the key exists
-
exists
Indicates if the given table contains a row matching the given key- Parameters:
fName
- a table name, without thephantombot_
prefixkey
- the value of thevariable
column- Returns:
true
if the key exists
-
get
Returns the value of thevalue
column from the default section of the given table and key as a stringA return value of
null
may denote that the table/row is not found, or that the actual stored value is SQLNULL
. Useexists(String, String)
to verify if the row exists- Parameters:
fName
- a table name, without thephantombot_
prefixkey
- the value of thevariable
column to retrieve- Returns:
- the value;
null
if not found
-
set
Sets the value of thevalue
column for the default section of the given table and key as a string- Parameters:
fName
- a table name, without thephantombot_
prefixkey
- the value of thevariable
column to updatevalue
- the new value of thevalue
column
-
setbatch
Performs a bulkset(String, String, String)
operation, using available database features to do so more efficiently.The array index of the keys and value params are linked
- Parameters:
fName
- a table name, without thephantombot_
prefixkeys
- the values of thevariable
column to updatevalue
- the new values to set thevalue
column to
-
del
Deletes the row from the default section that matches the given table and key- Parameters:
fName
- a table name, without thephantombot_
prefixkey
- the value of thevariable
column
-
incr
Increases the value of thevalue
column as an integer in the given table, section, and key- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
columnamount
- the amount to increase the value of thevalue
column by
-
incr
Increases the value of thevalue
column as an integer in the default section of the given table and key- Parameters:
fName
- a table name, without thephantombot_
prefixkey
- the value of thevariable
columnamount
- the amount to increase the value of thevalue
column by
-
incrL
Increases the value of thevalue
column as a long in the given table, section, and key- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
columnamount
- the amount to increase the value of thevalue
column by
-
incrL
Increases the value of thevalue
column as a long in the default section of the given table and key- Parameters:
fName
- a table name, without thephantombot_
prefixkey
- the value of thevariable
columnamount
- the amount to increase the value of thevalue
column by
-
incrD
Increases the value of thevalue
column as an integer in the given table, section, and key- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
columnamount
- the amount to increase the value of thevalue
column by
-
incrD
Increases the value of thevalue
column as an integer in the default section of the given table and key- Parameters:
fName
- a table name, without thephantombot_
prefixkey
- the value of thevariable
columnamount
- the amount to increase the value of thevalue
column by
-
incrF
Increases the value of thevalue
column as an integer in the given table, section, and key- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
columnamount
- the amount to increase the value of thevalue
column by
-
incrF
Increases the value of thevalue
column as an integer in the default section of the given table and key- Parameters:
fName
- a table name, without thephantombot_
prefixkey
- the value of thevariable
columnamount
- the amount to increase the value of thevalue
column by
-
decr
Decreases the value of thevalue
column as an integer in the given table, section, and key- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
columnvalue
- the amount to decrease the value of thevalue
column by
-
decr
Decreases the value of thevalue
column as an integer in the default section of the given table and key- Parameters:
fName
- a table name, without thephantombot_
prefixkey
- the value of thevariable
columnamount
- the amount to decrease the value of thevalue
column by
-
decrL
Decreases the value of thevalue
column as a long in the default section of the given table and key- Parameters:
fName
- a table name, without thephantombot_
prefixkey
- the value of thevariable
columnamount
- the amount to decrease the value of thevalue
column by
-
decrL
Decreases the value of thevalue
column as a long in the given table, section, and key- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
columnamount
- the amount to decrease the value of thevalue
column by
-
decrD
Decreases the value of thevalue
column as a long in the default section of the given table and key- Parameters:
fName
- a table name, without thephantombot_
prefixkey
- the value of thevariable
columnamount
- the amount to decrease the value of thevalue
column by
-
decrD
Decreases the value of thevalue
column as a long in the given table, section, and key- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
columnamount
- the amount to decrease the value of thevalue
column by
-
decrF
Decreases the value of thevalue
column as a long in the default section of the given table and key- Parameters:
fName
- a table name, without thephantombot_
prefixkey
- the value of thevariable
columnamount
- the amount to decrease the value of thevalue
column by
-
decrF
Decreases the value of thevalue
column as a long in the given table, section, and key- Parameters:
fName
- a table name, without thephantombot_
prefixsection
- a section name.""
(empty string) for the default section;null
for all sectionskey
- the value of thevariable
columnamount
- the amount to decrease the value of thevalue
column by
-
searchByValue
Returns a list of values in thevariable
column within the default section of the table, where the value of thevalue
column contains the search phrase- Parameters:
fName
- a table name, without thephantombot_
prefixsearch
- the partial value of thevalue
column to match against- Returns:
- a list of variables
-
searchByKey
Returns a list of values in thevariable
column within the default section of the table, where the value of thevariable
column contains the search phrase- Parameters:
fName
- a table name, without thephantombot_
prefixsearch
- the partial value of thevariable
column to match against- Returns:
- a list of variables
-
query
Executes an SQL queryThe query is executed using a
PreparedStatement
with calls toPreparedStatement.setString(int, String)
For example:
executeSql("SELECT * FROM foo WHERE bar = ?", ["baz"])
The value
"baz"
is escaped to prevent SQL injection, then inserted in place of the?
This yields the final query of
SELECT * FROM foo WHERE bar = "baz"
You can use
?
as many times as necessary, but must provide the same number of elements in the replacements array for the replacement to workReplacements are performed in order from left to right
Exceptions from failed SQL queries are NOT returned or thrown, but are logged in the core-error log
- Parameters:
sql
- The query to executereplacements
- Replacements forPreparedStatement.setString(int, String)
- Returns:
- An List of data as strings representing the result set, if the query was a DQL statement; an empty list otherwise. The outer list represents rows; the inner array represents columns; the values of the inner list represent the value of the row-column pair at that index as a string
-
executeSql
Executes an SQL queryThe query is executed using a
PreparedStatement
with calls toPreparedStatement.setString(int, String)
For example:
executeSql("SELECT * FROM foo WHERE bar = ?", ["baz"])
The value
"baz"
is escaped to prevent SQL injection, then inserted in place of the?
This yields the final query of
SELECT * FROM foo WHERE bar = "baz"
You can use
?
as many times as necessary, but must provide the same number of elements in the replacements array for the replacement to workReplacements are performed in order from left to right
Exceptions from failed SQL queries are NOT returned or thrown, but are logged in the core-error log
- Parameters:
sql
- The query to executereplacements
- Replacements forPreparedStatement.setString(int, String)
- Returns:
- An array of data as strings representing the result set, if the query was a DQL statement; empty arrays otherwise. The outer array represents rows; the inner array represents columns; the values of the inner array represent the value of the row-column pair at that index as a string
-
CreateIndexes
Deprecated, for removal: This API element is subject to removal in a future version.Indexes are created automatically uponCREATE TABLE
Ensures that all tables created withAddFile(String)
have aUNIQUE
index across thesection
andvariable
columnsIf a constraint violation occurs while attempting to create the index, all rows violating the constraint except the first for each pair are deleted
-
DropIndexes
Deprecated, for removal: This API element is subject to removal in a future version.Indexes are dropped automatically uponDROP TABLE
Drops allUNIQUE
indexes from tables created withAddFile(String)
-
CanConnect
public boolean CanConnect()Tests if the connection to the database succeeds- Returns:
true
on success
-
canBackup
public boolean canBackup()Indicates if this database type supports generating backup files- Returns:
true
if backups are supported
-
backupDB
Backs up the database to the specified filename in thedbbackup
folder- Parameters:
filename
- The filename for the backup, without extension
-
dispose
Deprecated, for removal: This API element is subject to removal in a future version.Please instead callDatastore2.dispose()
Cleanup open connections
-
CREATE TABLE