Permalink
Browse files

Refactor some ugly code

  • Loading branch information...
1 parent 39e3a06 commit c39df95e8f0d39a735fcc528195e125a35ba243f Jan Kotek committed Jan 26, 2012
Showing with 3 additions and 13 deletions.
  1. 0 LICENSE-2.0.html
  2. 0 README.md
  3. 0 pom.xml
  4. +3 −13 src/main/java/net/kotek/jdbm/DBMaker.java
View
0 LICENSE-2.0.html 100644 → 100755
No changes.
View
0 README.md 100644 → 100755
No changes.
View
0 pom.xml 100644 → 100755
No changes.
View
@@ -26,7 +26,7 @@
import java.security.spec.KeySpec;
/**
- *
+ * Class used to configure and create DB. It uses builder pattern.
*/
public class DBMaker {
@@ -252,7 +252,7 @@ public DB build() {
throw new Error("Block size changed after encryption, make sure you use '/NoPadding'");
byte[] data2 = cipherOut.doFinal(encData);
for (int i = 0; i < data.length; i++) {
- if (data[i] != data2[i]) throw new Error();
+ if (data[i] != data2[i]) throw new Error("Encryption provided by JRE does not work");
}
} catch (Exception e) {
@@ -268,24 +268,14 @@ public DB build() {
}
-
- if (cacheType == DBCache.MRU) {
- db = new DBCache((DBStore) db, mruCacheSize, cacheType,autoClearRefCacheOnLowMem);
- } else if (cacheType == DBCache.SOFT) {
- db = new DBCache((DBStore) db, mruCacheSize, cacheType,autoClearRefCacheOnLowMem);
- } else if (cacheType == DBCache.HARD) {
+ if (cacheType == DBCache.MRU || cacheType == DBCache.SOFT || cacheType == DBCache.HARD || cacheType == DBCache.WEAK) {
db = new DBCache((DBStore) db, mruCacheSize, cacheType,autoClearRefCacheOnLowMem);
-
- } else if (cacheType == DBCache.WEAK) {
- db = new DBCache((DBStore) db, mruCacheSize, cacheType, autoClearRefCacheOnLowMem);
-
} else if (cacheType == DBCache.NONE) {
//do nothing
} else {
throw new IllegalArgumentException("Unknown cache type: " + cacheType);
}
-
return db;
}

0 comments on commit c39df95

Please sign in to comment.