From: Roland Haeder Date: Sat, 15 Aug 2015 09:00:26 +0000 (+0200) Subject: Continued with jcore: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cbce74a5ee0bacfaab3b14d3c808222ab431ef4b;p=jcore.git Continued with jcore: - renamed interface to SearchableCriteria (typo fixed) - addCriteria() now accepts Boolean and not boolean - Signed-off-by:Roland Häder --- 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/SearchableCritera.java deleted file mode 100644 index 145d3c9..0000000 --- a/src/org/mxchange/jcore/criteria/searchable/SearchableCritera.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2015 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jcore.criteria.searchable; - -import java.lang.reflect.InvocationTargetException; -import org.mxchange.jcore.criteria.Criteria; -import org.mxchange.jcore.database.storage.Storeable; - -/** - * A searchable criteria - * - * @author Roland Haeder - */ -public interface SearchableCritera extends Criteria { - /** - * Checks if the given instance of a Storeable class matches - * - * @param storeable A Storeable instance to check - * @return Whether the Storeable 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; - - /** - * Setter for limit of possible matches - * - * @param limit Limit of matches - */ - public void setLimit (final int limit); - - /** - * Getter for limit of possible matches - * - * @return Limit of matches - */ - public int getLimit (); - - /** - * Setter for skipping of possible matches - * - * @param skip Skipping of matches - */ - public void setSkip (final int skip); - - /** - * Getter for skipping of possible matches - * - * @return Skipping of matches - */ - public int getSkip (); -} diff --git a/src/org/mxchange/jcore/criteria/searchable/SearchableCriteria.java b/src/org/mxchange/jcore/criteria/searchable/SearchableCriteria.java new file mode 100644 index 0000000..e0628f2 --- /dev/null +++ b/src/org/mxchange/jcore/criteria/searchable/SearchableCriteria.java @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcore.criteria.searchable; + +import java.lang.reflect.InvocationTargetException; +import org.mxchange.jcore.criteria.Criteria; +import org.mxchange.jcore.database.storage.Storeable; + +/** + * A searchable criteria + * + * @author Roland Haeder + */ +public interface SearchableCriteria extends Criteria { + /** + * Checks if the given instance of a Storeable class matches + * + * @param storeable A Storeable instance to check + * @return Whether the Storeable 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; + + /** + * Setter for limit of possible matches + * + * @param limit Limit of matches + */ + public void setLimit (final int limit); + + /** + * Getter for limit of possible matches + * + * @return Limit of matches + */ + public int getLimit (); + + /** + * Setter for skipping of possible matches + * + * @param skip Skipping of matches + */ + public void setSkip (final int skip); + + /** + * Getter for skipping of possible matches + * + * @return Skipping of matches + */ + public int getSkip (); +} 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));