From 047687bd5dda99c0eba35ecbbb67d02091dea80e Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 15 Aug 2015 00:11:31 +0200 Subject: [PATCH] =?utf8?q?Some=20more=20parameter=20checks=20and=20split?= =?utf8?q?=20each=20BASE64=20line=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../jcore/criteria/searchable/SearchCriteria.java | 12 ++++++++++++ .../backend/base64/Base64CsvDatabaseBackend.java | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) 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!"); -- 2.39.5