From 615cc5e9088f6a60650eefc032011adbca7463bd Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Wed, 28 Feb 2018 13:39:29 +0100 Subject: [PATCH] Reviewed Javadoc. --- src/fr/devinsy/sikevadb/core/SikevaDB.java | 8 +- .../core/UnopenedDatabaseException.java | 64 ++++ .../devinsy/sikevadb/demo/SikevaDBDemo.java | 4 +- .../sikevadb/filetree/FileTreeSikevaDB.java | 281 ++++++++--------- src/fr/devinsy/sikevadb/sql/SQLSikevaDB.java | 292 ++++++++---------- .../filetree/TreeFileSikevaDBTest.java | 2 +- 6 files changed, 339 insertions(+), 312 deletions(-) create mode 100644 src/fr/devinsy/sikevadb/core/UnopenedDatabaseException.java diff --git a/src/fr/devinsy/sikevadb/core/SikevaDB.java b/src/fr/devinsy/sikevadb/core/SikevaDB.java index 3154a64..61bb43a 100644 --- a/src/fr/devinsy/sikevadb/core/SikevaDB.java +++ b/src/fr/devinsy/sikevadb/core/SikevaDB.java @@ -152,6 +152,12 @@ public interface SikevaDB */ void deleteMany(final String key, final String... subkeys) throws SikevaDBException; + /** + * Destroy. + * + * @throws SikevaDBException + * the sikeva DB exception + */ public void destroy() throws SikevaDBException; /** @@ -297,7 +303,7 @@ public interface SikevaDB * @throws SikevaDBException * the SikevaDB exception */ - public boolean isCreated() throws SikevaDBException; + public boolean exists() throws SikevaDBException; /** * Checks if is opened. diff --git a/src/fr/devinsy/sikevadb/core/UnopenedDatabaseException.java b/src/fr/devinsy/sikevadb/core/UnopenedDatabaseException.java new file mode 100644 index 0000000..4aabced --- /dev/null +++ b/src/fr/devinsy/sikevadb/core/UnopenedDatabaseException.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2018 Christian Pierre MOMON + * + * This file is part of SikevaDB, simple key value database. + * + * SikevaDB is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * SikevaDB 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with SikevaDB. If not, see . + */ +package fr.devinsy.sikevadb.core; + +/** + * + * @author Christian Pierre MOMON (christian.momon@devinsy.fr) + */ +public class UnopenedDatabaseException extends SikevaDBException +{ + private static final long serialVersionUID = 8364599416669077052L; + + /** + * + */ + public UnopenedDatabaseException() + { + super(); + } + + /** + * + * @param message + */ + public UnopenedDatabaseException(final String message) + { + super(message); + } + + /** + * + * @param message + * @param cause + */ + public UnopenedDatabaseException(final String message, final Throwable cause) + { + super(message, cause); + } + + /** + * + * @param cause + */ + public UnopenedDatabaseException(final Throwable cause) + { + super(cause); + } +} diff --git a/src/fr/devinsy/sikevadb/demo/SikevaDBDemo.java b/src/fr/devinsy/sikevadb/demo/SikevaDBDemo.java index 049be80..9b81f27 100644 --- a/src/fr/devinsy/sikevadb/demo/SikevaDBDemo.java +++ b/src/fr/devinsy/sikevadb/demo/SikevaDBDemo.java @@ -62,7 +62,7 @@ public final class SikevaDBDemo File homeDirectory = new File("/tmp/footest"); database = SikevaDBFactory.get(homeDirectory); - if (database.isCreated()) + if (database.exists()) { database.destroy(); } @@ -136,7 +136,7 @@ public final class SikevaDBDemo } finally { - if ((database != null) && (database.isCreated())) + if ((database != null) && (database.exists())) { database.destroy(); } diff --git a/src/fr/devinsy/sikevadb/filetree/FileTreeSikevaDB.java b/src/fr/devinsy/sikevadb/filetree/FileTreeSikevaDB.java index 32df4c2..eb01aa3 100644 --- a/src/fr/devinsy/sikevadb/filetree/FileTreeSikevaDB.java +++ b/src/fr/devinsy/sikevadb/filetree/FileTreeSikevaDB.java @@ -110,9 +110,6 @@ public class FileTreeSikevaDB implements SikevaDB /* (non-Javadoc) * @see fr.devinsy.sikevadb.core.SikevaDB#archiver() */ - /** - * {@inheritDoc} - */ @Override public Archiver archiver() throws SikevaDBException { @@ -146,9 +143,8 @@ public class FileTreeSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#close() */ @Override public void close() throws SikevaDBException @@ -165,9 +161,8 @@ public class FileTreeSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#countOfElements() */ @Override public long countOfElements() throws SikevaDBException @@ -202,11 +197,8 @@ public class FileTreeSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * - * @throws SikevaDBException - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#countOfElements(java.lang.String) */ @Override public long countOfElements(final String key) throws SikevaDBException @@ -243,9 +235,8 @@ public class FileTreeSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#countOfElements(java.lang.String, long) */ @Override public long countOfElements(final String key, final long subkey) throws SikevaDBException @@ -258,9 +249,8 @@ public class FileTreeSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#countOfElements(java.lang.String, java.lang.String) */ @Override public long countOfElements(final String key, final String subkey) throws SikevaDBException @@ -296,9 +286,8 @@ public class FileTreeSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#create() */ @Override public void create() throws SikevaDBException @@ -323,9 +312,8 @@ public class FileTreeSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#delete(java.lang.String) */ @Override public void delete(final String key) throws SikevaDBException @@ -345,12 +333,12 @@ public class FileTreeSikevaDB implements SikevaDB boolean result = targetFile.delete(); if (!result) { - throw new SikevaDBException("Error removing [" + targetFile.getAbsolutePath() + "]"); + throw new SikevaDBException("Error deleting [" + targetFile.getAbsolutePath() + "]"); } } else { - throw new SikevaDBException("Invalid target to remove [" + targetFile.getAbsolutePath() + "]"); + throw new SikevaDBException("Invalid target to delete [" + targetFile.getAbsolutePath() + "]"); } } } @@ -360,9 +348,8 @@ public class FileTreeSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#delete(java.lang.String, long) */ @Override public void delete(final String key, final long subkey) throws SikevaDBException @@ -370,9 +357,8 @@ public class FileTreeSikevaDB implements SikevaDB delete(key, String.valueOf(subkey)); } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#delete(java.lang.String, java.lang.String) */ @Override public void delete(final String key, final String subkey) throws SikevaDBException @@ -393,12 +379,12 @@ public class FileTreeSikevaDB implements SikevaDB boolean result = targetFile.delete(); if (!result) { - throw new SikevaDBException("Error removing [" + targetFile.getAbsolutePath() + "]"); + throw new SikevaDBException("Error deleting [" + targetFile.getAbsolutePath() + "]"); } } else { - throw new SikevaDBException("Invalid target to remove [" + targetFile.getAbsolutePath() + "]"); + throw new SikevaDBException("Invalid target to deleting [" + targetFile.getAbsolutePath() + "]"); } } } @@ -408,9 +394,8 @@ public class FileTreeSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#deleteMany(java.lang.String, java.lang.String[]) */ @Override public void deleteMany(final String key, final String... subkeys) throws SikevaDBException @@ -438,9 +423,8 @@ public class FileTreeSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#destroy() */ @Override public void destroy() throws SikevaDBException @@ -486,7 +470,7 @@ public class FileTreeSikevaDB implements SikevaDB { throw new SikevaDBException("Invalid config directory (), destroy operation is cancelled."); } - else if (isCreated()) + else if (exists()) { try { @@ -504,6 +488,27 @@ public class FileTreeSikevaDB implements SikevaDB } } + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#isCreated() + */ + @Override + public boolean exists() throws SikevaDBException + { + boolean result; + + if ((this.homeDirectory.isDirectory()) && (this.dataDirectory.isDirectory()) && (this.configDirectory.isDirectory())) + { + result = true; + } + else + { + result = false; + } + + // + return result; + } + /** * Gets the config directory. * @@ -511,7 +516,12 @@ public class FileTreeSikevaDB implements SikevaDB */ public File getConfigDirectory() { - return this.configDirectory; + File result; + + result = this.configDirectory; + + // + return result; } /** @@ -521,12 +531,16 @@ public class FileTreeSikevaDB implements SikevaDB */ public File getDataDirectory() { - return this.dataDirectory; + File result; + + result = this.dataDirectory; + + // + return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getElement(java.lang.String) */ @Override public Element getElement(final String key) throws SikevaDBException @@ -559,9 +573,8 @@ public class FileTreeSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getElement(java.lang.String, long) */ @Override public Element getElement(final String key, final long subkey) throws SikevaDBException @@ -574,9 +587,8 @@ public class FileTreeSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getElement(java.lang.String, java.lang.String) */ @Override public Element getElement(final String key, final String subkey) throws SikevaDBException @@ -612,8 +624,8 @@ public class FileTreeSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getElements() */ @Override public Elements getElements() throws SikevaDBException @@ -658,9 +670,8 @@ public class FileTreeSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getElements(java.lang.String) */ @Override public Elements getElements(final String key) throws SikevaDBException @@ -706,13 +717,16 @@ public class FileTreeSikevaDB implements SikevaDB */ public File getFileTreeDirectory() { - return this.homeDirectory; + File result; + + result = this.homeDirectory; + + // + return result; } - /** - * {@inheritDoc} - * - * @throws SikevaDBException + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getKeys() */ @Override public StringList getKeys() throws SikevaDBException @@ -760,7 +774,12 @@ public class FileTreeSikevaDB implements SikevaDB */ public String getLogin() { - return this.login; + String result; + + result = this.login; + + // + return result; } /** @@ -770,13 +789,16 @@ public class FileTreeSikevaDB implements SikevaDB */ public String getPassword() { - return this.password; + String result; + + result = this.password; + + // + return result; } - /** - * {@inheritDoc} - * - * @throws SikevaDBException + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getSubkeys(java.lang.String) */ @Override public StringList getSubkeys(final String key) throws SikevaDBException @@ -814,10 +836,8 @@ public class FileTreeSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * - * @throws SikevaDBException + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getValue(java.lang.String) */ @Override public String getValue(final String key) throws SikevaDBException @@ -854,9 +874,8 @@ public class FileTreeSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getValue(java.lang.String, long) */ @Override public String getValue(final String key, final long subkey) throws SikevaDBException @@ -869,10 +888,8 @@ public class FileTreeSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * - * @throws SikevaDBException + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getValue(java.lang.String, java.lang.String) */ @Override public String getValue(final String key, final String subkey) throws SikevaDBException @@ -910,10 +927,8 @@ public class FileTreeSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * - * @throws SikevaDBException + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getValues(java.lang.String) */ @Override public StringList getValues(final String key) throws SikevaDBException @@ -1008,27 +1023,6 @@ public class FileTreeSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - */ - @Override - public boolean isCreated() throws SikevaDBException - { - boolean result; - - if ((this.homeDirectory.isDirectory()) && (this.dataDirectory.isDirectory()) && (this.configDirectory.isDirectory())) - { - result = true; - } - else - { - result = false; - } - - // - return result; - } - /* (non-Javadoc) * @see fr.devinsy.sikevadb.core.SikevaDB#isOpened() */ @@ -1050,10 +1044,8 @@ public class FileTreeSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * - * @throws SikevaDBException + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#memorySize() */ @Override public long memorySize() throws SikevaDBException @@ -1100,10 +1092,8 @@ public class FileTreeSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * - * @throws SikevaDBException + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#memorySize(java.lang.String) */ @Override public long memorySize(final String key) throws SikevaDBException @@ -1150,9 +1140,8 @@ public class FileTreeSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#memorySize(java.lang.String, long) */ @Override public long memorySize(final String key, final long subkey) throws SikevaDBException @@ -1165,9 +1154,8 @@ public class FileTreeSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#memorySize(java.lang.String, java.lang.String) */ @Override public long memorySize(final String key, final String subkey) throws SikevaDBException @@ -1206,13 +1194,13 @@ public class FileTreeSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#open() */ @Override public void open() throws SikevaDBException { - if (isCreated()) + if (exists()) { if (isOpened()) { @@ -1230,10 +1218,8 @@ public class FileTreeSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * - * @throws SikevaDBException + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#put(fr.devinsy.sikevadb.core.Element) */ @Override public void put(final Element element) throws SikevaDBException @@ -1282,9 +1268,8 @@ public class FileTreeSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#put(java.lang.String, long, java.lang.String) */ @Override public void put(final String key, final long subkey, final String value) throws SikevaDBException @@ -1292,9 +1277,8 @@ public class FileTreeSikevaDB implements SikevaDB put(key, String.valueOf(subkey), value); } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#put(java.lang.String, java.lang.String) */ @Override public void put(final String key, final String value) throws SikevaDBException @@ -1333,9 +1317,8 @@ public class FileTreeSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#put(java.lang.String, java.lang.String, java.lang.String) */ @Override public void put(final String key, final String subkey, final String value) throws SikevaDBException @@ -1375,9 +1358,8 @@ public class FileTreeSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#renameKey(java.lang.String, java.lang.String) */ @Override public void renameKey(final String oldKey, final String newKey) throws SikevaDBException @@ -1424,8 +1406,8 @@ public class FileTreeSikevaDB implements SikevaDB this.logger.debug("renameKey done."); } - /** - * {@inheritDoc} + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#renameSubkey(java.lang.String, long, long) */ @Override public void renameSubkey(final String key, final long oldSubKey, final long newSubkey) throws SikevaDBException @@ -1433,9 +1415,8 @@ public class FileTreeSikevaDB implements SikevaDB renameSubkey(key, String.valueOf(oldSubKey), String.valueOf(newSubkey)); } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#renameSubkey(java.lang.String, java.lang.String, java.lang.String) */ @Override public void renameSubkey(final String key, final String oldSubkey, final String newSubkey) throws SikevaDBException @@ -1487,10 +1468,8 @@ public class FileTreeSikevaDB implements SikevaDB this.logger.debug("renameSubKey done."); } - /** - * {@inheritDoc} - * - * @throws SikevaDBException + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#replaceInValue(java.lang.String, java.lang.String[]) */ @Override public void replaceInValue(final String key, final String... tokens) throws SikevaDBException @@ -1519,10 +1498,8 @@ public class FileTreeSikevaDB implements SikevaDB this.logger.info("replaceInValue done."); } - /** - * {@inheritDoc} - * - * @throws SikevaDBException + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#replaceInValues(java.lang.String, java.lang.String[]) */ @Override public void replaceInValues(final String key, final String... tokens) throws SikevaDBException diff --git a/src/fr/devinsy/sikevadb/sql/SQLSikevaDB.java b/src/fr/devinsy/sikevadb/sql/SQLSikevaDB.java index 0ad04f0..157a2d2 100644 --- a/src/fr/devinsy/sikevadb/sql/SQLSikevaDB.java +++ b/src/fr/devinsy/sikevadb/sql/SQLSikevaDB.java @@ -145,9 +145,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#clear() */ @Override public void clear() throws SikevaDBException @@ -180,9 +179,8 @@ public class SQLSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#close() */ @Override public void close() @@ -262,9 +260,8 @@ public class SQLSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#countOfElements() */ @Override public long countOfElements() throws SikevaDBException @@ -305,9 +302,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#countOfElements(java.lang.String) */ @Override public long countOfElements(final String key) throws SikevaDBException @@ -356,9 +352,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#countOfElements(java.lang.String, long) */ @Override public long countOfElements(final String key, final long subkey) throws SikevaDBException @@ -371,9 +366,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#countOfElements(java.lang.String, java.lang.String) */ @Override public long countOfElements(final String key, final String subkey) throws SikevaDBException @@ -427,9 +421,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#create() */ @Override public void create() throws SikevaDBException @@ -500,9 +493,8 @@ public class SQLSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#delete(java.lang.String) */ @Override public void delete(final String key) throws SikevaDBException @@ -532,12 +524,12 @@ public class SQLSikevaDB implements SikevaDB if (rowCount == 0) { - logger.warn("Remove action without existing target [key=" + key + "]"); + logger.warn("Delete action without existing target [key=" + key + "]"); } } catch (SQLException exception) { - logger.error("Error removing element.", exception); + logger.error("Error deleting element.", exception); try { connection.rollback(); @@ -546,7 +538,7 @@ public class SQLSikevaDB implements SikevaDB { logger.error("Rollback failed.", exception); } - throw new SikevaDBException("Error removing element", exception); + throw new SikevaDBException("Error deleting element", exception); } finally { @@ -560,9 +552,8 @@ public class SQLSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#delete(java.lang.String, long) */ @Override public void delete(final String key, final long subkey) throws SikevaDBException @@ -570,9 +561,8 @@ public class SQLSikevaDB implements SikevaDB delete(key, String.valueOf(subkey)); } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#delete(java.lang.String, java.lang.String) */ @Override public void delete(final String key, final String subkey) throws SikevaDBException @@ -606,13 +596,13 @@ public class SQLSikevaDB implements SikevaDB if (rowCount == 0) { - logger.warn("Remove action without existing target [key=" + key + "][subkey=" + subkey + "]"); + logger.warn("Delete action without existing target [key=" + key + "][subkey=" + subkey + "]"); } } catch (SQLException exception) { - logger.error("Error removing subkey.", exception); - throw new SikevaDBException("Error removing subkey", exception); + logger.error("Error deleting subkey.", exception); + throw new SikevaDBException("Error deleting subkey", exception); } finally { @@ -626,9 +616,8 @@ public class SQLSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#deleteMany(java.lang.String, java.lang.String[]) */ @Override public void deleteMany(final String key, final String... subkeys) throws SikevaDBException @@ -666,13 +655,13 @@ public class SQLSikevaDB implements SikevaDB int rowCount = statement.executeUpdate(); if (rowCount == 0) { - logger.warn("Remove action without existing target [key=" + key + "][subkeys=" + new StringList(subkeys).toStringWithCommas() + "]"); + logger.warn("Delete action without existing target [key=" + key + "][subkeys=" + new StringList(subkeys).toStringWithCommas() + "]"); } } catch (SQLException exception) { - logger.error("Error removing subkeys.", exception); - throw new SikevaDBException("Error removing subkeys", exception); + logger.error("Error deleting subkeys.", exception); + throw new SikevaDBException("Error deleting subkeys", exception); } finally { @@ -686,9 +675,8 @@ public class SQLSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#destroy() */ @Override public void destroy() throws SikevaDBException @@ -696,6 +684,21 @@ public class SQLSikevaDB implements SikevaDB // TODO } + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#exists() + */ + @Override + public boolean exists() throws SikevaDBException + { + boolean result; + + // TODO + result = false; + + // + return result; + } + /** * Exists. * @@ -769,7 +772,12 @@ public class SQLSikevaDB implements SikevaDB */ public String getContextName() { - return this.contextName; + String result; + + result = this.contextName; + + // + return result; } /** @@ -779,7 +787,12 @@ public class SQLSikevaDB implements SikevaDB */ public String getDriverClassname() { - return this.driverClassname; + String result; + + result = this.driverClassname; + + // + return result; } /** @@ -803,7 +816,6 @@ public class SQLSikevaDB implements SikevaDB } else { - // Connection connection = null; PreparedStatement statement = null; ResultSet resultSet = null; @@ -863,9 +875,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getElement(java.lang.String) */ @Override public Element getElement(final String key) throws SikevaDBException @@ -880,7 +891,6 @@ public class SQLSikevaDB implements SikevaDB } else { - // Connection connection = null; PreparedStatement statement = null; ResultSet resultSet = null; @@ -941,9 +951,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getElement(java.lang.String, long) */ @Override public Element getElement(final String key, final long subkey) throws SikevaDBException @@ -956,9 +965,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getElement(java.lang.String, java.lang.String) */ @Override public Element getElement(final String key, final String subkey) throws SikevaDBException @@ -977,7 +985,6 @@ public class SQLSikevaDB implements SikevaDB } else { - // Connection connection = null; PreparedStatement statement = null; ResultSet resultSet = null; @@ -1040,9 +1047,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getElements() */ @Override public Elements getElements() throws SikevaDBException @@ -1104,9 +1110,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getElements(java.lang.String) */ @Override public Elements getElements(final String key) throws SikevaDBException @@ -1176,9 +1181,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getKeys() */ @Override public StringList getKeys() throws SikevaDBException @@ -1232,7 +1236,12 @@ public class SQLSikevaDB implements SikevaDB */ public String getLogin() { - return this.login; + String result; + + result = this.login; + + // + return result; } /** @@ -1242,12 +1251,16 @@ public class SQLSikevaDB implements SikevaDB */ public String getPassword() { - return this.password; + String result; + + result = this.password; + + // + return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getSubkeys(java.lang.String) */ @Override public StringList getSubkeys(final String key) throws SikevaDBException @@ -1310,12 +1323,16 @@ public class SQLSikevaDB implements SikevaDB */ public String getUrl() { - return this.url; + String result; + + result = this.url; + + // + return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getValue(java.lang.String) */ @Override public String getValue(final String key) throws SikevaDBException @@ -1378,9 +1395,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getValue(java.lang.String, long) */ @Override public String getValue(final String key, final long subkey) throws SikevaDBException @@ -1393,9 +1409,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getValue(java.lang.String, java.lang.String) */ @Override public String getValue(final String key, final String subkey) throws SikevaDBException @@ -1463,9 +1478,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#getValues(java.lang.String) */ @Override public StringList getValues(final String key) throws SikevaDBException @@ -1513,9 +1527,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#isArchiveActivated() */ @Override public boolean isArchiveActivated() @@ -1535,9 +1548,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#isArchiveSuspended() */ @Override public boolean isArchiveSuspended() @@ -1550,9 +1562,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#isClosed() */ @Override public boolean isClosed() @@ -1572,25 +1583,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * - */ - @Override - public boolean isCreated() throws SikevaDBException - { - boolean result; - - // TODO - result = false; - - // - return result; - } - - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#isOpened() */ @Override public boolean isOpened() @@ -1603,9 +1597,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#memorySize() */ @Override public long memorySize() throws SikevaDBException @@ -1647,9 +1640,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#memorySize(java.lang.String) */ @Override public long memorySize(final String key) throws SikevaDBException @@ -1698,9 +1690,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#memorySize(java.lang.String, long) */ @Override public long memorySize(final String key, final long subkey) throws SikevaDBException @@ -1713,9 +1704,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#memorySize(java.lang.String, java.lang.String) */ @Override public long memorySize(final String key, final String subkey) throws SikevaDBException @@ -1770,9 +1760,8 @@ public class SQLSikevaDB implements SikevaDB return result; } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#open() */ @Override public void open() throws SikevaDBException @@ -1832,9 +1821,8 @@ public class SQLSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#put(fr.devinsy.sikevadb.core.Element) */ @Override public void put(final Element element) throws SikevaDBException @@ -1961,9 +1949,8 @@ public class SQLSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#put(java.lang.String, long, java.lang.String) */ @Override public void put(final String key, final long subkey, final String value) throws SikevaDBException @@ -1971,9 +1958,8 @@ public class SQLSikevaDB implements SikevaDB put(key, String.valueOf(subkey), String.valueOf(value)); } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#put(java.lang.String, java.lang.String) */ @Override public void put(final String key, final String value) throws SikevaDBException @@ -2059,9 +2045,8 @@ public class SQLSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#put(java.lang.String, java.lang.String, java.lang.String) */ @Override public void put(final String key, final String subkey, final String value) throws SikevaDBException @@ -2160,9 +2145,8 @@ public class SQLSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#renameKey(java.lang.String, java.lang.String) */ @Override public void renameKey(final String oldKey, final String newKey) throws SikevaDBException @@ -2216,9 +2200,8 @@ public class SQLSikevaDB implements SikevaDB logger.info("renameKey done."); } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#renameSubkey(java.lang.String, long, long) */ @Override public void renameSubkey(final String key, final long oldSubkey, final long newSubkey) throws SikevaDBException @@ -2226,9 +2209,8 @@ public class SQLSikevaDB implements SikevaDB renameSubkey(key, String.valueOf(oldSubkey), String.valueOf(newSubkey)); } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#renameSubkey(java.lang.String, java.lang.String, java.lang.String) */ @Override public void renameSubkey(final String key, final String oldKey, final String newKey) throws SikevaDBException @@ -2250,9 +2232,8 @@ public class SQLSikevaDB implements SikevaDB } } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#replaceInValue(java.lang.String, java.lang.String[]) */ @Override public void replaceInValue(final String key, final String... tokens) throws SikevaDBException @@ -2281,9 +2262,8 @@ public class SQLSikevaDB implements SikevaDB logger.info("replaceInValue done."); } - /** - * {@inheritDoc} - * + /* (non-Javadoc) + * @see fr.devinsy.sikevadb.core.SikevaDB#replaceInValues(java.lang.String, java.lang.String[]) */ @Override public void replaceInValues(final String key, final String... tokens) throws SikevaDBException diff --git a/test/fr/devinsy/sikevadb/filetree/TreeFileSikevaDBTest.java b/test/fr/devinsy/sikevadb/filetree/TreeFileSikevaDBTest.java index a9b1d60..c3c6d71 100644 --- a/test/fr/devinsy/sikevadb/filetree/TreeFileSikevaDBTest.java +++ b/test/fr/devinsy/sikevadb/filetree/TreeFileSikevaDBTest.java @@ -695,7 +695,7 @@ public class TreeFileSikevaDBTest File homeDirectory = new File("/tmp/footest"); database = new FileTreeSikevaDB(homeDirectory, null, null); - if (!database.isCreated()) + if (!database.exists()) { database.create(); }