]> git.mxchange.org Git - jcore.git/commitdiff
Some more parameter checks and split each BASE64 line
authorRoland Haeder <roland@mxchange.org>
Fri, 14 Aug 2015 22:11:31 +0000 (00:11 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 14 Aug 2015 22:14:00 +0000 (00:14 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java
src/org/mxchange/jcore/database/backend/base64/Base64CsvDatabaseBackend.java

index d9831e55cf38ae26ff5212d8a5780805635cf35a..f5c9387104685d64533fec8ee0928702adeb0e7c 100644 (file)
@@ -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<String, Boolean> criteraMatches = new HashMap<>(this.entrySet().size());
 
index 89c8964b779d1f757392002b4f6be0ef9838fd93..7c607fbe60925c772770765b251d7339719dde52 100644 (file)
@@ -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!");