From 4890815cd2db9ccc58e370a80b31357cbb290685 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 28 Aug 2015 12:09:19 +0200 Subject: [PATCH] =?utf8?q?Continued:=20-=20contacts=20are=20now=20fully=20?= =?utf8?q?comparable=20-=20this=20project=20has=20double=20libraries=20and?= =?utf8?q?=20source=20packages,=20please=20try=20to=20fix=20it=20Signed-of?= =?utf8?q?f-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- nbproject/build-impl.xml | 2859 ++++++++--------- nbproject/genfiles.properties | 16 +- nbproject/project.properties | 3 +- nbproject/project.xml | 34 +- .../mxchange/jcore/BaseFrameworkSystem.java | 16 +- .../mxchange/jcore/contact/BaseContact.java | 57 +- src/org/mxchange/jcore/contact/Contact.java | 24 +- .../criteria/searchable/SearchCriteria.java | 4 +- .../searchable/SearchableCriteria.java | 10 +- .../database/backend/BaseDatabaseBackend.java | 6 +- .../database/backend/DatabaseBackend.java | 6 +- .../base64/Base64CsvDatabaseBackend.java | 14 +- .../datasource/DataSourceDatabaseBackend.java | 6 +- .../backend/mysql/MySqlDatabaseBackend.java | 10 +- .../frontend/BaseDatabaseFrontend.java | 10 +- .../database/frontend/DatabaseFrontend.java | 18 +- .../jcore/database/result/DatabaseResult.java | 24 +- .../jcore/database/result/Result.java | 12 +- .../storage/{Storeable.java => Storable.java} | 2 +- 19 files changed, 1592 insertions(+), 1539 deletions(-) rename src/org/mxchange/jcore/database/storage/{Storeable.java => Storable.java} (97%) diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index a3546ea..f53d537 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -1,1438 +1,1421 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 9369a62..7e1816b 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=e30ed0d7 -build.xml.script.CRC32=b373860f -build.xml.stylesheet.CRC32=8064a381@1.75.2.48 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=e30ed0d7 -nbproject/build-impl.xml.script.CRC32=ecb8c0e4 -nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 +build.xml.data.CRC32=7d66003f +build.xml.script.CRC32=b373860f +build.xml.stylesheet.CRC32=8064a381@1.75.2.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=7d66003f +nbproject/build-impl.xml.script.CRC32=2f6e18c1 +nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 diff --git a/nbproject/project.properties b/nbproject/project.properties index 8659f92..4377cb9 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -101,5 +101,4 @@ source.encoding=UTF-8 source.reference.commons-codec-1.10.jar=/home/quix0r/MyProjects/JARs/commons-codec-1.10-sources.jar source.reference.commons-lang3-3.4.jar=C:\\Users\\KLC\\JARs\\commons-lang3-3.4-src.zip!/commons-lang3-3.4-src/src/main/java/ source.reference.log4j-api-2.3.jar=/home/quix0r/MyProjects/JARs/log4j-api-2.3-sources.jar -src.dir=src -test.src.dir=test +src.src.dir=src diff --git a/nbproject/project.xml b/nbproject/project.xml index 00d16bc..27f0f87 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -1,18 +1,16 @@ - - - org.netbeans.modules.java.j2seproject - - - jcore - - - - - - - - - .\lib\nblibraries.properties - - - + + + org.netbeans.modules.java.j2seproject + + + jcore + + + + + + + .\lib\nblibraries.properties + + + diff --git a/src/org/mxchange/jcore/BaseFrameworkSystem.java b/src/org/mxchange/jcore/BaseFrameworkSystem.java index eb66922..d4887f1 100644 --- a/src/org/mxchange/jcore/BaseFrameworkSystem.java +++ b/src/org/mxchange/jcore/BaseFrameworkSystem.java @@ -41,7 +41,7 @@ import org.mxchange.jcore.client.Client; import org.mxchange.jcore.contact.Contact; import org.mxchange.jcore.database.backend.DatabaseBackend; import org.mxchange.jcore.database.frontend.DatabaseFrontend; -import org.mxchange.jcore.database.storage.Storeable; +import org.mxchange.jcore.database.storage.Storable; import org.mxchange.jcore.manager.Manageable; /** @@ -841,7 +841,7 @@ public class BaseFrameworkSystem implements FrameworkInterface { * @throws java.lang.IllegalAccessException If the method cannot be accessed * @throws java.lang.reflect.InvocationTargetException Any other problems? */ - protected Iterator> fieldIterator (final Storeable instance, final String className) throws IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { + protected Iterator> fieldIterator (final Storable instance, final String className) throws IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { // Trace message this.getLogger().trace(MessageFormat.format("instance={0},className={1} - CALLED!", instance, className)); //NOI18N @@ -1120,9 +1120,9 @@ public class BaseFrameworkSystem implements FrameworkInterface { } /** - * Some "setter" for a value in given Storeable instance and target class + * Some "setter" for a value in given Storable instance and target class * - * @param instance An instance of a Storeable class + * @param instance An instance of a Storable class * @param targetClass The target class (where the field resides) * @param columnName Column name (= field name) * @param value Value to set @@ -1130,7 +1130,7 @@ public class BaseFrameworkSystem implements FrameworkInterface { * @throws java.lang.IllegalAccessException If the setter cannot be accessed * @throws java.lang.reflect.InvocationTargetException Any other problem? */ - protected void setValueInStoreableFromColumn (final Storeable instance, final String targetClass, final String columnName, final Object value) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + protected void setValueInStoreableFromColumn (final Storable instance, final String targetClass, final String columnName, final Object value) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { // Trace message this.getLogger().trace(MessageFormat.format("instance={0},targetClass={1},columnName={2},value={3} - CALLED!", instance, targetClass, columnName, value)); //NOI18N @@ -1163,9 +1163,9 @@ public class BaseFrameworkSystem implements FrameworkInterface { } /** - * Some "getter" for a value from given Storeable instance and target class + * Some "getter" for a value from given Storable instance and target class * - * @param instance An instance of a Storeable class + * @param instance An instance of a Storable class * @param targetClass The target class (where the field resides) * @param columnName Column name (= field name) * @return value Value to get @@ -1173,7 +1173,7 @@ public class BaseFrameworkSystem implements FrameworkInterface { * @throws java.lang.IllegalAccessException If the getter cannot be accessed * @throws java.lang.reflect.InvocationTargetException Some other problems? */ - protected Object getValueInStoreableFromColumn (final Storeable instance, final String targetClass, final String columnName) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + protected Object getValueInStoreableFromColumn (final Storable instance, final String targetClass, final String columnName) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { // Trace message this.getLogger().trace(MessageFormat.format("instance={0},targetClass={1},columnName={2} - CALLED!", instance, targetClass, columnName)); //NOI18N diff --git a/src/org/mxchange/jcore/contact/BaseContact.java b/src/org/mxchange/jcore/contact/BaseContact.java index a6238a9..b0da086 100644 --- a/src/org/mxchange/jcore/contact/BaseContact.java +++ b/src/org/mxchange/jcore/contact/BaseContact.java @@ -31,7 +31,12 @@ import org.mxchange.jcore.client.Client; * @author Roland Haeder * @version 0.0 */ -public class BaseContact extends BaseFrameworkSystem implements Contact { +public class BaseContact extends BaseFrameworkSystem implements Contact, Comparable { + + /** + * Id number + */ + private Long contactId; /** * Birth day @@ -247,6 +252,24 @@ public class BaseContact extends BaseFrameworkSystem implements Contact { this.companyName = companyName; } + /** + * Id number + * @return the contactId + */ + @Override + public final Long getContactId () { + return this.contactId; + } + + /** + * Id number + * @param contactId the contactId to set + */ + @Override + public final void setContactId (final Long contactId) { + this.contactId = contactId; + } + /** * Country code * @@ -616,4 +639,36 @@ public class BaseContact extends BaseFrameworkSystem implements Contact { protected final void enableFlagOwnContact () { this.ownContact = true; } + + /** + * Compares two contacts with each other + * + * @param contact Contact comparator + * @return Comparison value + */ + @Override + public int compareTo (final Contact contact) { + // Trace message + this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N + + // contact should not be null + if (null == contact) { + throw new NullPointerException("contact is null"); //NOI18N + } + + // Debug message + this.getLogger().debug(MessageFormat.format("this.id={0},contact.id={1}", this.getContactId(), contact.getContactId())); //NOI18N + + // Is the contactId the same? + if (Objects.equals(this.getContactId(), contact.getContactId())) { + // Same contactId, means same contact + return 0; + } else if (this.getContactId() > contact.getContactId()) { + // This contactId is larger than compared to + return -1; + } + + // The other contactId is larger + return 1; + } } diff --git a/src/org/mxchange/jcore/contact/Contact.java b/src/org/mxchange/jcore/contact/Contact.java index cf78950..2f2f92a 100644 --- a/src/org/mxchange/jcore/contact/Contact.java +++ b/src/org/mxchange/jcore/contact/Contact.java @@ -21,14 +21,14 @@ import java.lang.reflect.InvocationTargetException; import java.util.Iterator; import java.util.Map; import org.mxchange.jcore.client.Client; -import org.mxchange.jcore.database.storage.Storeable; +import org.mxchange.jcore.database.storage.Storable; /** * A general contact interface * * @author Roland Haeder */ -public interface Contact extends Storeable { +public interface Contact extends Storable, Comparable { /** * Returns an iterator of all values from this object * @@ -46,6 +46,18 @@ public interface Contact extends Storeable { */ public String getTranslatedGender (); + /** + * Id number + * @return the contactId + */ + public Long getContactId (); + + /** + * Id number + * @param contactId the contactId to set + */ + public void setContactId (final Long contactId); + /** * Gender of the contact * @@ -269,4 +281,12 @@ public interface Contact extends Storeable { * @param client Client instance to call back */ public void show (final Client client); + + /** + * Compare method + * @param contact Contact to compare to + * @return Comparison value + */ + @Override + public int compareTo (final Contact contact); } diff --git a/src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java b/src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java index b276026..668425d 100644 --- a/src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java +++ b/src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java @@ -21,7 +21,7 @@ import java.text.MessageFormat; import java.util.HashMap; import java.util.Map; import org.mxchange.jcore.criteria.BaseCriteria; -import org.mxchange.jcore.database.storage.Storeable; +import org.mxchange.jcore.database.storage.Storable; /** * A search criteria class @@ -66,7 +66,7 @@ public class SearchCriteria extends BaseCriteria implements SearchableCriteria { } @Override - public boolean matches (final Storeable storeable) throws IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { + public boolean matches (final Storable storeable) throws IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { // Trace message this.getLogger().trace(MessageFormat.format("storeable={0} - CALLED!", storeable)); //NOI18N diff --git a/src/org/mxchange/jcore/criteria/searchable/SearchableCriteria.java b/src/org/mxchange/jcore/criteria/searchable/SearchableCriteria.java index e0628f2..dd2ae3c 100644 --- a/src/org/mxchange/jcore/criteria/searchable/SearchableCriteria.java +++ b/src/org/mxchange/jcore/criteria/searchable/SearchableCriteria.java @@ -18,7 +18,7 @@ package org.mxchange.jcore.criteria.searchable; import java.lang.reflect.InvocationTargetException; import org.mxchange.jcore.criteria.Criteria; -import org.mxchange.jcore.database.storage.Storeable; +import org.mxchange.jcore.database.storage.Storable; /** * A searchable criteria @@ -27,16 +27,16 @@ import org.mxchange.jcore.database.storage.Storeable; */ public interface SearchableCriteria extends Criteria { /** - * Checks if the given instance of a Storeable class matches + * Checks if the given instance of a Storable class matches * - * @param storeable A Storeable instance to check - * @return Whether the Storeable instance matches + * @param storeable A Storable instance to check + * @return Whether the Storable instance matches * @throws IllegalArgumentException Some implementations may throw this * @throws java.lang.NoSuchMethodException If the invoked method was not found * @throws java.lang.IllegalAccessException If the method cannot be accessed * @throws java.lang.reflect.InvocationTargetException Any other problems? */ - public boolean matches (final Storeable storeable) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException; + public boolean matches (final Storable storeable) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException; /** * Setter for limit of possible matches diff --git a/src/org/mxchange/jcore/database/backend/BaseDatabaseBackend.java b/src/org/mxchange/jcore/database/backend/BaseDatabaseBackend.java index 6a38586..69192fe 100644 --- a/src/org/mxchange/jcore/database/backend/BaseDatabaseBackend.java +++ b/src/org/mxchange/jcore/database/backend/BaseDatabaseBackend.java @@ -26,7 +26,7 @@ import java.util.Enumeration; import org.mxchange.jcore.BaseFrameworkSystem; import org.mxchange.jcore.criteria.searchable.SearchableCriteria; import org.mxchange.jcore.database.result.Result; -import org.mxchange.jcore.database.storage.Storeable; +import org.mxchange.jcore.database.storage.Storable; import org.mxchange.jcore.exceptions.BadTokenException; import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException; import org.mxchange.jcore.exceptions.UnsupportedDatabaseDriverException; @@ -115,7 +115,7 @@ public abstract class BaseDatabaseBackend extends BaseFrameworkSystem { } // Run "SELECT" - Result result = this.doSelectByCriteria(criteria); + Result result = this.doSelectByCriteria(criteria); // Get size int numRows = result.size(); @@ -140,5 +140,5 @@ public abstract class BaseDatabaseBackend extends BaseFrameworkSystem { * @throws java.lang.IllegalAccessException If the method cannot be accessed * @throws java.lang.reflect.InvocationTargetException Any other problems? */ - public abstract Result doSelectByCriteria (SearchableCriteria criteria) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException; + public abstract Result doSelectByCriteria (SearchableCriteria criteria) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException; } diff --git a/src/org/mxchange/jcore/database/backend/DatabaseBackend.java b/src/org/mxchange/jcore/database/backend/DatabaseBackend.java index d6ce352..45522c8 100644 --- a/src/org/mxchange/jcore/database/backend/DatabaseBackend.java +++ b/src/org/mxchange/jcore/database/backend/DatabaseBackend.java @@ -24,7 +24,7 @@ import javax.naming.NamingException; import org.mxchange.jcore.FrameworkInterface; import org.mxchange.jcore.criteria.searchable.SearchableCriteria; import org.mxchange.jcore.database.result.Result; -import org.mxchange.jcore.database.storage.Storeable; +import org.mxchange.jcore.database.storage.Storable; import org.mxchange.jcore.exceptions.BadTokenException; import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException; @@ -52,7 +52,7 @@ public interface DatabaseBackend extends FrameworkInterface { * @throws java.sql.SQLException If any SQL error occurs * @throws java.io.IOException If an IO error occurs */ - public Result doInsertDataSet (final Map dataset) throws SQLException, IOException; + public Result doInsertDataSet (final Map dataset) throws SQLException, IOException; /** * Run a "SELECT" statement with given criteria and always return a Result @@ -71,7 +71,7 @@ public interface DatabaseBackend extends FrameworkInterface { * @throws java.lang.IllegalAccessException If the method cannot be accessed * @throws java.lang.reflect.InvocationTargetException Any other problems? */ - public Result doSelectByCriteria (final SearchableCriteria criteria) throws IOException, BadTokenException, CorruptedDatabaseFileException, SQLException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException; + public Result doSelectByCriteria (final SearchableCriteria criteria) throws IOException, BadTokenException, CorruptedDatabaseFileException, SQLException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException; /** * Shuts down this backend diff --git a/src/org/mxchange/jcore/database/backend/base64/Base64CsvDatabaseBackend.java b/src/org/mxchange/jcore/database/backend/base64/Base64CsvDatabaseBackend.java index 99f2ba6..345427c 100644 --- a/src/org/mxchange/jcore/database/backend/base64/Base64CsvDatabaseBackend.java +++ b/src/org/mxchange/jcore/database/backend/base64/Base64CsvDatabaseBackend.java @@ -34,7 +34,7 @@ import org.mxchange.jcore.database.file.SynchronizeableFile; import org.mxchange.jcore.database.frontend.DatabaseFrontend; import org.mxchange.jcore.database.result.DatabaseResult; import org.mxchange.jcore.database.result.Result; -import org.mxchange.jcore.database.storage.Storeable; +import org.mxchange.jcore.database.storage.Storable; import org.mxchange.jcore.exceptions.BadTokenException; import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException; @@ -104,7 +104,7 @@ public class Base64CsvDatabaseBackend extends BaseDatabaseBackend implements Dat } @Override - public Result doInsertDataSet (final Map dataset) throws IOException { + public Result doInsertDataSet (final Map dataset) throws IOException { // Trace message this.getLogger().trace(MessageFormat.format("dataset={0} - CALLED!", dataset)); //NOI18N @@ -163,7 +163,7 @@ public class Base64CsvDatabaseBackend extends BaseDatabaseBackend implements Dat this.writeData(output); // The result set needs to be transformed into Result, so initialize a result instance here - Result result = new DatabaseResult(); + Result result = new DatabaseResult(); // Trace message this.getLogger().trace(MessageFormat.format("result={0} - EXIT!", result)); //NOI18N @@ -173,12 +173,12 @@ public class Base64CsvDatabaseBackend extends BaseDatabaseBackend implements Dat } @Override - public Result doSelectByCriteria (final SearchableCriteria criteria) throws IOException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + public Result doSelectByCriteria (final SearchableCriteria criteria) throws IOException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { // Trace message this.getLogger().trace(MessageFormat.format("criteria={0} - CALLED!", criteria)); //NOI18N // Init result instance - Result result = new DatabaseResult(); + Result result = new DatabaseResult(); // First rewind this backend this.rewind(); @@ -194,8 +194,8 @@ public class Base64CsvDatabaseBackend extends BaseDatabaseBackend implements Dat // Parse it to a Map Map map = this.getMapFromLine(line); - // Convert it to a Storeable instance - Storeable storeable = this.getFrontend().toStoreable(map); + // Convert it to a Storable instance + Storable storeable = this.getFrontend().toStoreable(map); // Debug message this.getLogger().debug(MessageFormat.format("storeable={0}", storeable)); //NOI18N diff --git a/src/org/mxchange/jcore/database/backend/datasource/DataSourceDatabaseBackend.java b/src/org/mxchange/jcore/database/backend/datasource/DataSourceDatabaseBackend.java index b905676..7d7854e 100644 --- a/src/org/mxchange/jcore/database/backend/datasource/DataSourceDatabaseBackend.java +++ b/src/org/mxchange/jcore/database/backend/datasource/DataSourceDatabaseBackend.java @@ -32,7 +32,7 @@ import org.mxchange.jcore.database.backend.BaseDatabaseBackend; import org.mxchange.jcore.database.backend.DatabaseBackend; import org.mxchange.jcore.database.frontend.DatabaseFrontend; import org.mxchange.jcore.database.result.Result; -import org.mxchange.jcore.database.storage.Storeable; +import org.mxchange.jcore.database.storage.Storable; import org.mxchange.jcore.exceptions.BadTokenException; import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException; import org.mxchange.jcore.exceptions.UnsupportedDatabaseDriverException; @@ -111,12 +111,12 @@ public class DataSourceDatabaseBackend extends BaseDatabaseBackend implements Da } @Override - public Result doInsertDataSet (final Map dataset) throws SQLException, IOException { + public Result doInsertDataSet (final Map dataset) throws SQLException, IOException { throw new UnsupportedOperationException(MessageFormat.format("Not supported yet: dataset={0}", dataset)); } @Override - public Result doSelectByCriteria (final SearchableCriteria criteria) throws IOException, BadTokenException, CorruptedDatabaseFileException, SQLException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + public Result doSelectByCriteria (final SearchableCriteria criteria) throws IOException, BadTokenException, CorruptedDatabaseFileException, SQLException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { throw new UnsupportedOperationException(MessageFormat.format("Not supported yet: criteria={0}", criteria)); } diff --git a/src/org/mxchange/jcore/database/backend/mysql/MySqlDatabaseBackend.java b/src/org/mxchange/jcore/database/backend/mysql/MySqlDatabaseBackend.java index 2a1498d..38a7407 100644 --- a/src/org/mxchange/jcore/database/backend/mysql/MySqlDatabaseBackend.java +++ b/src/org/mxchange/jcore/database/backend/mysql/MySqlDatabaseBackend.java @@ -33,7 +33,7 @@ import org.mxchange.jcore.database.backend.DatabaseBackend; import org.mxchange.jcore.database.frontend.DatabaseFrontend; import org.mxchange.jcore.database.result.DatabaseResult; import org.mxchange.jcore.database.result.Result; -import org.mxchange.jcore.database.storage.Storeable; +import org.mxchange.jcore.database.storage.Storable; import org.mxchange.jcore.exceptions.UnsupportedDatabaseDriverException; /** @@ -135,7 +135,7 @@ public class MySqlDatabaseBackend extends BaseDatabaseBackend implements Databas * @todo Support more than one record being inserted in a separate method */ @Override - public Result doInsertDataSet (final Map dataset) throws SQLException { + public Result doInsertDataSet (final Map dataset) throws SQLException { // Trace message this.getLogger().trace(MessageFormat.format("dataset={0} - CALLED!", dataset)); //NOI18N @@ -213,7 +213,7 @@ public class MySqlDatabaseBackend extends BaseDatabaseBackend implements Databas this.getLogger().debug(MessageFormat.format("status={0}", status)); //NOI18N // The result set needs to be transformed into Result, so initialize a result instance here - Result result = new DatabaseResult(status, statement); + Result result = new DatabaseResult(status, statement); // Trace message this.getLogger().trace(MessageFormat.format("result={0} - EXIT!", result)); //NOI18N @@ -223,7 +223,7 @@ public class MySqlDatabaseBackend extends BaseDatabaseBackend implements Databas } @Override - public Result doSelectByCriteria (final SearchableCriteria criteria) throws SQLException { + public Result doSelectByCriteria (final SearchableCriteria criteria) throws SQLException { // Trace message this.getLogger().trace(MessageFormat.format("criteria={0} - CALLED!", criteria)); //NOI18N @@ -307,7 +307,7 @@ public class MySqlDatabaseBackend extends BaseDatabaseBackend implements Databas this.getLogger().debug(MessageFormat.format("resultSet={0}", resultSet)); // The result set needs to be transformed into Result, so initialize a result instance here - Result result = this.getFrontend().getResultFromSet(resultSet); + Result result = this.getFrontend().getResultFromSet(resultSet); // Trace message this.getLogger().trace(MessageFormat.format("result={0} - EXIT!", result)); //NOI18N diff --git a/src/org/mxchange/jcore/database/frontend/BaseDatabaseFrontend.java b/src/org/mxchange/jcore/database/frontend/BaseDatabaseFrontend.java index d2447e4..9d5fb65 100644 --- a/src/org/mxchange/jcore/database/frontend/BaseDatabaseFrontend.java +++ b/src/org/mxchange/jcore/database/frontend/BaseDatabaseFrontend.java @@ -28,7 +28,7 @@ import org.mxchange.jcore.BaseFrameworkSystem; import org.mxchange.jcore.database.backend.DatabaseBackend; import org.mxchange.jcore.database.result.DatabaseResult; import org.mxchange.jcore.database.result.Result; -import org.mxchange.jcore.database.storage.Storeable; +import org.mxchange.jcore.database.storage.Storable; import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException; import org.mxchange.jcore.factory.database.backend.BackendFactory; @@ -67,9 +67,9 @@ public abstract class BaseDatabaseFrontend extends BaseFrameworkSystem implement * @throws java.sql.SQLException If an SQL error occurs */ @Override - public Result getResultFromSet (final ResultSet resultSet) throws SQLException { + public Result getResultFromSet (final ResultSet resultSet) throws SQLException { // Init result instance - Result result = new DatabaseResult(); + Result result = new DatabaseResult(); // Attach all possible warnings result.setWarnings(resultSet.getWarnings()); @@ -129,7 +129,7 @@ public abstract class BaseDatabaseFrontend extends BaseFrameworkSystem implement * @throws java.sql.SQLException If any SQL error occurs * @throws java.io.IOException If an IO error occurs */ - protected Result doInsertDataSet () throws SQLException, IOException { + protected Result doInsertDataSet () throws SQLException, IOException { // Trace message this.getLogger().trace("CALLED!"); //NOI18N @@ -140,7 +140,7 @@ public abstract class BaseDatabaseFrontend extends BaseFrameworkSystem implement } // Call backend method - Result result = this.getBackend().doInsertDataSet(this.dataset); + Result result = this.getBackend().doInsertDataSet(this.dataset); // Trace message this.getLogger().trace(MessageFormat.format("result={0} - EXIT!", result)); //NOI18N diff --git a/src/org/mxchange/jcore/database/frontend/DatabaseFrontend.java b/src/org/mxchange/jcore/database/frontend/DatabaseFrontend.java index 43069f4..511750e 100644 --- a/src/org/mxchange/jcore/database/frontend/DatabaseFrontend.java +++ b/src/org/mxchange/jcore/database/frontend/DatabaseFrontend.java @@ -23,7 +23,7 @@ import java.sql.SQLException; import java.util.Map; import org.mxchange.jcore.FrameworkInterface; import org.mxchange.jcore.database.result.Result; -import org.mxchange.jcore.database.storage.Storeable; +import org.mxchange.jcore.database.storage.Storable; /** * A generic interface for database frontends @@ -47,16 +47,16 @@ public interface DatabaseFrontend extends FrameworkInterface { * @return A typorized Result instance * @throws java.sql.SQLException If an SQL error occurs */ - public Result getResultFromSet (final ResultSet resultSet) throws SQLException; + public Result getResultFromSet (final ResultSet resultSet) throws SQLException; /** - * Returns a Storeable instance from given row index. Value 0 means first + * Returns a Storable instance from given row index. Value 0 means first * row and so on. Row index below zero results in an exception. * * @param rowIndex Row index too look for - * @return A Storeable instance + * @return A Storable instance */ - public Storeable getStoreableAtRow (final int rowIndex); + public Storable getStoreableAtRow (final int rowIndex); /** * Name of used database table, handled over to backend @@ -73,18 +73,18 @@ public interface DatabaseFrontend extends FrameworkInterface { public void doShutdown () throws SQLException, IOException; /** - * Converts the given map into a Storeable instance, depending on which class implements it. All + * Converts the given map into a Storable instance, depending on which class implements it. All * keys are being interpreted as class fields/attributes and their respective setters are being searched for. As * this method may fail to find one or access it, this method throws some exception. * - * @param map Map instance to convert to Storeable - * @return An instance of a Storeable implementation + * @param map Map instance to convert to Storable + * @return An instance of a Storable implementation * @throws IllegalArgumentException Some implementations may throw this * @throws java.lang.NoSuchMethodException If the invoked method was not found * @throws java.lang.IllegalAccessException If the method cannot be accessed * @throws java.lang.reflect.InvocationTargetException Any other problems? */ - public Storeable toStoreable (final Map map) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException; + public Storable toStoreable (final Map map) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException; /** * Some getter for name of id column diff --git a/src/org/mxchange/jcore/database/result/DatabaseResult.java b/src/org/mxchange/jcore/database/result/DatabaseResult.java index a5cfd4a..352d041 100644 --- a/src/org/mxchange/jcore/database/result/DatabaseResult.java +++ b/src/org/mxchange/jcore/database/result/DatabaseResult.java @@ -21,24 +21,22 @@ import java.sql.SQLException; import java.sql.SQLWarning; import java.text.MessageFormat; import java.util.Collections; -import java.util.HashMap; import java.util.Iterator; -import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; import org.mxchange.jcore.BaseFrameworkSystem; -import org.mxchange.jcore.database.storage.Storeable; +import org.mxchange.jcore.database.storage.Storable; /** * A database result * @author Roland Haeder */ -public class DatabaseResult extends BaseFrameworkSystem implements Result { +public class DatabaseResult extends BaseFrameworkSystem implements Result { /** - * Set of all found Storeable instances + * Set of all found Storable instances */ - private final SortedSet result; + private final SortedSet result; /** * Status value from previous executeUpdate() call @@ -84,12 +82,12 @@ public class DatabaseResult extends BaseFrameworkSystem implements Result iterator () { + public final Iterator iterator () { // Return iterator from result set return this.result.iterator(); } @Override - public final Storeable next () { + public final Storable next () { // Call iterator's method return this.iterator().next(); } @@ -144,8 +142,8 @@ public class DatabaseResult extends BaseFrameworkSystem implements Result resultSet () { - // Return it + public Set resultSet () { + // Return it unmodifiable return Collections.unmodifiableSet(this.result); } } diff --git a/src/org/mxchange/jcore/database/result/Result.java b/src/org/mxchange/jcore/database/result/Result.java index ff67e63..4a733e1 100644 --- a/src/org/mxchange/jcore/database/result/Result.java +++ b/src/org/mxchange/jcore/database/result/Result.java @@ -20,7 +20,7 @@ import java.sql.SQLWarning; import java.util.Iterator; import java.util.Set; import org.mxchange.jcore.FrameworkInterface; -import org.mxchange.jcore.database.storage.Storeable; +import org.mxchange.jcore.database.storage.Storable; /** * An interface for database results @@ -28,14 +28,14 @@ import org.mxchange.jcore.database.storage.Storeable; * @author Roland Haeder * @param Anything that is storeable */ -public interface Result extends FrameworkInterface, Iterator, Iterable { +public interface Result extends FrameworkInterface, Iterator, Iterable { /** - * Given Storeable instance as a query result. + * Given Storable instance as a query result. * - * @param storeable An instance of a Storeable class + * @param storeable An instance of a Storable class */ - public void add (final Storeable storeable); + public void add (final Storable storeable); /** * Setter for warnings @@ -63,5 +63,5 @@ public interface Result extends FrameworkInterface, Iterato * * @return A map from this result */ - public Set resultSet (); + public Set resultSet (); } diff --git a/src/org/mxchange/jcore/database/storage/Storeable.java b/src/org/mxchange/jcore/database/storage/Storable.java similarity index 97% rename from src/org/mxchange/jcore/database/storage/Storeable.java rename to src/org/mxchange/jcore/database/storage/Storable.java index f412bcc..87b9ec9 100644 --- a/src/org/mxchange/jcore/database/storage/Storeable.java +++ b/src/org/mxchange/jcore/database/storage/Storable.java @@ -24,7 +24,7 @@ import org.mxchange.jcore.FrameworkInterface; * * @author Roland Haeder */ -public interface Storeable extends FrameworkInterface { +public interface Storable extends FrameworkInterface { /** * Some "getter for a value from given column name. This name will be * translated into a method name and then this method is called. -- 2.39.5