From b7663925811eb300b17d07e3f2a0fe6ef44ed337 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Mon, 24 Aug 2015 14:29:18 +0200 Subject: [PATCH] =?utf8?q?Final=20(hopeful)=20fixes=20for=20new=20jcore.?= =?utf8?q?=20Still=20some=20new=20method(s)=20need(s)=20implementation.=20?= =?utf8?q?Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../AddressbookContactDatabaseFrontend.java | 41 +++++-------------- 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactDatabaseFrontend.java b/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactDatabaseFrontend.java index 25f8496..3577e17 100644 --- a/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactDatabaseFrontend.java +++ b/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactDatabaseFrontend.java @@ -83,12 +83,6 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp 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 @@ -127,7 +121,7 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp // 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); } @@ -136,11 +130,6 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp 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 @@ -226,14 +215,8 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp 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 @@ -246,8 +229,16 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp // 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 result = this.getBackend().doSelectByCriteria(criteria); + + // Debug message + this.getLogger().debug(MessageFormat.format("result({0})={1}", result.size(), result)); // Start iteration - Iterator iterator = this.getBackend().iterator(); + Iterator iterator = result.iterator(); // Check all entries while (iterator.hasNext()) { @@ -272,16 +263,6 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp 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 -- 2.39.5