Class DataStore
- Direct Known Subclasses:
H2Store,MariaDBStore,MySQLStore,SqliteStore
- Author:
- gmt2001
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringTable name prefix for all tables created asSectionVariableValueTable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCreates a new tablevoidDeprecated.booleanDeprecated.booleanTests if the connection to the database succeedsvoidDeprecated, for removal: This API element is subject to removal in a future version.voidDecreases the value of thevaluecolumn as an integer in the default section of the given table and keyvoidDecreases the value of thevaluecolumn as an integer in the given table, section, and keyvoidDecreases the value of thevaluecolumn as a long in the default section of the given table and keyvoidDecreases the value of thevaluecolumn as a long in the given table, section, and keyvoidDecreases the value of thevaluecolumn as a long in the default section of the given table and keyvoidDecreases the value of thevaluecolumn as a long in the given table, section, and keyvoidDecreases the value of thevaluecolumn as a long in the default section of the given table and keyvoidDecreases the value of thevaluecolumn as a long in the given table, section, and keyvoidDeletes the row from the default section that matches the given table and keyvoiddispose()Deprecated, for removal: This API element is subject to removal in a future version.Please instead callDatastore2.dispose()voidDeprecated, for removal: This API element is subject to removal in a future version.Indexes are dropped automatically uponDROP TABLEdsl()Shortcut forDatastore2.dslContext()String[][]executeSql(String sql, String[] replacements) Executes an SQL querybooleanIndicates if the given table contains a row matching the given keyAttempts to find the named field case-insensitivelybooleanFileExists(String fName) Indicates if the given table already existsAttempts to find the named table case-insensitivelyReturns the value of thevaluecolumn from the default section of the given table and key as a stringbooleanGetBoolean(String fName, String section, String key) Returns the value of thevaluecolumn for the given table, section, and key as a booleanbooleanGetBoolean(String fName, String section, String key, boolean fallback) Returns the value of thevaluecolumn for the given table, section, and key as a booleanString[]GetCategoryList(String fName) Returns a list of all values in thesectioncolumn within the tabledoubleReturns the value of thevaluecolumn for the given table, section, and key as a doubledoubleReturns the value of thevaluecolumn for the given table, section, and key as a doubleString[]Returns a list of tables in the database.floatReturns the value of thevaluecolumn for the given table, section, and key as a floatfloatReturns the value of thevaluecolumn for the given table, section, and key as a floatintGetInteger(String fName, String section, String key) Returns the value of thevaluecolumn for the given table, section, and key as an integerintGetInteger(String fName, String section, String key, int fallback) Returns the value of thevaluecolumn for the given table, section, and key as an integerGetKeyByValue(String fName, String section, String value) Returns the value of thevariablecolumn for the given table, section, and valueString[]GetKeyList(String fName, String section) Returns a list of all values in thevariablecolumn within the table and sectionString[]GetKeysByLikeKeys(String fName, String section, String search) Returns a list of values in thevariablecolumn within the table and section, where the value of thevariablecolumn contains the search phraseString[]GetKeysByLikeKeysOrder(String fName, String search) Returns a list of all values in thevariablecolumn within the default section of the table, where the value of thevariablecolumn contains the search phrase, sorted naturally DescendingString[]GetKeysByLikeKeysOrder(String fName, String section, String search) Returns a list of all values in thevariablecolumn within the table and section, where the value of thevariablecolumn contains the search phrase, sorted naturally DescendingString[]GetKeysByLikeKeysOrder(String fName, String section, String search, String order) Returns a list of all values in thevariablecolumn within the table and section, where the value of thevariablecolumn 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 thevariablecolumn within the table and section, where the value of thevariablecolumn contains the search phrase, sorted naturallyString[]GetKeysByLikeValues(String fName, String section, String search) Returns a list of values in thevariablecolumn within the table and section, where the value of thevaluecolumn contains the search phraseString[]GetKeysByNumberOrder(String fName) Returns a list of all values in thevariablecolumn within the default section of the table, sorted naturally Descending as integersString[]GetKeysByNumberOrder(String fName, String section) Returns a list of all values in thevariablecolumn within the table and section, sorted naturally Descending as integersString[]GetKeysByNumberOrder(String fName, String section, String order) Returns a list of all values in thevariablecolumn within the table and section, sorted naturally as integersString[]Returns a list of values in thevariablecolumn within the table and section, sorted naturally as integersString[]GetKeysByNumberOrderValue(String fName) Returns a list of all values in thevariablecolumn within the default section of the table, sorted naturally Descending by thevaluecolumn as integersString[]GetKeysByNumberOrderValue(String fName, String section) Returns a list of all values in thevariablecolumn within the table and section, sorted naturally Descending by thevaluecolumn as integersString[]GetKeysByNumberOrderValue(String fName, String section, String order) Returns a list of all values in thevariablecolumn within the table and section, sorted naturally by thevaluecolumn as integersString[]Returns a list of values in thevariablecolumn within the table and section, sorted naturally by thevaluecolumn as integersString[]GetKeysByOrder(String fName) Returns a list of all values in thevariablecolumn within the default section of the table, sorted naturally in Descending orderString[]GetKeysByOrder(String fName, String section) Returns a list of all values in thevariablecolumn within the table and section, sorted naturally in Descending orderString[]GetKeysByOrder(String fName, String section, String order) Returns a list of all values in thevariablecolumn within the table and section, sorted naturallyString[]Returns a list of values in thevariablecolumn within the table and section, sorted naturallyString[]GetKeysByOrderValue(String fName) Returns a list of all values in thevariablecolumn within the default section of the table, sorted naturally Descending by thevaluecolumnString[]GetKeysByOrderValue(String fName, String section) Returns a list of all values in thevariablecolumn within the table and section, sorted naturally Descending by thevaluecolumnString[]GetKeysByOrderValue(String fName, String section, String order) Returns a list of all values in thevariablecolumn within the table and section, sorted naturally by thevaluecolumnString[]Returns a list of values in thevariablecolumn within the table and section, sorted naturally by thevaluecolumnKeyValue[]GetKeyValueList(String fName, String section) Returns a list of allvariable/valuepairs within the table and sectionlongReturns the value of thevaluecolumn for the given table, section, and key as a longlongReturns the value of thevaluecolumn for the given table, section, and key as a longReturns the value of thevaluecolumn for the given table, section, and key as a stringReturns the value of thevaluecolumn for the given table, section, and key as a stringbooleanIndicates if the given table contains a row matching the given section and keyvoidIncreases the value of thevaluecolumn as an integer in the default section of the given table and keyvoidIncreases the value of thevaluecolumn as an integer in the given table, section, and keyvoidIncreases the value of thevaluecolumn as an integer in the default section of the given table and keyvoidIncreases the value of thevaluecolumn as an integer in the given table, section, and keyvoidIncreaseBatchString(String fName, String section, String[] keys, String value) Increases the value of thevaluecolumn as an integer for all keys of the given table and sectionvoidIncreases the value of thevaluecolumn as an integer in the default section of the given table and keyvoidIncreases the value of thevaluecolumn as an integer in the given table, section, and keyvoidIncreases the value of thevaluecolumn as a long in the default section of the given table and keyvoidIncreases the value of thevaluecolumn as a long in the given table, section, and keyvoidInsertString(String fName, String section, String key, String value) Sets the value of thevaluecolumn for the given table, section, and key as a stringstatic DataStoreinstance()Provides an instance ofDataStoreOptBoolean(String fName, String section, String key) Returns the value of thevaluecolumn for the given table, section, and key as a booleanReturns the value of thevaluecolumn for the given table, section, and key as a doubleReturns the value of thevaluecolumn for the given table, section, and key as a floatOptInteger(String fName, String section, String key) Returns the value of thevaluecolumn for the given table, section, and key as an integerReturns the value of thevaluecolumn 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 thevaluecolumn for the given table, section, and key as a stringExecutes an SQL queryvoidRemoveFile(String fName) Deletes the tablevoidDeletes the row that matches the given table, section, and keyvoidRemoveSection(String fName, String section) Deletes all rows that match the given table and sectionvoidRenameFile(String fNameSource, String fNameDest) Renames the tablestatic StringresolveClassname(String classname) Converts Datastore1 driver names to Datastore2 driver namesbooleanSafeChangeLong(String fName, String section, String key, long orig, long value) Changes the value of thevaluecolumn for the given table, section, and key as a long, only if the record is unmodified fromorigor does not existString[]searchByKey(String fName, String search) Returns a list of values in thevariablecolumn within the default section of the table, where the value of thevariablecolumn contains the search phraseString[]searchByValue(String fName, String search) Returns a list of values in thevariablecolumn within the default section of the table, where the value of thevaluecolumn contains the search phrasevoidSets the value of thevaluecolumn for the default section of the given table and key as a stringvoidPerforms a bulkset(String, String, String)operation, using available database features to do so more efficiently.voidSetBatchString(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.voidSetBoolean(String fName, String section, String key, boolean value) Sets the value of thevaluecolumn for the given table, section, and key as a booleanvoidSets the value of thevaluecolumn for the given table, section, and key as a doublevoidSets the value of thevaluecolumn for the given table, section, and key as a floatvoidSetInteger(String fName, String section, String key, int value) Sets the value of thevaluecolumn for the given table, section, and key as an integervoidSets the value of thevaluecolumn for the given table, section, and key as a longvoidSets the value of thevaluecolumn for the given table, section, and key as a string
-
Field Details
-
PREFIX
Table name prefix for all tables created asSectionVariableValueTable- See Also:
-
-
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 thesectioncolumn within the table- Parameters:
fName- a table name, without thephantombot_prefix- Returns:
- an array of sections
-
GetKeyList
Returns a list of all values in thevariablecolumn within the table and section- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sections- Returns:
- an array of variables
-
GetKeyValueList
Returns a list of allvariable/valuepairs within the table and section- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sections- Returns:
- an array of
KeyValuepairs denoting the variables and values
-
GetKeysByOrder
Returns a list of all values in thevariablecolumn 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 thevariablecolumn 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;nullfor all sections- Returns:
- a sorted list of variables
-
GetKeysByOrder
Returns a list of all values in thevariablecolumn within the table and section, sorted naturally- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor 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 thevariablecolumn within the table and section, sorted naturally- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor 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 thevariablecolumn 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 thevariablecolumn 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;nullfor all sections- Returns:
- a sorted list of variables
-
GetKeysByNumberOrder
Returns a list of all values in thevariablecolumn 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;nullfor 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 thevariablecolumn 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;nullfor 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 thevariablecolumn within the default section of the table, sorted naturally Descending by thevaluecolumn- Parameters:
fName- a table name, without thephantombot_prefix- Returns:
- a sorted list of variables
-
GetKeysByOrderValue
Returns a list of all values in thevariablecolumn within the table and section, sorted naturally Descending by thevaluecolumn- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sections- Returns:
- a sorted list of variables
-
GetKeysByOrderValue
Returns a list of all values in thevariablecolumn within the table and section, sorted naturally by thevaluecolumn- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor 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 thevariablecolumn within the table and section, sorted naturally by thevaluecolumn- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor 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 thevariablecolumn within the default section of the table, sorted naturally Descending by thevaluecolumn as integers- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sections- Returns:
- a sorted list of variables
-
GetKeysByNumberOrderValue
Returns a list of all values in thevariablecolumn within the table and section, sorted naturally Descending by thevaluecolumn as integers- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sections- Returns:
- a sorted list of variables
-
GetKeysByNumberOrderValue
Returns a list of all values in thevariablecolumn within the table and section, sorted naturally by thevaluecolumn as integers- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor 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 thevariablecolumn within the table and section, sorted naturally by thevaluecolumn as integers- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor 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 thevariablecolumn for the given table, section, and value- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sectionsvalue- the value of thevaluecolumn- Returns:
- the variable;
nullif not found
-
GetKeysByLikeValues
Returns a list of values in thevariablecolumn within the table and section, where the value of thevaluecolumn contains the search phrase- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sectionssearch- the partial value of thevaluecolumn to match against- Returns:
- a list of variables
-
GetKeysByLikeKeys
Returns a list of values in thevariablecolumn within the table and section, where the value of thevariablecolumn contains the search phrase- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sectionssearch- the partial value of thevariablecolumn to match against- Returns:
- a list of variables
-
GetKeysByLikeKeysOrder
Returns a list of all values in thevariablecolumn within the default section of the table, where the value of thevariablecolumn contains the search phrase, sorted naturally Descending- Parameters:
fName- a table name, without thephantombot_prefixsearch- the partial value of thevariablecolumn to match against- Returns:
- a sorted list of variables
-
GetKeysByLikeKeysOrder
Returns a list of all values in thevariablecolumn within the table and section, where the value of thevariablecolumn contains the search phrase, sorted naturally Descending- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sectionssearch- the partial value of thevariablecolumn to match against- Returns:
- a sorted list of variables
-
GetKeysByLikeKeysOrder
Returns a list of all values in thevariablecolumn within the table and section, where the value of thevariablecolumn contains the search phrase, sorted naturally- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sectionssearch- the partial value of thevariablecolumn 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 thevariablecolumn within the table and section, where the value of thevariablecolumn contains the search phrase, sorted naturally- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sectionssearch- the partial value of thevariablecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrieve- Returns:
- an
Optionalthat may contain aSectionVariableValueRecordif 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;nullfor all sectionskey- the value of thevariablecolumn to retrieve- Returns:
- an
Optionalthat may contain aSectionVariableValueRecordif the row exists
-
OptString
Returns the value of thevaluecolumn for the given table, section, and key as a stringIt is not possible to distinguish between the SQL value
NULLand 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;nullfor all sectionskey- the value of thevariablecolumn to retrieve- Returns:
- an
Optionalthat may contain the value
-
GetString
Returns the value of thevaluecolumn for the given table, section, and key as a stringA return value of
nullmay 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;nullfor all sectionskey- the value of thevariablecolumn to retrieve- Returns:
- the value
-
GetString
Returns the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrievefallback- the fallback String; returned if the key is not present or the string isnull- Returns:
- the value;
fallbackif not found or the value beingnull
-
SetString
Sets the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to updatevalue- the new value of thevaluecolumn
-
InsertString
Sets the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to updatevalue- the new value of thevaluecolumn
-
IncreaseBatchString
Increases the value of thevaluecolumn 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;nullfor all sectionskeys- the values of thevariablecolumn to updatevalue- the new value to increase thevaluecolumn 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;nullfor all sectionskeys- the values of thevariablecolumn to updatevalues- the new values to set thevaluecolumn to
-
OptLong
Returns the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrieve- Returns:
- an
Optionalthat may contain the value as a long
-
GetLong
Returns the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrieve- Returns:
- the value as a long;
0Lif the conversion fails
-
GetLong
Returns the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrievefallback- the fallback int; returned if the key is not present- Returns:
- the value as a long;
fallbackif the conversion fails
-
SetLong
Sets the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrievevalue- the new value of thevaluecolumn
-
SafeChangeLong
Changes the value of thevaluecolumn for the given table, section, and key as a long, only if the record is unmodified fromorigor does not exist- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sectionskey- the value of thevariablecolumn to retrieveorig- the original value of thevaluecolumn. Any value if the record does not existvalue- the new value to store in thevaluecolumn- Returns:
trueon success
-
OptInteger
Returns the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrieve- Returns:
- an
Optionalthat may contain the value as an integer
-
GetInteger
Returns the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrieve- Returns:
- the value as an integer;
0if the conversion fails
-
GetInteger
Returns the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrievefallback- the fallback integer; returned if the key is not present- Returns:
- the value as an integer;
fallbackif the conversion fails
-
SetInteger
Sets the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrievevalue- the new value of thevaluecolumn
-
OptFloat
Returns the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrieve- Returns:
- an
Optionalthat may contain the value as a float
-
GetFloat
Returns the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrieve- Returns:
- the value as a float;
0.0fif the conversion fails
-
GetFloat
Returns the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrievefallback- the fallback float; returned if the key is not present- Returns:
- the value as a float;
fallbackif the conversion fails
-
SetFloat
Sets the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrievevalue- the new value of thevaluecolumn
-
OptDouble
Returns the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrieve- Returns:
- an
Optionalthat may contain the value as a double
-
GetDouble
Returns the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrieve- Returns:
- the value as a double;
0.0if the conversion fails
-
GetDouble
Returns the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrievefallback- the fallback double; returned if the key is not present- Returns:
- the value as a double;
fallbackif the conversion fails
-
SetDouble
Sets the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrievevalue- the new value of thevaluecolumn
-
OptBoolean
Returns the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrieve- Returns:
- an
Optionalthat may contain the value as a boolean;trueif the value as a string is"1","true", or"yes";falseotherwise
-
GetBoolean
Returns the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrieve- Returns:
trueif the value as a string is"1","true", or"yes";falseotherwise
-
GetBoolean
Returns the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrievefallback- the fallback boolean; returned if the key is not present- Returns:
trueif the value as a string is"1","true", or"yes";fallbackotherwise
-
SetBoolean
Sets the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumn to retrievevalue- the new value of thevaluecolumn
-
RemoveKey
Deletes the row that matches the given table, section, and keyIf
sectionis 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;nullfor all sectionskey- the value of thevariablecolumn
-
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:
trueif 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) ornullfor all sectionskey- the value of thevariablecolumn- Returns:
trueif 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 thevariablecolumn- Returns:
trueif the key exists
-
get
Returns the value of thevaluecolumn from the default section of the given table and key as a stringA return value of
nullmay 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 thevariablecolumn to retrieve- Returns:
- the value;
nullif not found
-
set
Sets the value of thevaluecolumn for the default section of the given table and key as a string- Parameters:
fName- a table name, without thephantombot_prefixkey- the value of thevariablecolumn to updatevalue- the new value of thevaluecolumn
-
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 thevariablecolumn to updatevalue- the new values to set thevaluecolumn 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 thevariablecolumn
-
incr
Increases the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumnamount- the amount to increase the value of thevaluecolumn by
-
incr
Increases the value of thevaluecolumn as an integer in the default section of the given table and key- Parameters:
fName- a table name, without thephantombot_prefixkey- the value of thevariablecolumnamount- the amount to increase the value of thevaluecolumn by
-
incrL
Increases the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumnamount- the amount to increase the value of thevaluecolumn by
-
incrL
Increases the value of thevaluecolumn as a long in the default section of the given table and key- Parameters:
fName- a table name, without thephantombot_prefixkey- the value of thevariablecolumnamount- the amount to increase the value of thevaluecolumn by
-
incrD
Increases the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumnamount- the amount to increase the value of thevaluecolumn by
-
incrD
Increases the value of thevaluecolumn as an integer in the default section of the given table and key- Parameters:
fName- a table name, without thephantombot_prefixkey- the value of thevariablecolumnamount- the amount to increase the value of thevaluecolumn by
-
incrF
Increases the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumnamount- the amount to increase the value of thevaluecolumn by
-
incrF
Increases the value of thevaluecolumn as an integer in the default section of the given table and key- Parameters:
fName- a table name, without thephantombot_prefixkey- the value of thevariablecolumnamount- the amount to increase the value of thevaluecolumn by
-
decr
Decreases the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumnvalue- the amount to decrease the value of thevaluecolumn by
-
decr
Decreases the value of thevaluecolumn as an integer in the default section of the given table and key- Parameters:
fName- a table name, without thephantombot_prefixkey- the value of thevariablecolumnamount- the amount to decrease the value of thevaluecolumn by
-
decrL
Decreases the value of thevaluecolumn as a long in the default section of the given table and key- Parameters:
fName- a table name, without thephantombot_prefixkey- the value of thevariablecolumnamount- the amount to decrease the value of thevaluecolumn by
-
decrL
Decreases the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumnamount- the amount to decrease the value of thevaluecolumn by
-
decrD
Decreases the value of thevaluecolumn as a long in the default section of the given table and key- Parameters:
fName- a table name, without thephantombot_prefixkey- the value of thevariablecolumnamount- the amount to decrease the value of thevaluecolumn by
-
decrD
Decreases the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumnamount- the amount to decrease the value of thevaluecolumn by
-
decrF
Decreases the value of thevaluecolumn as a long in the default section of the given table and key- Parameters:
fName- a table name, without thephantombot_prefixkey- the value of thevariablecolumnamount- the amount to decrease the value of thevaluecolumn by
-
decrF
Decreases the value of thevaluecolumn 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;nullfor all sectionskey- the value of thevariablecolumnamount- the amount to decrease the value of thevaluecolumn by
-
searchByValue
Returns a list of values in thevariablecolumn within the default section of the table, where the value of thevaluecolumn contains the search phrase- Parameters:
fName- a table name, without thephantombot_prefixsearch- the partial value of thevaluecolumn to match against- Returns:
- a list of variables
-
searchByKey
Returns a list of values in thevariablecolumn within the default section of the table, where the value of thevariablecolumn contains the search phrase- Parameters:
fName- a table name, without thephantombot_prefixsearch- the partial value of thevariablecolumn to match against- Returns:
- a list of variables
-
query
Executes an SQL queryThe query is executed using a
PreparedStatementwith 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
PreparedStatementwith 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 TABLEEnsures that all tables created withAddFile(String)have aUNIQUEindex across thesectionandvariablecolumnsIf 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 TABLEDrops allUNIQUEindexes from tables created withAddFile(String) -
CanConnect
public boolean CanConnect()Tests if the connection to the database succeeds- Returns:
trueon success
-
canBackup
Deprecated.Indicates if this database type supports generating backup files- Returns:
trueif backups are supported
-
backupDB
Deprecated.Backs up the database to the specified filename in thedbbackupfolder- 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