From: Roland Haeder Date: Fri, 14 Aug 2015 22:11:31 +0000 (+0200) Subject: Some more parameter checks and split each BASE64 line X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=047687bd5dda99c0eba35ecbbb67d02091dea80e;p=jcore.git Some more parameter checks and split each BASE64 line Signed-off-by:Roland Häder --- diff --git a/src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java b/src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java index d9831e5..f5c9387 100644 --- a/src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java +++ b/src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java @@ -77,6 +77,18 @@ public class SearchCriteria extends BaseCriteria implements SearchableCritera { throw new NullPointerException("storeable is null"); } + // Debug message + this.getLogger().debug("this.entrySet().size()=" + this.entrySet().size()); + + // No matches found? + if (this.entrySet().isEmpty()) { + // Debug message + this.getLogger().debug("No criteria set, returning true ..."); + + // Then there is nothing to match! + return true; + } + // Init matches array Map criteraMatches = new HashMap<>(this.entrySet().size()); diff --git a/src/org/mxchange/jcore/database/backend/base64/Base64CsvDatabaseBackend.java b/src/org/mxchange/jcore/database/backend/base64/Base64CsvDatabaseBackend.java index 89c8964..7c607fb 100644 --- a/src/org/mxchange/jcore/database/backend/base64/Base64CsvDatabaseBackend.java +++ b/src/org/mxchange/jcore/database/backend/base64/Base64CsvDatabaseBackend.java @@ -328,7 +328,7 @@ public class Base64CsvDatabaseBackend extends BaseDatabaseBackend implements Dat } /** - * Writes data BASE64-encoded to database file + * Writes a line with BASE64 encoding to database file * * @param output Output string to write */ @@ -336,14 +336,23 @@ public class Base64CsvDatabaseBackend extends BaseDatabaseBackend implements Dat // Trace message this.getLogger().trace("output=" + output + " - CALLED!"); + // No null or empty strings + if (output == null) { + // Is null + throw new NullPointerException("output is null"); + } else if (output.length() == 0) { + // Is empty + throw new IllegalArgumentException("output is empty"); + } + // Encode it to BASE64 String rawOutput = Base64.encodeBase64String(output.toString().getBytes()); // Debug message this.getLogger().debug("rawOutput=" + rawOutput); - // Write it - this.getStorageFile().writeBytes(rawOutput); + // Write each line separately + this.getStorageFile().writeBytes(rawOutput + "\n"); // Trace message this.getLogger().trace("EXIT!");