/** * Makes any edits necessary in the SQL string for it to be compatible with the database in use. * * @return * @throws SQLException */ public static String getScrubSQL(String sql) throws SQLException { if (isMapNull()) throw new NullDatabaseMapException("No database map set!"); return dbMap.getScrubSQL(sql); }
public static String getSelectLastInsertIdentity() { if (isMapNull()) throw new NullDatabaseMapException("No database map set!"); return dbMap.getSelectLastInsertIdentity(); }
public static int getResultSetType() { if (isMapNull()) throw new NullDatabaseMapException("No database map set!"); return dbMap.getResultSetType(); }
/** * Gets an in memory DB connection. Will load DB Driver if not already loaded. * * @return Connection to In Memory Database. */ public static Connection getMemoryConnection() { if (!isMapLoaded()) LoadSQLiteDriver(); try { return DriverManager.getConnection(dbMap.getConnectionString()); } catch (SQLException e) { throw new CannotLoadDatabaseMapDriverException("Error in DatabaseConfig, could not retrieve connection to in memory database.", e); } }
/** * Sets what database will be used and loads the database driver, based on what DBmap is provided. */ private static void LoadSQLiteDriver() { if (isMapNull()) throw new NullDatabaseMapException("Error in DatabaseConfig: DatabaseMap has not been set."); try { Class.forName(dbMap.getDriverClassName()).newInstance(); } catch (InstantiationException e) { throw new CannotLoadDatabaseMapDriverException("Error in DatabaseConfig: SQLite driver could not be instantiated;", e); } catch (IllegalAccessException e) { throw new CannotLoadDatabaseMapDriverException("Error in DatabaseConfig: SQLite driver could not be accessed;", e); } catch (ClassNotFoundException e) { throw new CannotLoadDatabaseMapDriverException("Error in DatabaseConfig: SQLite driver class could not be found;", e); } isLoaded = true; }
public synchronized boolean advanceTo(long endingTime) { if (endingTime - currentTime < 0 || enqueuedTaskCount() < 1) { return false; } int runCount = 0; while (nextTaskIsScheduledBefore(endingTime)) { runOneTask(); ++runCount; } currentTime = endingTime; return runCount > 0; }
public synchronized boolean runOneTask() { if (enqueuedTaskCount() < 1) { return false; } PostedRunnable postedRunnable = postedRunnables.remove(0); currentTime = postedRunnable.scheduledTime; postedRunnable.run(); return true; }
/** * Causes {@link Runnable}s that have been scheduled to run immediately to actually run. Does not advance the * scheduler's clock; */ public void idle() { scheduler.advanceBy(0); }
/** * Causes all of the {@link Runnable}s that have been scheduled to run while advancing the scheduler's clock to the * start time of the last scheduled {@link Runnable}. */ public void runToEndOfTasks() { scheduler.advanceToLastPostedRunnable(); }
@Override public void execute(Runnable runnable) { submit(runnable); } }
/** * Causes only one of the next {@link Runnable}s that have been scheduled to run while advancing the scheduler's * clock to its start time. Only one {@link Runnable} will run even if more than one has ben scheduled to run at the * same time. */ public void runOneTask() { scheduler.runOneTask(); }
public boolean postAtFrontOfQueue(Runnable runnable) { if (!quit) { scheduler.postAtFrontOfQueue(runnable); return true; } else { return false; } }
/** * Causes all enqueued tasks to be discarded */ public void reset() { scheduler.reset(); }
/** * Causes the next {@link Runnable}(s) that have been scheduled to run while advancing the scheduler's clock to its * start time. If more than one {@link Runnable} is scheduled to run at this time then they will all be run. */ public void runToNextTask() { scheduler.advanceToNextPostedRunnable(); }
public synchronized boolean advanceBy(long intervalMs) { long endingTime = currentTime + intervalMs; return advanceTo(endingTime); }
public synchronized boolean areAnyRunnable() { return nextTaskIsScheduledBefore(currentTime); }
public synchronized boolean runTasks(int howMany) { if (enqueuedTaskCount() < howMany) { return false; } while (howMany > 0) { PostedRunnable postedRunnable = postedRunnables.remove(0); currentTime = postedRunnable.scheduledTime; postedRunnable.run(); howMany--; } return true; }
/** * Causes {@link Runnable}s that have been scheduled to run within the next {@code intervalMillis} milliseconds to * run while advancing the scheduler's clock. * * @param intervalMillis milliseconds to advance */ public void idle(long intervalMillis) { scheduler.advanceBy(intervalMillis); }
public synchronized void unPause() { paused = false; advanceToLastPostedRunnable(); }
@Override public Future<?> submit(Runnable runnable) { return submit(runnable, null); }