Package net.lapismc.datastore
Class DataStore
- java.lang.Object
-
- net.lapismc.datastore.DataStore
-
- Direct Known Subclasses:
MySQL
public abstract class DataStore extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDataStore.StorageType
-
Field Summary
Fields Modifier and Type Field Description java.lang.StringvalueSeparatorThis separator should be used when submitting values in the addData methods
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidaddData(Table table, java.lang.String values)Add data to a table, this may result in duplicate valuesabstract voidaddData(Table table, java.lang.String primaryKey, java.lang.String primaryValue, java.lang.String values)Add or update data in a table, if used properly this will ensure that there are no duplicate rows and allows mass value updatingabstract voidcloseConnection()Closes any currently open connections to the databasevoidconvertData(DataStore to, java.util.List<Table> tables)protected abstract voiddropTable(Table table)Drop an entire tableabstract java.lang.BooleangetBoolean(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)Get a value of the type Booleanabstract java.util.List<java.lang.String>getEntireColumn(Table table, java.lang.String key)Get all the values in a column of a tableabstract java.util.List<java.lang.String>getEntireRow(Table table, java.lang.String primaryKey, java.lang.String value)Returns a list of String that contains all the values in a row that matches the primary key and valueabstract java.util.List<java.lang.String>getEntireTable(Table table)Get a list of all rows in a table, the values are separated withvalueSeparatorabstract java.lang.LonggetLong(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)Get a value of the type Longabstract java.util.List<java.lang.Long>getLongList(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)Get a list of long, use a non unique primary key and value to get multiple values returnedabstract java.lang.ObjectgetObject(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)Get a value of the type Objectabstract DataStore.StorageTypegetStorageType()Get the storage typeabstract java.lang.StringgetString(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)Get a value of the type Stringabstract java.util.List<java.lang.String>getStringList(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)Get a list of strings, use a non unique primary key and value to get multiple values returnedabstract voidinitialiseDataStore()This will create and necessary files and generate tablesbooleanisAsync()Check if operations are being done asynchronouslyabstract voidremoveAllData(Table table)Removes all rows from the given tableabstract voidremoveData(Table table, java.lang.String key, java.lang.String value)Removes any row with value in the key column in tablevoidsetAsync(boolean isAsync)Enable or disable async operationsabstract voidsetData(Table table, java.lang.String primaryKey, java.lang.String primaryValue, java.lang.String key, java.lang.String value)Set a single value in a rowabstract voidshutdown()Shutdown will close any connections and shutdown the connection manager
-
-
-
Method Detail
-
initialiseDataStore
public abstract void initialiseDataStore()
This will create and necessary files and generate tables
-
getStorageType
public abstract DataStore.StorageType getStorageType()
Get the storage type- Returns:
- Returns the type of this DataStore
-
isAsync
public boolean isAsync()
Check if operations are being done asynchronously- Returns:
- true if operations are async, otherwise false
-
setAsync
public void setAsync(boolean isAsync)
Enable or disable async operations- Parameters:
isAsync- true means operations will be completed asynchronously
-
closeConnection
public abstract void closeConnection()
Closes any currently open connections to the database
-
shutdown
public abstract void shutdown()
Shutdown will close any connections and shutdown the connection manager
-
addData
public abstract void addData(Table table, java.lang.String values)
Add data to a table, this may result in duplicate values- Parameters:
table- The table you wish to add toovalues- The values you wish to add, must be in the correct order based on the table definition and be separated by thevalueSeparator, Must include all values of the table
-
addData
public abstract void addData(Table table, java.lang.String primaryKey, java.lang.String primaryValue, java.lang.String values)
Add or update data in a table, if used properly this will ensure that there are no duplicate rows and allows mass value updating- Parameters:
table- The table you wish to editprimaryKey- The primary key of this tableprimaryValue- The value you wish to add/edit for in the primary key columnvalues- The values you wish to add, must be in the correct order based on the table definition and be separated by thevalueSeparator, Must include all values of the table
-
setData
public abstract void setData(Table table, java.lang.String primaryKey, java.lang.String primaryValue, java.lang.String key, java.lang.String value)
Set a single value in a row- Parameters:
table- The table you wish to editprimaryKey- The primary key of the row you wish to editprimaryValue- The primary keys value for the row you wish to editkey- The key of the value you wish to editvalue- The value you wish the key to be set too
-
getLong
public abstract java.lang.Long getLong(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)
Get a value of the type Long- Parameters:
table- The table you wish to accessprimaryKey- The primary key of the row you wish to accessvalue- The value of the primary key in the row you wish to accesskey- The key to the value you wish to access- Returns:
- Returns a long if the data is found or Null if not
-
getString
public abstract java.lang.String getString(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)
Get a value of the type String- Parameters:
table- The table you wish to accessprimaryKey- The primary key of the row you wish to accessvalue- The value of the primary key in the row you wish to accesskey- The key to the value you wish to access- Returns:
- Returns a string if the data is found or Null if not
-
getBoolean
public abstract java.lang.Boolean getBoolean(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)
Get a value of the type Boolean- Parameters:
table- The table you wish to accessprimaryKey- The primary key of the row you wish to accessvalue- The value of the primary key in the row you wish to accesskey- The key to the value you wish to access- Returns:
- Returns a boolean if the data is found or Null if not
-
getObject
public abstract java.lang.Object getObject(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)
Get a value of the type Object- Parameters:
table- The table you wish to accessprimaryKey- The primary key of the row you wish to accessvalue- The value of the primary key in the row you wish to accesskey- The key to the value you wish to access- Returns:
- Returns an object if the data is found or Null if not
-
getLongList
public abstract java.util.List<java.lang.Long> getLongList(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)
Get a list of long, use a non unique primary key and value to get multiple values returned- Parameters:
table- The table you wish to accessprimaryKey- The primary key of the row you wish to accessvalue- The value of the primary key in the row you wish to accesskey- The key to the value you wish to access- Returns:
- Returns a list of long if the data is found or Null if not
-
getStringList
public abstract java.util.List<java.lang.String> getStringList(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)
Get a list of strings, use a non unique primary key and value to get multiple values returned- Parameters:
table- The table you wish to accessprimaryKey- The primary key of the row you wish to accessvalue- The value of the primary key in the row you wish to accesskey- The key to the value you wish to access- Returns:
- Returns a list of string if the data is found or Null if not
-
getEntireColumn
public abstract java.util.List<java.lang.String> getEntireColumn(Table table, java.lang.String key)
Get all the values in a column of a table- Parameters:
table- The table you wish to accesskey- The column you wish to receive values from- Returns:
- Returns a list of string of all the values in the column
-
getEntireRow
public abstract java.util.List<java.lang.String> getEntireRow(Table table, java.lang.String primaryKey, java.lang.String value)
Returns a list of String that contains all the values in a row that matches the primary key and value- Parameters:
table- The table you wish to accessprimaryKey- The primary value of the row you wish to accessvalue- The value of the primary key in the row you wish to access- Returns:
- Returns the first row that matches the criteria, an empty list if no row is found
-
getEntireTable
public abstract java.util.List<java.lang.String> getEntireTable(Table table)
Get a list of all rows in a table, the values are separated withvalueSeparator- Parameters:
table- The table you wish to retrieve- Returns:
- Returns a list of char separated strings containing all values in the table
-
removeData
public abstract void removeData(Table table, java.lang.String key, java.lang.String value)
Removes any row with value in the key column in table- Parameters:
table- The table you wish to editkey- The key you wish to test forvalue- The value required for a record to be deleted
-
removeAllData
public abstract void removeAllData(Table table)
Removes all rows from the given table- Parameters:
table- the table to truncate
-
dropTable
protected abstract void dropTable(Table table)
Drop an entire table- Parameters:
table- The table you wish to drop
-
-