Class DataStore

  • Direct Known Subclasses:
    MySQL

    public abstract class DataStore
    extends java.lang.Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  DataStore.StorageType  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      java.lang.String valueSeparator
      This 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 void addData​(Table table, java.lang.String values)
      Add data to a table, this may result in duplicate values
      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
      abstract void closeConnection()
      Closes any currently open connections to the database
      void convertData​(DataStore to, java.util.List<Table> tables)  
      protected abstract void dropTable​(Table table)
      Drop an entire table
      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
      abstract java.util.List<java.lang.String> getEntireColumn​(Table table, java.lang.String key)
      Get all the values in a column of a table
      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
      abstract java.util.List<java.lang.String> getEntireTable​(Table table)
      Get a list of all rows in a table, the values are separated with valueSeparator
      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
      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
      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
      abstract DataStore.StorageType getStorageType()
      Get the storage type
      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
      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
      abstract void initialiseDataStore()
      This will create and necessary files and generate tables
      boolean isAsync()
      Check if operations are being done asynchronously
      abstract void removeAllData​(Table table)
      Removes all rows from the given table
      abstract void removeData​(Table table, java.lang.String key, java.lang.String value)
      Removes any row with value in the key column in table
      void setAsync​(boolean isAsync)
      Enable or disable async operations
      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
      abstract void shutdown()
      Shutdown will close any connections and shutdown the connection manager
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • valueSeparator

        public java.lang.String valueSeparator
        This separator should be used when submitting values in the addData methods
    • 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 too
        values - The values you wish to add, must be in the correct order based on the table definition and be separated by the valueSeparator, 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 edit
        primaryKey - The primary key of this table
        primaryValue - The value you wish to add/edit for in the primary key column
        values - The values you wish to add, must be in the correct order based on the table definition and be separated by the valueSeparator, 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 edit
        primaryKey - The primary key of the row you wish to edit
        primaryValue - The primary keys value for the row you wish to edit
        key - The key of the value you wish to edit
        value - 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 access
        primaryKey - The primary key of the row you wish to access
        value - The value of the primary key in the row you wish to access
        key - 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 access
        primaryKey - The primary key of the row you wish to access
        value - The value of the primary key in the row you wish to access
        key - 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 access
        primaryKey - The primary key of the row you wish to access
        value - The value of the primary key in the row you wish to access
        key - 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 access
        primaryKey - The primary key of the row you wish to access
        value - The value of the primary key in the row you wish to access
        key - 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 access
        primaryKey - The primary key of the row you wish to access
        value - The value of the primary key in the row you wish to access
        key - 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 access
        primaryKey - The primary key of the row you wish to access
        value - The value of the primary key in the row you wish to access
        key - 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 access
        key - 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 access
        primaryKey - The primary value of the row you wish to access
        value - 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 with valueSeparator
        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 edit
        key - The key you wish to test for
        value - 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
      • convertData

        public void convertData​(DataStore to,
                                java.util.List<Table> tables)