Added opened database check. Renamed remove method with delete.
This commit is contained in:
parent
0303fee50b
commit
b17515229a
5 changed files with 599 additions and 416 deletions
64
src/fr/devinsy/sikevadb/core/UnopenedDatabaseException.java
Normal file
64
src/fr/devinsy/sikevadb/core/UnopenedDatabaseException.java
Normal 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);
|
||||
}
|
||||
}
|
|
@ -1005,7 +1005,7 @@ public class FileTreeSikevaDB implements SikevaDB
|
|||
* @see fr.devinsy.sikevadb.core.SikevaDB#remove(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void remove(final String key) throws SikevaDBException
|
||||
public void delete(final String key) throws SikevaDBException
|
||||
{
|
||||
if (this.status == Status.CLOSED)
|
||||
{
|
||||
|
@ -1038,7 +1038,7 @@ public class FileTreeSikevaDB implements SikevaDB
|
|||
* @see fr.devinsy.sikevadb.core.SikevaDB#remove(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void remove(final String key, final String subkey) throws SikevaDBException
|
||||
public void delete(final String key, final String subkey) throws SikevaDBException
|
||||
{
|
||||
if (this.status == Status.CLOSED)
|
||||
{
|
||||
|
@ -1072,7 +1072,7 @@ public class FileTreeSikevaDB implements SikevaDB
|
|||
* @see fr.devinsy.sikevadb.core.SikevaDB#removeMany(java.lang.String, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public void removeMany(final String key, final String... subkeys) throws SikevaDBException
|
||||
public void deleteMany(final String key, final String... subkeys) throws SikevaDBException
|
||||
{
|
||||
if (this.status == Status.CLOSED)
|
||||
{
|
||||
|
@ -1088,7 +1088,7 @@ public class FileTreeSikevaDB implements SikevaDB
|
|||
{
|
||||
for (String subkey : subkeys)
|
||||
{
|
||||
remove(key, subkey);
|
||||
delete(key, subkey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -501,7 +501,7 @@ public class TreeFileSikevaDBTest
|
|||
|
||||
Assert.assertEquals(12, database.countOfElements());
|
||||
|
||||
database.removeMany("alpha01", "bravo", "delta", "fox");
|
||||
database.deleteMany("alpha01", "bravo", "delta", "fox");
|
||||
|
||||
Assert.assertEquals(9, database.countOfElements());
|
||||
|
||||
|
@ -560,14 +560,14 @@ public class TreeFileSikevaDBTest
|
|||
database.put("alpha03", "qlskjfmlqj");
|
||||
database.put("alpha04", "qlskjfmlqj");
|
||||
database.put("alpha05", "qlskjfmlqj");
|
||||
database.remove("alpha03");
|
||||
database.delete("alpha03");
|
||||
database.put("alpha01s", "bravo1", "qlskjfmlqja");
|
||||
database.put("alpha01s", "bravo1", "qlskjfmlqjb");
|
||||
database.put("alpha01s", "bravo2", "qlskjfmlqj");
|
||||
database.put("alpha01s", "bravo3", "qlskjfmlqj");
|
||||
database.put("alpha01s", "bravo4", "qlskjfmlqj");
|
||||
database.put("alpha01s", "bravo5", "qlskjfmlqj");
|
||||
database.remove("alpha01s", "bravo3");
|
||||
database.delete("alpha01s", "bravo3");
|
||||
|
||||
// System.out.println(database.countOfElements() + " " +
|
||||
// database.countOfArchivedElements() + " " +
|
||||
|
|
|
@ -566,7 +566,7 @@ public class SQLSikevaDBTest
|
|||
|
||||
Assert.assertEquals(12, database.countOfElements());
|
||||
|
||||
database.removeMany("alpha01", "bravo", "delta", "fox");
|
||||
database.deleteMany("alpha01", "bravo", "delta", "fox");
|
||||
|
||||
Assert.assertEquals(9, database.countOfElements());
|
||||
|
||||
|
@ -625,14 +625,14 @@ public class SQLSikevaDBTest
|
|||
database.put("alpha03", "qlskjfmlqj");
|
||||
database.put("alpha04", "qlskjfmlqj");
|
||||
database.put("alpha05", "qlskjfmlqj");
|
||||
database.remove("alpha03");
|
||||
database.delete("alpha03");
|
||||
database.put("alpha01", "bravo1", "qlskjfmlqja");
|
||||
database.put("alpha01", "bravo1", "qlskjfmlqjb");
|
||||
database.put("alpha01", "bravo2", "qlskjfmlqj");
|
||||
database.put("alpha01", "bravo3", "qlskjfmlqj");
|
||||
database.put("alpha01", "bravo4", "qlskjfmlqj");
|
||||
database.put("alpha01", "bravo5", "qlskjfmlqj");
|
||||
database.remove("alpha01", "bravo3");
|
||||
database.delete("alpha01", "bravo3");
|
||||
|
||||
// System.out.println(database.countOfElements() + " " +
|
||||
// database.countOfArchivedElements() + " " +
|
||||
|
|
Loading…
Reference in a new issue