this.initBackend();
}
- /**
- * Adds given contact instance to database
- *
- * @param contact Contact instance
- * @throws org.mxchange.addressbook.exceptions.ContactAlreadyAddedException If the contact instance is already found
- */
@Override
public void addContact (final Contact contact) throws ContactAlreadyAddedException {
// Trace message
// Debug message
this.getLogger().debug(MessageFormat.format("result={0}", result)); //NOI18N
- } catch (final IOException | BadTokenException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
+ } catch (final IOException | BadTokenException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException | CorruptedDatabaseFileException ex) {
// Abort here
this.abortProgramWithException(ex);
}
this.getLogger().trace("CALLED!"); //NOI18N
}
- /**
- * Shuts down the database layer
- * @throws java.sql.SQLException If an SQL error occurs
- * @throws java.io.IOException If an IO error occurs
- */
@Override
public void doShutdown () throws SQLException, IOException {
// Trace message
throw new UnsupportedOperationException("Not supported yet: rowIndex=" + rowIndex);
}
- /**
- * Checks if given Contact is found
- *
- * @param contact Contact instance to check
- * @return Whether the given Contact instance is found
- */
@Override
- public boolean isContactFound (final Contact contact) throws BadTokenException {
+ public boolean isContactFound (final Contact contact) throws BadTokenException, IOException, CorruptedDatabaseFileException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
// Trace message
this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
// Default is not found
boolean isFound = false;
+ // Init search instance (but empty)
+ SearchableCriteria criteria = new SearchCriteria();
+
+ // Look for all entries and compare here. Else all entries needs to be compared with many AND statements
+ Result<? extends Storeable> result = this.getBackend().doSelectByCriteria(criteria);
+
+ // Debug message
+ this.getLogger().debug(MessageFormat.format("result({0})={1}", result.size(), result));
// Start iteration
- Iterator<? extends Storeable> iterator = this.getBackend().iterator();
+ Iterator<? extends Storeable> iterator = result.iterator();
// Check all entries
while (iterator.hasNext()) {
return isFound;
}
- /**
- * Checks whether own contact is found in database
- *
- * @return Whether own contact is found
- * @throws org.mxchange.jcore.exceptions.BadTokenException Continued throw
- * @throws org.mxchange.jcore.exceptions.CorruptedDatabaseFileException If the database file is damaged
- * @throws java.lang.NoSuchMethodException If a method cannot be found
- * @throws java.lang.IllegalAccessException If a method is not accessible
- * @throws java.lang.reflect.InvocationTargetException Any other problems?
- */
@Override
public boolean isOwnContactFound () throws SQLException, IOException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
// Get search criteria instance