|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvooga.engine.resource.DBHandler
public class DBHandler
DBHandler is a class that allows static access to a database for reading and writing data. The DBHandler class allows for basic interactions with an SQLite database. Currently, its functionality includes creating tables, fetching columns, and adding and deleting table rows. Different types of data can be stored in the database columns as dictated by the built-in data type constants in the Column class. As SQLite is loosely typed, it is usually fine to use the "NONE" data type for all columns.
Constructor Summary | |
---|---|
DBHandler()
|
Method Summary | ||
---|---|---|
static boolean |
addRow(Entry<?>... entries)
Adds a row of data to the database |
|
static boolean |
createTable(java.lang.String tableName,
Column... columns)
Creates a new table in the database with the specified name and columns |
|
static boolean |
createTable(java.lang.String tableName,
java.lang.String... columnNames)
Creates a new table in the database with the specified name and columns of the BLOB data type |
|
static boolean |
deleteRow(Entry<?>... entries)
Deletes a row of data from the database |
|
static java.util.List<java.lang.String> |
getColumn(java.lang.String fieldName)
Retrieves a column of information from the database as strings |
|
static
|
getColumn(java.lang.String fieldName,
T t)
Retrieves a column of information from the database in the specified format |
|
static boolean |
open(java.lang.String dbFileName)
Opens a connection to the database file specified. |
|
static boolean |
setTable(java.lang.String tableName)
Sets the active table on which other operations are performed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DBHandler()
Method Detail |
---|
public static boolean open(java.lang.String dbFileName)
dbFileName
- Path to database file.
public static boolean createTable(java.lang.String tableName, Column... columns)
tableName
- Name of tablecolumns
- The columns the table will have
public static boolean createTable(java.lang.String tableName, java.lang.String... columnNames)
tableName
- Name of tablecolumnNames
- Names of columns
public static boolean setTable(java.lang.String tableName)
tableName
- Name of table
public static java.util.List<java.lang.String> getColumn(java.lang.String fieldName)
fieldName
- Name of field to fetch
public static <T> java.util.List<T> getColumn(java.lang.String fieldName, T t)
T
- A class which extends Integer, String, Double, BooleanfieldName
- Name of field to fetcht
- An object of the class of the desired output
public static boolean addRow(Entry<?>... entries)
entries
- A set of field,data pairs
public static boolean deleteRow(Entry<?>... entries)
entries
- A set of field,data pairs a row must satisfy (via LIKE
operator) to be deleted
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |