From cbce74a5ee0bacfaab3b14d3c808222ab431ef4b Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 15 Aug 2015 11:00:26 +0200 Subject: [PATCH] Continued with jcore: - renamed interface to SearchableCriteria (typo fixed) - addCriteria() now accepts Boolean and not boolean - MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by:Roland Häder --- .../mxchange/jcore/criteria/BaseCriteria.java | 21 ++++++++----------- src/org/mxchange/jcore/criteria/Criteria.java | 10 ++++++++- .../criteria/searchable/SearchCriteria.java | 2 +- ...leCritera.java => SearchableCriteria.java} | 2 +- .../database/backend/DatabaseBackend.java | 4 ++-- .../base64/Base64CsvDatabaseBackend.java | 4 ++-- .../backend/mysql/MySqlDatabaseBackend.java | 4 ++-- 7 files changed, 26 insertions(+), 21 deletions(-) rename src/org/mxchange/jcore/criteria/searchable/{SearchableCritera.java => SearchableCriteria.java} (97%) diff --git a/src/org/mxchange/jcore/criteria/BaseCriteria.java b/src/org/mxchange/jcore/criteria/BaseCriteria.java index fd81c2e..0846504 100644 --- a/src/org/mxchange/jcore/criteria/BaseCriteria.java +++ b/src/org/mxchange/jcore/criteria/BaseCriteria.java @@ -47,7 +47,7 @@ public class BaseCriteria extends BaseFrameworkSystem implements Criteria { } @Override - public void addCriteria (final String key, final boolean value) { + public void addCriteria (final String key, final Boolean value) { // Add to map this.criteria.put(key, value); } @@ -58,21 +58,11 @@ public class BaseCriteria extends BaseFrameworkSystem implements Criteria { this.criteria.put(key, value); } - /** - * Gets all entries as a key-value pair - * - * @return Key-value paira of all entries - */ @Override public Set> entrySet () { return this.criteria.entrySet(); } - /** - * Gets all values from underlaying map in an iterator. - * - * @return Values iteratable - */ @Override public Iterable values () { // Call map's method @@ -90,9 +80,16 @@ public class BaseCriteria extends BaseFrameworkSystem implements Criteria { } /** - * @param logcial the logcial to set + * Setter for Logical instance + * + * @param logcial the Logical instance to set */ public final void setLogcial (final Logical logcial) { this.logcial = logcial; } + + @Override + public void addCriteria (final String key, final Number value) { + this.criteria.put(key, value); + } } diff --git a/src/org/mxchange/jcore/criteria/Criteria.java b/src/org/mxchange/jcore/criteria/Criteria.java index bddd6d0..c6f1397 100644 --- a/src/org/mxchange/jcore/criteria/Criteria.java +++ b/src/org/mxchange/jcore/criteria/Criteria.java @@ -32,7 +32,7 @@ public interface Criteria extends FrameworkInterface { * @param key Key of criteria * @param value Value of criteria */ - public void addCriteria (final String key, final boolean value); + public void addCriteria (final String key, final Boolean value); /** * Adds a string criteria @@ -42,6 +42,14 @@ public interface Criteria extends FrameworkInterface { */ public void addCriteria (final String key, final String value); + /** + * Adds a number criteria + * + * @param key Key of criteria + * @param value Value of criteria + */ + public void addCriteria (final String key, final Number value); + /** * Gets all values from underlaying map in an iterator. * diff --git a/src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java b/src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java index f5c9387..e217f09 100644 --- a/src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java +++ b/src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java @@ -29,7 +29,7 @@ import org.mxchange.jcore.database.storage.Storeable; * * @author Roland Haeder */ -public class SearchCriteria extends BaseCriteria implements SearchableCritera { +public class SearchCriteria extends BaseCriteria implements SearchableCriteria { /** * Limit of matches */ diff --git a/src/org/mxchange/jcore/criteria/searchable/SearchableCritera.java b/src/org/mxchange/jcore/criteria/searchable/SearchableCriteria.java similarity index 97% rename from src/org/mxchange/jcore/criteria/searchable/SearchableCritera.java rename to src/org/mxchange/jcore/criteria/searchable/SearchableCriteria.java index 145d3c9..e0628f2 100644 --- a/src/org/mxchange/jcore/criteria/searchable/SearchableCritera.java +++ b/src/org/mxchange/jcore/criteria/searchable/SearchableCriteria.java @@ -25,7 +25,7 @@ import org.mxchange.jcore.database.storage.Storeable; * * @author Roland Haeder */ -public interface SearchableCritera extends Criteria { +public interface SearchableCriteria extends Criteria { /** * Checks if the given instance of a Storeable class matches * diff --git a/src/org/mxchange/jcore/database/backend/DatabaseBackend.java b/src/org/mxchange/jcore/database/backend/DatabaseBackend.java index ea8cb00..3ed3038 100644 --- a/src/org/mxchange/jcore/database/backend/DatabaseBackend.java +++ b/src/org/mxchange/jcore/database/backend/DatabaseBackend.java @@ -21,7 +21,7 @@ import java.lang.reflect.InvocationTargetException; import java.sql.SQLException; import java.util.Map; import org.mxchange.jcore.FrameworkInterface; -import org.mxchange.jcore.criteria.searchable.SearchableCritera; +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.exceptions.BadTokenException; @@ -66,7 +66,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 SearchableCritera critera) throws IOException, BadTokenException, CorruptedDatabaseFileException, SQLException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException; + public Result doSelectByCriteria (final SearchableCriteria critera) 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 859f228..9293d5b 100644 --- a/src/org/mxchange/jcore/database/backend/base64/Base64CsvDatabaseBackend.java +++ b/src/org/mxchange/jcore/database/backend/base64/Base64CsvDatabaseBackend.java @@ -28,7 +28,7 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.codec.binary.Base64; -import org.mxchange.jcore.criteria.searchable.SearchableCritera; +import org.mxchange.jcore.criteria.searchable.SearchableCriteria; import org.mxchange.jcore.database.backend.BaseDatabaseBackend; import org.mxchange.jcore.database.backend.DatabaseBackend; import org.mxchange.jcore.database.backend.file.SynchronizeableFile; @@ -175,7 +175,7 @@ public class Base64CsvDatabaseBackend extends BaseDatabaseBackend implements Dat } @Override - public Result doSelectByCriteria (final SearchableCritera critera) throws IOException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + public Result doSelectByCriteria (final SearchableCriteria critera) throws IOException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { // Trace message this.getLogger().trace(MessageFormat.format("criteria={0} - CALLED!", critera)); diff --git a/src/org/mxchange/jcore/database/backend/mysql/MySqlDatabaseBackend.java b/src/org/mxchange/jcore/database/backend/mysql/MySqlDatabaseBackend.java index a97bd26..11f9e20 100644 --- a/src/org/mxchange/jcore/database/backend/mysql/MySqlDatabaseBackend.java +++ b/src/org/mxchange/jcore/database/backend/mysql/MySqlDatabaseBackend.java @@ -27,7 +27,7 @@ import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; -import org.mxchange.jcore.criteria.searchable.SearchableCritera; +import org.mxchange.jcore.criteria.searchable.SearchableCriteria; import org.mxchange.jcore.database.backend.BaseDatabaseBackend; import org.mxchange.jcore.database.backend.DatabaseBackend; import org.mxchange.jcore.database.frontend.DatabaseFrontend; @@ -223,7 +223,7 @@ public class MySqlDatabaseBackend extends BaseDatabaseBackend implements Databas } @Override - public Result doSelectByCriteria (final SearchableCritera critera) throws SQLException { + public Result doSelectByCriteria (final SearchableCriteria critera) throws SQLException { // Trace message this.getLogger().trace(MessageFormat.format("criteria={0} - CALLED!", critera)); -- 2.39.5