|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.db.DBUtils
public final class DBUtils
provides convenience methods for dealing with database related issues
| Method Summary | ||
|---|---|---|
static boolean |
abort(DBTransaction t)
aborts an ongoing transaction if it is active, or simply returns false. |
|
static
|
commitCall(Callable<T> call,
DBTransaction tx)
commits the given task synchronized to the transaction and aborts the transaction in case of an exception |
|
static void |
commitEntries(Database<?> db,
Iterator<? extends DBEntry> it)
|
|
static
|
commitEntry(Database<?> db,
T entry)
commits the given entry to the database and returns the given entry |
|
static
|
commitEntry(DBClassStore<T> store,
T entry)
the store is used to update/insert the entry and the transaction is committed. |
|
static void |
commitTask(Task<?> task,
DBTransaction tx)
commits the given task synchronized to the transaction and aborts the transaction in case of an exception |
|
static TableModel |
createMappingInfoModel(Database<?> db)
|
|
static TableModel |
createMappingInfoModel(Database<?> db,
Monitor mon)
|
|
static
|
delete(Database<?> db,
Iterable<? extends DBReference> list)
deletes the given entries from the database |
|
static
|
delete(DBClassStore<T> store,
Iterable<T> entries)
deletes the given entries from the database |
|
static
|
deleteIndividually(DBClassStore<T> store,
Filter<? super T> filter)
deletes all entries that pass the given filter individually |
|
static void |
ensureActive(DBTransaction tx)
ensures that the current thread holds a lock on the given transaction and that this transaction is also active |
|
static DBReference |
ensureReferenceString(Database<?> db,
DBReference ref)
|
|
static boolean |
exists(Database<?> db,
DBReference ref)
determines whether there is a relevant store that contains the relevant id for the given reference in the given database |
|
static Set<Class<? extends DBEntry>> |
findStoresWithID(Database<?> db,
Object id)
|
|
static DBEntry |
get(Database<?> db,
DBReference ref)
determines whether there is a relevant store that contains the relevant id for the given reference in the given database. |
|
static
|
getFirstEntry(DBClassStore<T> store,
Filter<? super T> filter)
|
|
static
|
getFirstStub(DBClassStore<T> store,
Filter<? super Stub<?>> filter)
|
|
static
|
getIDExtractor()
|
|
static HashSet<Object> |
getIDSet(Collection<? extends DBReference> col)
|
|
static
|
getRandomEntry(DBClassStore<T> store,
Filter<? super T> filter)
|
|
static
|
getRandomStub(DBClassStore<T> store)
|
|
static
|
handle(DBClassStore<T> store,
Handler<? super T,?> handler,
Filter<? super T> filter,
Monitor monitor,
boolean useCommitNotAbort)
|
|
static
|
insertEntry(DBClassStore<T> store,
T entry)
the store is used to insert the entry and the transaction is committed. |
|
static
|
iterate(DBClassStore<T> store,
Filter<? super T> filter)
|
|
static
|
listEntries(DBClassStore<T> store,
Filter<? super T> filter)
|
|
static
|
listEntries(DBClassStore<T> store,
Filter<? super T> filter,
int maxEntries)
|
|
static DatabaseChangeMonitor |
listenWhileVisible(JComponent c,
Database<?> db,
DatabaseChangeListener listener)
uses an AncestorListener on the given component to enable the listener only while it is displayed |
|
static
|
listStubs(DBClassStore<T> store,
Filter<? super Stub<?>> filter)
|
|
static
|
listStubs(DBClassStore<T> store,
Filter<? super Stub<?>> filter,
int maxEntries)
|
|
static Stub<?> |
loadStub(Database<?> db,
DBReference ref)
reloads a reference as a stub, so that the display value is properly initialized. |
|
static
|
mapEntries(Collection<T> entries,
Filter<? super T> filter)
|
|
static
|
mapEntries(DBClassStore<T> store,
Filter<? super T> filter)
|
|
static
|
mapEntries(DBClassStore<T> store,
PatternExtractor<? super T,P> pe,
Filter<? super T> filter)
|
|
static
|
mapStubs(Collection<Stub<T>> stubs,
Filter<? super Stub<T>> filter)
|
|
static
|
mapStubs(DBClassStore<T> store,
Filter<? super Stub<?>> filter)
|
|
static boolean |
referenceRefersToEntry(DBReference ref,
DBEntry entry)
|
|
static
|
runInTransaction(Callable<T> call,
DBTransaction t,
boolean useCommitNotAbort)
the given task is guaranteed to run in an active transaction, where this method only begins a transaction, if the given transaction is not active, yet. |
|
static void |
runInTransaction(Task<? extends Exception> task,
DBTransaction t,
boolean useCommitNotAbort)
the given task is guaranteed to run in an active transaction, where this method only begins a transaction, if the given transaction is not active, yet. |
|
static void |
store(Database<?> db,
DBEntry... entries)
|
|
static void |
store(Database<?> db,
Iterator<? extends DBEntry> i)
|
|
static
|
store(DBClassStore<T> store,
Collection<T> entries)
inserts/updates the given entries in the database depending on whether it already exists |
|
static
|
store(DBClassStore<T> store,
Iterator<T> entries)
inserts/updates the given entries in the database depending on whether it already exists |
|
static
|
store(DBClassStore<T> store,
T entry)
inserts/updates the given entry into the database depending on whether it already exists |
|
static DBClassStore<DBEntry> |
unsaveStore(DBClassStore<?> store)
|
|
static
|
updateAll(DBClassStore<T> store,
Processor<T,E> handler,
Filter<? super T> filter)
|
|
static
|
updateAll(DBClassStore<T> store,
Processor<T,E> handler,
Filter<? super T> filter,
Monitor mon)
|
|
static
|
updateEntry(DBClassStore<T> store,
T entry)
the store is used to update the entry and the transaction is committed. |
|
static
|
wrapTransactional(DBTransaction tx,
T instance,
Class<T> transactionalInterface)
wraps a given instance into a proxy that calls all methods of the provided interface in a proper transactional context. |
|
static
|
wrapWithUser(Callable<T> call,
DBTransaction t,
User user)
allows to wrap the given call so that it runs in the context of the given user as the current user for the database |
|
static
|
wrapWithUser(Task<E> task,
DBTransaction t,
User user)
allows to wrap the given task so that it runs in the context of the given user as the current user for the database |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <T extends DBEntry> PatternExtractor<T,Object> getIDExtractor()
public static <T> T wrapTransactional(DBTransaction tx,
T instance,
Class<T> transactionalInterface)
tx - the transaction that all calls should be synchronized withinstance - the object that eventually executes all calls to the proxytransactionalInterface - the interface that is to be exposed by the
returned proxy in a transactionally consistent way
TransactionRequired
public static <E extends Exception> Task<E> wrapWithUser(Task<E> task,
DBTransaction t,
User user)
public static <T> Callable<T> wrapWithUser(Callable<T> call,
DBTransaction t,
User user)
public static void runInTransaction(Task<? extends Exception> task,
DBTransaction t,
boolean useCommitNotAbort)
throws DatabaseException
DatabaseException
public static <T> T runInTransaction(Callable<T> call,
DBTransaction t,
boolean useCommitNotAbort)
throws DatabaseException
DatabaseException
public static <T extends DBEntry,E extends Exception> void updateAll(DBClassStore<T> store,
Processor<T,E> handler,
Filter<? super T> filter)
throws DatabaseException
DatabaseException
public static <T extends DBEntry,E extends Exception> void updateAll(DBClassStore<T> store,
Processor<T,E> handler,
Filter<? super T> filter,
Monitor mon)
throws DatabaseException,
CancellationWarning
DatabaseException
CancellationWarning
public static <T extends DBEntry> void handle(DBClassStore<T> store,
Handler<? super T,?> handler,
Filter<? super T> filter,
Monitor monitor,
boolean useCommitNotAbort)
throws DatabaseException
DatabaseException
public static void commitTask(Task<?> task,
DBTransaction tx)
throws DatabaseException
DatabaseException
public static <T> T commitCall(Callable<T> call,
DBTransaction tx)
throws DatabaseException
DatabaseExceptionpublic static boolean abort(DBTransaction t)
public static void ensureActive(DBTransaction tx)
throws TransactionException
TransactionException - if any of the two assumption are not met
public static <T extends DBEntry> T commitEntry(Database<?> db,
T entry)
throws DatabaseException
DatabaseException
public static void commitEntries(Database<?> db,
Iterator<? extends DBEntry> it)
throws DatabaseException
DatabaseException
public static boolean exists(Database<?> db,
DBReference ref)
throws DatabaseException
DatabaseException
public static DBEntry get(Database<?> db,
DBReference ref)
throws DatabaseException
DatabaseException
public static Stub<?> loadStub(Database<?> db,
DBReference ref)
throws DatabaseException
DatabaseException
public static Set<Class<? extends DBEntry>> findStoresWithID(Database<?> db,
Object id)
throws DatabaseException
DatabaseException
public static <T extends DBEntry> T commitEntry(DBClassStore<T> store,
T entry)
throws DatabaseException
Serializable,
this method will use DBClassStore.insertAsNew(DBEntry)
to store the entry and return the entry that has been saved to the database (instead of the given one).
DatabaseException
public static <T extends DBEntry> T insertEntry(DBClassStore<T> store,
T entry)
throws DatabaseException
DatabaseException
public static <T extends DBEntry> T updateEntry(DBClassStore<T> store,
T entry)
throws DatabaseException
DatabaseException
public static boolean referenceRefersToEntry(DBReference ref,
DBEntry entry)
public static DBClassStore<DBEntry> unsaveStore(DBClassStore<?> store)
public static <T extends DBEntry> Stub<T> getFirstStub(DBClassStore<T> store,
Filter<? super Stub<?>> filter)
throws DatabaseException
DatabaseException
public static <T extends DBEntry> ArrayList<Stub<T>> listStubs(DBClassStore<T> store,
Filter<? super Stub<?>> filter)
throws DatabaseException
DatabaseException
public static <T extends DBEntry> ArrayList<Stub<T>> listStubs(DBClassStore<T> store,
Filter<? super Stub<?>> filter,
int maxEntries)
throws DatabaseException
DatabaseException
public static <T extends DBEntry> T getRandomEntry(DBClassStore<T> store,
Filter<? super T> filter)
throws DatabaseException
DatabaseException
public static <T extends DBEntry> Stub<T> getRandomStub(DBClassStore<T> store)
throws DatabaseException
DatabaseException
public static <T extends DBEntry> T getFirstEntry(DBClassStore<T> store,
Filter<? super T> filter)
throws DatabaseException
DatabaseException
public static <T extends DBEntry> Iterable<T> iterate(DBClassStore<T> store,
Filter<? super T> filter)
throws DatabaseException
DatabaseException
public static <T extends DBEntry> ArrayList<T> listEntries(DBClassStore<T> store,
Filter<? super T> filter)
throws DatabaseException
DatabaseException
public static <T extends DBEntry> ArrayList<T> listEntries(DBClassStore<T> store,
Filter<? super T> filter,
int maxEntries)
throws DatabaseException
DatabaseException
public static void store(Database<?> db,
DBEntry... entries)
throws DatabaseException
DatabaseException
public static void store(Database<?> db,
Iterator<? extends DBEntry> i)
throws DatabaseException
DatabaseException
public static <T extends DBEntry> void store(DBClassStore<T> store,
T entry)
throws DatabaseException
DatabaseException
public static <T extends DBEntry> void store(DBClassStore<T> store,
Collection<T> entries)
throws DatabaseException
DatabaseException
public static <T extends DBEntry> void store(DBClassStore<T> store,
Iterator<T> entries)
throws DatabaseException
DatabaseException
public static <T extends DBEntry> int delete(Database<?> db,
Iterable<? extends DBReference> list)
throws DatabaseException
DatabaseException
public static <T extends DBEntry> int delete(DBClassStore<T> store,
Iterable<T> entries)
throws DatabaseException
DatabaseException
public static <T extends DBEntry> int deleteIndividually(DBClassStore<T> store,
Filter<? super T> filter)
throws DatabaseException
DatabaseExceptionpublic static HashSet<Object> getIDSet(Collection<? extends DBReference> col)
public static <T extends DBEntry> Hashtable<Object,Stub<T>> mapStubs(DBClassStore<T> store,
Filter<? super Stub<?>> filter)
throws DatabaseException
DatabaseException
public static <T extends DBEntry> Hashtable<Object,T> mapEntries(DBClassStore<T> store,
Filter<? super T> filter)
throws DatabaseException
DatabaseException
public static <T extends DBEntry,P> Hashtable<Object,P> mapEntries(DBClassStore<T> store,
PatternExtractor<? super T,P> pe,
Filter<? super T> filter)
throws DatabaseException
DatabaseException
public static <T extends DBEntry> Hashtable<Object,T> mapEntries(Collection<T> entries,
Filter<? super T> filter)
public static <T extends DBEntry> Hashtable<Object,Stub<T>> mapStubs(Collection<Stub<T>> stubs,
Filter<? super Stub<T>> filter)
public static DatabaseChangeMonitor listenWhileVisible(JComponent c,
Database<?> db,
DatabaseChangeListener listener)
AncestorListener on the given component to enable the listener only while it is displayed
public static DBReference ensureReferenceString(Database<?> db,
DBReference ref)
throws DatabaseException
DatabaseException
public static TableModel createMappingInfoModel(Database<?> db)
throws DatabaseException,
OfficeException
DatabaseException
OfficeException
public static TableModel createMappingInfoModel(Database<?> db,
Monitor mon)
throws OfficeException,
DatabaseException
OfficeException
DatabaseException
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||