diff --git a/src/fr/devinsy/sikevadb/core/SikevaDB.java b/src/fr/devinsy/sikevadb/core/SikevaDB.java index 9e0ece9..174b656 100644 --- a/src/fr/devinsy/sikevadb/core/SikevaDB.java +++ b/src/fr/devinsy/sikevadb/core/SikevaDB.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2013-2017 Christian Pierre MOMON + * Copyright (C) 2013-2018 Christian Pierre MOMON * * This file is part of SikevaDB, simple key value database. * @@ -21,73 +21,349 @@ package fr.devinsy.sikevadb.core; import fr.devinsy.util.strings.StringList; /** - * + * The Interface SikevaDB. * * @author Christian Pierre MOMON */ public interface SikevaDB { + /** + * Delete all elements of current opened database. + * + * @throws SikevaDBException + * the SikevaDB exception + */ public void clear() throws SikevaDBException; + /** + * Close the current database session. + * + * @throws SikevaDBException + * the SikevaDB exception + */ public void close() throws SikevaDBException; + /** + * Count of elements in current database. + * + * @return the long + * @throws SikevaDBException + * the SikevaDB exception + */ public long countOfElements() throws SikevaDBException; + /** + * Count of elements by key. + * + * @param key + * the key + * @return the long + * @throws SikevaDBException + * the SikevaDB exception + */ public long countOfElements(String key) throws SikevaDBException; + /** + * Count of elements by key and subkey. + * + * @param key + * the key + * @param subkey + * the subkey + * @return the long + * @throws SikevaDBException + * the SikevaDB exception + */ public long countOfElements(String key, String subkey) throws SikevaDBException; + /** + * Creates the database. + * + * @throws SikevaDBException + * the SikevaDB exception + */ public void create() throws SikevaDBException; + /** + * Removes the. + * + * @param key + * the key + * @throws SikevaDBException + * the SikevaDB exception + */ + void delete(final String key) throws SikevaDBException; + + /** + * Delete. + * + * @param key + * the key + * @param subkey + * the subkey + * @throws SikevaDBException + * the SikevaDB exception + */ + void delete(final String key, final String subkey) throws SikevaDBException; + + /** + * Delete many. + * + * @param key + * the key + * @param subkeys + * the subkeys + * @throws SikevaDBException + * the SikevaDB exception + */ + void deleteMany(final String key, final String... subkeys) throws SikevaDBException; + + /** + * Gets an element by key. + * + * @param key + * the key + * @return the element + * @throws SikevaDBException + * the SikevaDB exception + */ public Element getElement(String key) throws SikevaDBException; + /** + * Gets an element by key and sub key. + * + * @param key + * the key + * @param subkey + * the sub key + * @return the element + * @throws SikevaDBException + * the SikevaDB exception + */ public Element getElement(String key, String subkey) throws SikevaDBException; + /** + * Gets all elements in current database. + * + * @return the elements + * @throws SikevaDBException + * the SikevaDB exception + */ public Elements getElements() throws SikevaDBException; + /** + * Gets all elements of a top key. + * + * @param key + * the key + * @return the elements + * @throws SikevaDBException + * the SikevaDB exception + */ public Elements getElements(String key) throws SikevaDBException; - public fr.devinsy.util.strings.StringList getKeys() throws SikevaDBException; + /** + * Gets all the top keys. + * + * @return the keys + * @throws SikevaDBException + * the SikevaDB exception + */ + public StringList getKeys() throws SikevaDBException; + /** + * Gets all the sub keys of a key. + * + * @param key + * the key + * @return the subkeys + * @throws SikevaDBException + * the SikevaDB exception + */ public StringList getSubkeys(String key) throws SikevaDBException; + /** + * Gets the value of a key. + * + * @param key + * the key + * @return the value + * @throws SikevaDBException + * the SikevaDB exception + */ public String getValue(String key) throws SikevaDBException; + /** + * Gets the value of a key and a sub key. + * + * @param key + * the key + * @param subkey + * the sub key + * @return the value + * @throws SikevaDBException + * the SikevaDB exception + */ public String getValue(String key, String subkey) throws SikevaDBException; + /** + * Gets the values of a key. + * + * @param key + * the key + * @return the values + * @throws SikevaDBException + * the SikevaDB exception + */ public StringList getValues(String key) throws SikevaDBException; + /** + * Checks if is closed. + * + * @return true, if is closed + */ public boolean isClosed(); + /** + * Checks if is created. + * + * @return true, if is created + * @throws SikevaDBException + * the SikevaDB exception + */ public boolean isCreated() throws SikevaDBException; + /** + * Checks if is opened. + * + * @return true, if is opened + */ public boolean isOpened(); + /** + * Returns the memory size of the elements in database. + * + * @return the long + * @throws SikevaDBException + * the SikevaDB exception + */ public long memorySize() throws SikevaDBException; + /** + * Returns the memory size of elements of a key. + * + * @param key + * the key + * @return the long + * @throws SikevaDBException + * the SikevaDB exception + */ public long memorySize(String key) throws SikevaDBException; + /** + * Returns the memory size of element of a key and a sub key. + * + * @param key + * the key + * @param subkey + * the sub key + * @return the long + * @throws SikevaDBException + * the SikevaDB exception + */ public long memorySize(String key, String subkey) throws SikevaDBException; + /** + * Open a database. + * + * @throws SikevaDBException + * the SikevaDB exception + */ void open() throws SikevaDBException; + /** + * Put an element in database. + * + * @param element + * the element + * @throws SikevaDBException + * the SikevaDB exception + */ void put(Element element) throws SikevaDBException; + /** + * Put a value for a key in current opened database. + * + * @param key + * the key + * @param value + * the value + * @throws SikevaDBException + * the SikevaDB exception + */ void put(String key, String value) throws SikevaDBException; + /** + * Put a value for a key and a sub key in current opened database. + * + * @param key + * the key + * @param subkey + * the subkey + * @param value + * the value + * @throws SikevaDBException + * the SikevaDB exception + */ void put(String key, String subkey, String value) throws SikevaDBException; - void remove(final String key) throws SikevaDBException; - - void remove(final String key, final String subkey) throws SikevaDBException; - - void removeMany(final String key, final String... subkeys) throws SikevaDBException; - + /** + * Rename a key. + * + * @param oldKey + * the old key + * @param newKey + * the new key + * @throws SikevaDBException + * the SikevaDB exception + */ void renameKey(final String oldKey, final String newKey) throws SikevaDBException; + /** + * Rename a sub key. + * + * @param key + * the key + * @param oldSubKey + * the old sub key + * @param newSubKey + * the new sub key + * @throws SikevaDBException + * the SikevaDB exception + */ void renameSubKey(final String key, final String oldSubKey, final String newSubKey) throws SikevaDBException; + /** + * Replace a substring in a value of a key. + * + * @param key + * the key + * @param tokens + * the tokens + * @throws SikevaDBException + * the SikevaDB exception + */ void replaceInValue(final String key, final String... tokens) throws SikevaDBException; + /** + * Replace a substring in values of all sub keys of a key. + * + * @param key + * the key + * @param tokens + * the tokens + * @throws SikevaDBException + * the SikevaDB exception + */ void replaceInValues(final String key, final String... tokens) throws SikevaDBException; }