Class SQLiteUtils
- java.lang.Object
-
- org.openstreetmap.atlas.checks.utility.SQLiteUtils
-
- All Implemented Interfaces:
java.io.Serializable
public class SQLiteUtils extends java.lang.Object implements java.io.SerializableThis utility class is designed to take an SQLite database, and manage connections for you. It is designed to be serializable, such that when it is deserialized/unserialized, everything just works (tm).- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringMEMORY_DBThe db "file" for in memory databases
-
Constructor Summary
Constructors Constructor Description SQLiteUtils(ExternalDataFetcher fileFetcher, java.lang.String database, java.lang.String table)Initialize a database
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear cached datajava.lang.StringgetFile()Get the file for the databasejava.util.Map<java.lang.String,java.lang.Object>getRows(java.util.Map<java.lang.String,java.lang.String> values)Get row(s) from the tablestatic booleanisValidDatabase(java.lang.String database)Check that a database exists
-
-
-
Field Detail
-
MEMORY_DB
public static final java.lang.String MEMORY_DB
The db "file" for in memory databases- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SQLiteUtils
public SQLiteUtils(ExternalDataFetcher fileFetcher, java.lang.String database, java.lang.String table)
Initialize a database- Parameters:
fileFetcher- The file fetcher to use to get filesdatabase- A database to use (should be checked first withisValidDatabase(java.lang.String))table- The default table to use, if a passed table is null or blank
-
-
Method Detail
-
isValidDatabase
public static boolean isValidDatabase(java.lang.String database)
Check that a database exists- Parameters:
database- The location of the database (may be":memory:")- Returns:
trueif the database file exists
-
clear
public void clear()
Clear cached data
-
getFile
public java.lang.String getFile()
Get the file for the database- Returns:
- The path for the database
-
getRows
public java.util.Map<java.lang.String,java.lang.Object> getRows(java.util.Map<java.lang.String,java.lang.String> values)
Get row(s) from the table- Parameters:
values- The values to filter by (column name, value )- Returns:
- The rows that match for the query (
SELECT * FROM {table} WHERE {key1}={value1} AND ...)
-
-