Reviewed Javadoc.

This commit is contained in:
Christian P. MOMON 2018-02-28 13:39:29 +01:00
parent cea1dd448e
commit 615cc5e908
6 changed files with 339 additions and 312 deletions

View file

@ -152,6 +152,12 @@ public interface SikevaDB
*/ */
void deleteMany(final String key, final String... subkeys) throws SikevaDBException; void deleteMany(final String key, final String... subkeys) throws SikevaDBException;
/**
* Destroy.
*
* @throws SikevaDBException
* the sikeva DB exception
*/
public void destroy() throws SikevaDBException; public void destroy() throws SikevaDBException;
/** /**
@ -297,7 +303,7 @@ public interface SikevaDB
* @throws SikevaDBException * @throws SikevaDBException
* the SikevaDB exception * the SikevaDB exception
*/ */
public boolean isCreated() throws SikevaDBException; public boolean exists() throws SikevaDBException;
/** /**
* Checks if is opened. * Checks if is opened.

View file

@ -0,0 +1,64 @@
/*
* Copyright (C) 2018 Christian Pierre MOMON <christian.momon@devinsy.fr>
*
* 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 <http://www.gnu.org/licenses/>.
*/
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);
}
}

View file

@ -62,7 +62,7 @@ public final class SikevaDBDemo
File homeDirectory = new File("/tmp/footest"); File homeDirectory = new File("/tmp/footest");
database = SikevaDBFactory.get(homeDirectory); database = SikevaDBFactory.get(homeDirectory);
if (database.isCreated()) if (database.exists())
{ {
database.destroy(); database.destroy();
} }
@ -136,7 +136,7 @@ public final class SikevaDBDemo
} }
finally finally
{ {
if ((database != null) && (database.isCreated())) if ((database != null) && (database.exists()))
{ {
database.destroy(); database.destroy();
} }

View file

@ -110,9 +110,6 @@ public class FileTreeSikevaDB implements SikevaDB
/* (non-Javadoc) /* (non-Javadoc)
* @see fr.devinsy.sikevadb.core.SikevaDB#archiver() * @see fr.devinsy.sikevadb.core.SikevaDB#archiver()
*/ */
/**
* {@inheritDoc}
*/
@Override @Override
public Archiver archiver() throws SikevaDBException public Archiver archiver() throws SikevaDBException
{ {
@ -146,9 +143,8 @@ public class FileTreeSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#close()
*
*/ */
@Override @Override
public void close() throws SikevaDBException public void close() throws SikevaDBException
@ -165,9 +161,8 @@ public class FileTreeSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#countOfElements()
*
*/ */
@Override @Override
public long countOfElements() throws SikevaDBException public long countOfElements() throws SikevaDBException
@ -202,11 +197,8 @@ public class FileTreeSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#countOfElements(java.lang.String)
*
* @throws SikevaDBException
*
*/ */
@Override @Override
public long countOfElements(final String key) throws SikevaDBException public long countOfElements(final String key) throws SikevaDBException
@ -243,9 +235,8 @@ public class FileTreeSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#countOfElements(java.lang.String, long)
*
*/ */
@Override @Override
public long countOfElements(final String key, final long subkey) throws SikevaDBException public long countOfElements(final String key, final long subkey) throws SikevaDBException
@ -258,9 +249,8 @@ public class FileTreeSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#countOfElements(java.lang.String, java.lang.String)
*
*/ */
@Override @Override
public long countOfElements(final String key, final String subkey) throws SikevaDBException public long countOfElements(final String key, final String subkey) throws SikevaDBException
@ -296,9 +286,8 @@ public class FileTreeSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#create()
*
*/ */
@Override @Override
public void create() throws SikevaDBException public void create() throws SikevaDBException
@ -323,9 +312,8 @@ public class FileTreeSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#delete(java.lang.String)
*
*/ */
@Override @Override
public void delete(final String key) throws SikevaDBException public void delete(final String key) throws SikevaDBException
@ -345,12 +333,12 @@ public class FileTreeSikevaDB implements SikevaDB
boolean result = targetFile.delete(); boolean result = targetFile.delete();
if (!result) if (!result)
{ {
throw new SikevaDBException("Error removing [" + targetFile.getAbsolutePath() + "]"); throw new SikevaDBException("Error deleting [" + targetFile.getAbsolutePath() + "]");
} }
} }
else 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
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#delete(java.lang.String, long)
*
*/ */
@Override @Override
public void delete(final String key, final long subkey) throws SikevaDBException 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)); delete(key, String.valueOf(subkey));
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#delete(java.lang.String, java.lang.String)
*
*/ */
@Override @Override
public void delete(final String key, final String subkey) throws SikevaDBException public void delete(final String key, final String subkey) throws SikevaDBException
@ -393,12 +379,12 @@ public class FileTreeSikevaDB implements SikevaDB
boolean result = targetFile.delete(); boolean result = targetFile.delete();
if (!result) if (!result)
{ {
throw new SikevaDBException("Error removing [" + targetFile.getAbsolutePath() + "]"); throw new SikevaDBException("Error deleting [" + targetFile.getAbsolutePath() + "]");
} }
} }
else 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
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#deleteMany(java.lang.String, java.lang.String[])
*
*/ */
@Override @Override
public void deleteMany(final String key, final String... subkeys) throws SikevaDBException public void deleteMany(final String key, final String... subkeys) throws SikevaDBException
@ -438,9 +423,8 @@ public class FileTreeSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#destroy()
*
*/ */
@Override @Override
public void destroy() throws SikevaDBException public void destroy() throws SikevaDBException
@ -486,7 +470,7 @@ public class FileTreeSikevaDB implements SikevaDB
{ {
throw new SikevaDBException("Invalid config directory (), destroy operation is cancelled."); throw new SikevaDBException("Invalid config directory (), destroy operation is cancelled.");
} }
else if (isCreated()) else if (exists())
{ {
try 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. * Gets the config directory.
* *
@ -511,7 +516,12 @@ public class FileTreeSikevaDB implements SikevaDB
*/ */
public File getConfigDirectory() 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() public File getDataDirectory()
{ {
return this.dataDirectory; File result;
result = this.dataDirectory;
//
return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getElement(java.lang.String)
*
*/ */
@Override @Override
public Element getElement(final String key) throws SikevaDBException public Element getElement(final String key) throws SikevaDBException
@ -559,9 +573,8 @@ public class FileTreeSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getElement(java.lang.String, long)
*
*/ */
@Override @Override
public Element getElement(final String key, final long subkey) throws SikevaDBException public Element getElement(final String key, final long subkey) throws SikevaDBException
@ -574,9 +587,8 @@ public class FileTreeSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getElement(java.lang.String, java.lang.String)
*
*/ */
@Override @Override
public Element getElement(final String key, final String subkey) throws SikevaDBException public Element getElement(final String key, final String subkey) throws SikevaDBException
@ -612,8 +624,8 @@ public class FileTreeSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getElements()
*/ */
@Override @Override
public Elements getElements() throws SikevaDBException public Elements getElements() throws SikevaDBException
@ -658,9 +670,8 @@ public class FileTreeSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getElements(java.lang.String)
*
*/ */
@Override @Override
public Elements getElements(final String key) throws SikevaDBException public Elements getElements(final String key) throws SikevaDBException
@ -706,13 +717,16 @@ public class FileTreeSikevaDB implements SikevaDB
*/ */
public File getFileTreeDirectory() public File getFileTreeDirectory()
{ {
return this.homeDirectory; File result;
result = this.homeDirectory;
//
return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getKeys()
*
* @throws SikevaDBException
*/ */
@Override @Override
public StringList getKeys() throws SikevaDBException public StringList getKeys() throws SikevaDBException
@ -760,7 +774,12 @@ public class FileTreeSikevaDB implements SikevaDB
*/ */
public String getLogin() 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() public String getPassword()
{ {
return this.password; String result;
result = this.password;
//
return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getSubkeys(java.lang.String)
*
* @throws SikevaDBException
*/ */
@Override @Override
public StringList getSubkeys(final String key) throws SikevaDBException public StringList getSubkeys(final String key) throws SikevaDBException
@ -814,10 +836,8 @@ public class FileTreeSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getValue(java.lang.String)
*
* @throws SikevaDBException
*/ */
@Override @Override
public String getValue(final String key) throws SikevaDBException public String getValue(final String key) throws SikevaDBException
@ -854,9 +874,8 @@ public class FileTreeSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getValue(java.lang.String, long)
*
*/ */
@Override @Override
public String getValue(final String key, final long subkey) throws SikevaDBException public String getValue(final String key, final long subkey) throws SikevaDBException
@ -869,10 +888,8 @@ public class FileTreeSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getValue(java.lang.String, java.lang.String)
*
* @throws SikevaDBException
*/ */
@Override @Override
public String getValue(final String key, final String subkey) throws SikevaDBException public String getValue(final String key, final String subkey) throws SikevaDBException
@ -910,10 +927,8 @@ public class FileTreeSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getValues(java.lang.String)
*
* @throws SikevaDBException
*/ */
@Override @Override
public StringList getValues(final String key) throws SikevaDBException public StringList getValues(final String key) throws SikevaDBException
@ -1008,27 +1023,6 @@ public class FileTreeSikevaDB implements SikevaDB
return result; 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) /* (non-Javadoc)
* @see fr.devinsy.sikevadb.core.SikevaDB#isOpened() * @see fr.devinsy.sikevadb.core.SikevaDB#isOpened()
*/ */
@ -1050,10 +1044,8 @@ public class FileTreeSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#memorySize()
*
* @throws SikevaDBException
*/ */
@Override @Override
public long memorySize() throws SikevaDBException public long memorySize() throws SikevaDBException
@ -1100,10 +1092,8 @@ public class FileTreeSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#memorySize(java.lang.String)
*
* @throws SikevaDBException
*/ */
@Override @Override
public long memorySize(final String key) throws SikevaDBException public long memorySize(final String key) throws SikevaDBException
@ -1150,9 +1140,8 @@ public class FileTreeSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#memorySize(java.lang.String, long)
*
*/ */
@Override @Override
public long memorySize(final String key, final long subkey) throws SikevaDBException public long memorySize(final String key, final long subkey) throws SikevaDBException
@ -1165,9 +1154,8 @@ public class FileTreeSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#memorySize(java.lang.String, java.lang.String)
*
*/ */
@Override @Override
public long memorySize(final String key, final String subkey) throws SikevaDBException public long memorySize(final String key, final String subkey) throws SikevaDBException
@ -1206,13 +1194,13 @@ public class FileTreeSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#open()
*/ */
@Override @Override
public void open() throws SikevaDBException public void open() throws SikevaDBException
{ {
if (isCreated()) if (exists())
{ {
if (isOpened()) if (isOpened())
{ {
@ -1230,10 +1218,8 @@ public class FileTreeSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#put(fr.devinsy.sikevadb.core.Element)
*
* @throws SikevaDBException
*/ */
@Override @Override
public void put(final Element element) throws SikevaDBException public void put(final Element element) throws SikevaDBException
@ -1282,9 +1268,8 @@ public class FileTreeSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#put(java.lang.String, long, java.lang.String)
*
*/ */
@Override @Override
public void put(final String key, final long subkey, final String value) throws SikevaDBException 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); put(key, String.valueOf(subkey), value);
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#put(java.lang.String, java.lang.String)
*
*/ */
@Override @Override
public void put(final String key, final String value) throws SikevaDBException public void put(final String key, final String value) throws SikevaDBException
@ -1333,9 +1317,8 @@ public class FileTreeSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#put(java.lang.String, java.lang.String, java.lang.String)
*
*/ */
@Override @Override
public void put(final String key, final String subkey, final String value) throws SikevaDBException public void put(final String key, final String subkey, final String value) throws SikevaDBException
@ -1375,9 +1358,8 @@ public class FileTreeSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#renameKey(java.lang.String, java.lang.String)
*
*/ */
@Override @Override
public void renameKey(final String oldKey, final String newKey) throws SikevaDBException 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."); this.logger.debug("renameKey done.");
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#renameSubkey(java.lang.String, long, long)
*/ */
@Override @Override
public void renameSubkey(final String key, final long oldSubKey, final long newSubkey) throws SikevaDBException 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)); renameSubkey(key, String.valueOf(oldSubKey), String.valueOf(newSubkey));
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#renameSubkey(java.lang.String, java.lang.String, java.lang.String)
*
*/ */
@Override @Override
public void renameSubkey(final String key, final String oldSubkey, final String newSubkey) throws SikevaDBException 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."); this.logger.debug("renameSubKey done.");
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#replaceInValue(java.lang.String, java.lang.String[])
*
* @throws SikevaDBException
*/ */
@Override @Override
public void replaceInValue(final String key, final String... tokens) throws SikevaDBException 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."); this.logger.info("replaceInValue done.");
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#replaceInValues(java.lang.String, java.lang.String[])
*
* @throws SikevaDBException
*/ */
@Override @Override
public void replaceInValues(final String key, final String... tokens) throws SikevaDBException public void replaceInValues(final String key, final String... tokens) throws SikevaDBException

View file

@ -145,9 +145,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#clear()
*
*/ */
@Override @Override
public void clear() throws SikevaDBException public void clear() throws SikevaDBException
@ -180,9 +179,8 @@ public class SQLSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#close()
*
*/ */
@Override @Override
public void close() public void close()
@ -262,9 +260,8 @@ public class SQLSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#countOfElements()
*
*/ */
@Override @Override
public long countOfElements() throws SikevaDBException public long countOfElements() throws SikevaDBException
@ -305,9 +302,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#countOfElements(java.lang.String)
*
*/ */
@Override @Override
public long countOfElements(final String key) throws SikevaDBException public long countOfElements(final String key) throws SikevaDBException
@ -356,9 +352,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#countOfElements(java.lang.String, long)
*
*/ */
@Override @Override
public long countOfElements(final String key, final long subkey) throws SikevaDBException public long countOfElements(final String key, final long subkey) throws SikevaDBException
@ -371,9 +366,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#countOfElements(java.lang.String, java.lang.String)
*
*/ */
@Override @Override
public long countOfElements(final String key, final String subkey) throws SikevaDBException public long countOfElements(final String key, final String subkey) throws SikevaDBException
@ -427,9 +421,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#create()
*
*/ */
@Override @Override
public void create() throws SikevaDBException public void create() throws SikevaDBException
@ -500,9 +493,8 @@ public class SQLSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#delete(java.lang.String)
*
*/ */
@Override @Override
public void delete(final String key) throws SikevaDBException public void delete(final String key) throws SikevaDBException
@ -532,12 +524,12 @@ public class SQLSikevaDB implements SikevaDB
if (rowCount == 0) if (rowCount == 0)
{ {
logger.warn("Remove action without existing target [key=" + key + "]"); logger.warn("Delete action without existing target [key=" + key + "]");
} }
} }
catch (SQLException exception) catch (SQLException exception)
{ {
logger.error("Error removing element.", exception); logger.error("Error deleting element.", exception);
try try
{ {
connection.rollback(); connection.rollback();
@ -546,7 +538,7 @@ public class SQLSikevaDB implements SikevaDB
{ {
logger.error("Rollback failed.", exception); logger.error("Rollback failed.", exception);
} }
throw new SikevaDBException("Error removing element", exception); throw new SikevaDBException("Error deleting element", exception);
} }
finally finally
{ {
@ -560,9 +552,8 @@ public class SQLSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#delete(java.lang.String, long)
*
*/ */
@Override @Override
public void delete(final String key, final long subkey) throws SikevaDBException 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)); delete(key, String.valueOf(subkey));
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#delete(java.lang.String, java.lang.String)
*
*/ */
@Override @Override
public void delete(final String key, final String subkey) throws SikevaDBException public void delete(final String key, final String subkey) throws SikevaDBException
@ -606,13 +596,13 @@ public class SQLSikevaDB implements SikevaDB
if (rowCount == 0) 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) catch (SQLException exception)
{ {
logger.error("Error removing subkey.", exception); logger.error("Error deleting subkey.", exception);
throw new SikevaDBException("Error removing subkey", exception); throw new SikevaDBException("Error deleting subkey", exception);
} }
finally finally
{ {
@ -626,9 +616,8 @@ public class SQLSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#deleteMany(java.lang.String, java.lang.String[])
*
*/ */
@Override @Override
public void deleteMany(final String key, final String... subkeys) throws SikevaDBException public void deleteMany(final String key, final String... subkeys) throws SikevaDBException
@ -666,13 +655,13 @@ public class SQLSikevaDB implements SikevaDB
int rowCount = statement.executeUpdate(); int rowCount = statement.executeUpdate();
if (rowCount == 0) 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) catch (SQLException exception)
{ {
logger.error("Error removing subkeys.", exception); logger.error("Error deleting subkeys.", exception);
throw new SikevaDBException("Error removing subkeys", exception); throw new SikevaDBException("Error deleting subkeys", exception);
} }
finally finally
{ {
@ -686,9 +675,8 @@ public class SQLSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#destroy()
*
*/ */
@Override @Override
public void destroy() throws SikevaDBException public void destroy() throws SikevaDBException
@ -696,6 +684,21 @@ public class SQLSikevaDB implements SikevaDB
// TODO // TODO
} }
/* (non-Javadoc)
* @see fr.devinsy.sikevadb.core.SikevaDB#exists()
*/
@Override
public boolean exists() throws SikevaDBException
{
boolean result;
// TODO
result = false;
//
return result;
}
/** /**
* Exists. * Exists.
* *
@ -769,7 +772,12 @@ public class SQLSikevaDB implements SikevaDB
*/ */
public String getContextName() 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() public String getDriverClassname()
{ {
return this.driverClassname; String result;
result = this.driverClassname;
//
return result;
} }
/** /**
@ -803,7 +816,6 @@ public class SQLSikevaDB implements SikevaDB
} }
else else
{ {
//
Connection connection = null; Connection connection = null;
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet resultSet = null; ResultSet resultSet = null;
@ -863,9 +875,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getElement(java.lang.String)
*
*/ */
@Override @Override
public Element getElement(final String key) throws SikevaDBException public Element getElement(final String key) throws SikevaDBException
@ -880,7 +891,6 @@ public class SQLSikevaDB implements SikevaDB
} }
else else
{ {
//
Connection connection = null; Connection connection = null;
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet resultSet = null; ResultSet resultSet = null;
@ -941,9 +951,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getElement(java.lang.String, long)
*
*/ */
@Override @Override
public Element getElement(final String key, final long subkey) throws SikevaDBException public Element getElement(final String key, final long subkey) throws SikevaDBException
@ -956,9 +965,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getElement(java.lang.String, java.lang.String)
*
*/ */
@Override @Override
public Element getElement(final String key, final String subkey) throws SikevaDBException public Element getElement(final String key, final String subkey) throws SikevaDBException
@ -977,7 +985,6 @@ public class SQLSikevaDB implements SikevaDB
} }
else else
{ {
//
Connection connection = null; Connection connection = null;
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet resultSet = null; ResultSet resultSet = null;
@ -1040,9 +1047,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getElements()
*
*/ */
@Override @Override
public Elements getElements() throws SikevaDBException public Elements getElements() throws SikevaDBException
@ -1104,9 +1110,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getElements(java.lang.String)
*
*/ */
@Override @Override
public Elements getElements(final String key) throws SikevaDBException public Elements getElements(final String key) throws SikevaDBException
@ -1176,9 +1181,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getKeys()
*
*/ */
@Override @Override
public StringList getKeys() throws SikevaDBException public StringList getKeys() throws SikevaDBException
@ -1232,7 +1236,12 @@ public class SQLSikevaDB implements SikevaDB
*/ */
public String getLogin() 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() public String getPassword()
{ {
return this.password; String result;
result = this.password;
//
return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getSubkeys(java.lang.String)
*
*/ */
@Override @Override
public StringList getSubkeys(final String key) throws SikevaDBException public StringList getSubkeys(final String key) throws SikevaDBException
@ -1310,12 +1323,16 @@ public class SQLSikevaDB implements SikevaDB
*/ */
public String getUrl() public String getUrl()
{ {
return this.url; String result;
result = this.url;
//
return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getValue(java.lang.String)
*
*/ */
@Override @Override
public String getValue(final String key) throws SikevaDBException public String getValue(final String key) throws SikevaDBException
@ -1378,9 +1395,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getValue(java.lang.String, long)
*
*/ */
@Override @Override
public String getValue(final String key, final long subkey) throws SikevaDBException public String getValue(final String key, final long subkey) throws SikevaDBException
@ -1393,9 +1409,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getValue(java.lang.String, java.lang.String)
*
*/ */
@Override @Override
public String getValue(final String key, final String subkey) throws SikevaDBException public String getValue(final String key, final String subkey) throws SikevaDBException
@ -1463,9 +1478,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#getValues(java.lang.String)
*
*/ */
@Override @Override
public StringList getValues(final String key) throws SikevaDBException public StringList getValues(final String key) throws SikevaDBException
@ -1513,9 +1527,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#isArchiveActivated()
*
*/ */
@Override @Override
public boolean isArchiveActivated() public boolean isArchiveActivated()
@ -1535,9 +1548,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#isArchiveSuspended()
*
*/ */
@Override @Override
public boolean isArchiveSuspended() public boolean isArchiveSuspended()
@ -1550,9 +1562,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#isClosed()
*
*/ */
@Override @Override
public boolean isClosed() public boolean isClosed()
@ -1572,25 +1583,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#isOpened()
*
*/
@Override
public boolean isCreated() throws SikevaDBException
{
boolean result;
// TODO
result = false;
//
return result;
}
/**
* {@inheritDoc}
*
*/ */
@Override @Override
public boolean isOpened() public boolean isOpened()
@ -1603,9 +1597,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#memorySize()
*
*/ */
@Override @Override
public long memorySize() throws SikevaDBException public long memorySize() throws SikevaDBException
@ -1647,9 +1640,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#memorySize(java.lang.String)
*
*/ */
@Override @Override
public long memorySize(final String key) throws SikevaDBException public long memorySize(final String key) throws SikevaDBException
@ -1698,9 +1690,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#memorySize(java.lang.String, long)
*
*/ */
@Override @Override
public long memorySize(final String key, final long subkey) throws SikevaDBException public long memorySize(final String key, final long subkey) throws SikevaDBException
@ -1713,9 +1704,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#memorySize(java.lang.String, java.lang.String)
*
*/ */
@Override @Override
public long memorySize(final String key, final String subkey) throws SikevaDBException public long memorySize(final String key, final String subkey) throws SikevaDBException
@ -1770,9 +1760,8 @@ public class SQLSikevaDB implements SikevaDB
return result; return result;
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#open()
*
*/ */
@Override @Override
public void open() throws SikevaDBException public void open() throws SikevaDBException
@ -1832,9 +1821,8 @@ public class SQLSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#put(fr.devinsy.sikevadb.core.Element)
*
*/ */
@Override @Override
public void put(final Element element) throws SikevaDBException public void put(final Element element) throws SikevaDBException
@ -1961,9 +1949,8 @@ public class SQLSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#put(java.lang.String, long, java.lang.String)
*
*/ */
@Override @Override
public void put(final String key, final long subkey, final String value) throws SikevaDBException 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)); put(key, String.valueOf(subkey), String.valueOf(value));
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#put(java.lang.String, java.lang.String)
*
*/ */
@Override @Override
public void put(final String key, final String value) throws SikevaDBException public void put(final String key, final String value) throws SikevaDBException
@ -2059,9 +2045,8 @@ public class SQLSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#put(java.lang.String, java.lang.String, java.lang.String)
*
*/ */
@Override @Override
public void put(final String key, final String subkey, final String value) throws SikevaDBException public void put(final String key, final String subkey, final String value) throws SikevaDBException
@ -2160,9 +2145,8 @@ public class SQLSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#renameKey(java.lang.String, java.lang.String)
*
*/ */
@Override @Override
public void renameKey(final String oldKey, final String newKey) throws SikevaDBException public void renameKey(final String oldKey, final String newKey) throws SikevaDBException
@ -2216,9 +2200,8 @@ public class SQLSikevaDB implements SikevaDB
logger.info("renameKey done."); logger.info("renameKey done.");
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#renameSubkey(java.lang.String, long, long)
*
*/ */
@Override @Override
public void renameSubkey(final String key, final long oldSubkey, final long newSubkey) throws SikevaDBException 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)); renameSubkey(key, String.valueOf(oldSubkey), String.valueOf(newSubkey));
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#renameSubkey(java.lang.String, java.lang.String, java.lang.String)
*
*/ */
@Override @Override
public void renameSubkey(final String key, final String oldKey, final String newKey) throws SikevaDBException public void renameSubkey(final String key, final String oldKey, final String newKey) throws SikevaDBException
@ -2250,9 +2232,8 @@ public class SQLSikevaDB implements SikevaDB
} }
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#replaceInValue(java.lang.String, java.lang.String[])
*
*/ */
@Override @Override
public void replaceInValue(final String key, final String... tokens) throws SikevaDBException public void replaceInValue(final String key, final String... tokens) throws SikevaDBException
@ -2281,9 +2262,8 @@ public class SQLSikevaDB implements SikevaDB
logger.info("replaceInValue done."); logger.info("replaceInValue done.");
} }
/** /* (non-Javadoc)
* {@inheritDoc} * @see fr.devinsy.sikevadb.core.SikevaDB#replaceInValues(java.lang.String, java.lang.String[])
*
*/ */
@Override @Override
public void replaceInValues(final String key, final String... tokens) throws SikevaDBException public void replaceInValues(final String key, final String... tokens) throws SikevaDBException

View file

@ -695,7 +695,7 @@ public class TreeFileSikevaDBTest
File homeDirectory = new File("/tmp/footest"); File homeDirectory = new File("/tmp/footest");
database = new FileTreeSikevaDB(homeDirectory, null, null); database = new FileTreeSikevaDB(homeDirectory, null, null);
if (!database.isCreated()) if (!database.exists())
{ {
database.create(); database.create();
} }