Compare commits

..

46 commits
0.1 ... 1.17

Author SHA1 Message Date
52645283be Build 1.17.0 2024-08-23 12:19:52 +02:00
95feb60b49 Increased version number. 2024-08-23 12:18:01 +02:00
4018f2cc15 Made javadoc review. 2024-08-23 12:17:29 +02:00
5aaf1bf9f4 Set project encoding to UTF-8. 2024-08-23 12:05:52 +02:00
2410c1fa92 Upgraded libs. 2024-08-23 12:04:59 +02:00
9cfa1a36f3 Start migration to Java 17. 2024-08-23 10:51:29 +02:00
a27caf05a5 Migrated to Elcipse 4.16 and Java 11. 2020-08-14 17:59:24 +02:00
42899fd3d6 Step in Java 8 migration. 2020-08-14 17:57:15 +02:00
67592f8e86 Improved lib README. 2018-06-05 18:39:51 +02:00
5311b4b8ad Upgraded jar files. Upgraded Eclipse configuration to Java 8. Migrated
from JodaTime to java.time.
2018-06-05 14:54:25 +02:00
35c5fbfbf0 Init Java 8 migration. 2018-06-04 18:49:28 +02:00
4ee68495db Fixed Eclipse settings. 2018-05-25 09:59:53 +02:00
20842f3770 Cleaned code. 2018-05-25 09:52:11 +02:00
96ec235e9a Replaced devinsy-utils jar with devinsy-strings and devinsy-xml jars. 2018-03-01 01:10:51 +01:00
f68fb63e97 Build 1.0.1 2018-02-28 19:03:09 +01:00
36a8350b53 Fixed database export with unitary test. Added XML export in file. 2018-02-28 17:58:44 +01:00
240c9d28e9 Added export database in file method. 2018-02-28 17:25:25 +01:00
49d906a0b8 Refactored exception in XMLSikevaDB. 2018-02-28 17:17:41 +01:00
e939664d89 Updated headers. 2018-02-28 16:24:59 +01:00
70bb0c74dd Fixed XML export and getKeys methods (thanks Didier). Renamed getKeys
with getTopKeys.
2018-02-28 16:20:16 +01:00
280e8c7a57 Refactored code: added database status check in methods, replaced
NullPointerException with IllegarlArgumentException, fixed SQL create
method, improved code…
2018-02-28 16:04:50 +01:00
615cc5e908 Reviewed Javadoc. 2018-02-28 14:05:14 +01:00
cea1dd448e Reviewed Javadoc fo SikevaDB interface. Renamed remove method with
delete.
2018-02-28 13:28:21 +01:00
70ed239209 Build 1.0.0 2018-02-04 12:20:07 +01:00
431025f138 Refactored libs. 2017-05-03 19:33:31 +02:00
3281414dd4 Performed a Javadoc review. 2017-05-03 19:32:17 +02:00
b2a7877a8f Improved README. 2017-04-28 00:08:10 +02:00
ee3d1e98c4 Fixed old trace of another project. 2017-04-28 00:07:55 +02:00
27cd726adc Moved hsqldb jar to main list. 2017-04-26 14:36:48 +02:00
960cd5945e Improved README. 2017-04-26 14:36:03 +02:00
0641a8eec7 Refactored lib packages. 2017-04-26 14:02:31 +02:00
8bedd19e84 Improved demo display. 2017-04-26 09:27:23 +02:00
020df07995 Added database status check in methods. 2017-04-26 09:24:31 +02:00
7ea53a7955 Improved Demo. Added helper methods for numeric subkey. 2017-04-25 23:50:24 +02:00
ff63a72919 Completed Demo add. 2017-04-25 23:18:48 +02:00
57d846cc03 Add log4j.properties file. 2017-04-25 19:49:56 +02:00
b84362e31f Added demo code. 2017-04-25 19:49:37 +02:00
feddf34744 Improved naming. 2017-04-24 08:57:47 +02:00
3e91ccc342 Fixed naming. 2017-04-24 08:47:09 +02:00
e063099719 Added README.md file. 2017-04-22 01:45:46 +02:00
27a3ac09a4 Added Archiver. 2017-04-22 01:29:37 +02:00
d0f0f68ff7 Updated build version to 1.0 2017-04-21 19:47:05 +02:00
b04d79fd08 Refactored hugely to branch 1.0 2017-04-21 19:46:28 +02:00
ffdba7956c Cleaned code. 2016-12-13 17:06:25 +01:00
1ef88b0c7d Refactored SQL part to dedicated package. 2016-12-13 14:16:54 +01:00
bc969b91a6 Done a full code format review. Improve code format settings. 2016-05-27 15:17:19 +02:00
87 changed files with 8507 additions and 3573 deletions

View file

@ -2,27 +2,26 @@
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/> <classpathentry kind="src" path="test"/>
<classpathentry kind="lib" path="lib/commons-lang3-3.1.jar"/>
<classpathentry kind="lib" path="lib/hamcrest-core-1.3.jar"/>
<classpathentry kind="lib" path="lib/junit-4.11.jar" sourcepath="lib/junit-4.11-sources.jar"/>
<classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/>
<classpathentry kind="lib" path="lib/slf4j-api-1.7.5.jar"/>
<classpathentry kind="lib" path="lib/slf4j-log4j12-1.7.5.jar"/>
<classpathentry kind="lib" path="lib/commons-codec-1.8.jar"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0"> <classpathentry kind="lib" path="lib/UnitTesting/hamcrest-core-1.3.jar" sourcepath="lib/UnitTesting/hamcrest-core-1.3-sources.jar"/>
<attributes> <classpathentry kind="lib" path="lib/UnitTesting/junit-4.12.jar" sourcepath="lib/UnitTesting/junit-4.12-sources.jar"/>
<attribute name="owner.project.facets" value="jst.utility"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_45">
<attributes> <attributes>
<attribute name="module" value="true"/>
<attribute name="owner.project.facets" value="java"/> <attribute name="owner.project.facets" value="java"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="lib/mysql-jdbc-5.0.8.jar"/> <classpathentry kind="lib" path="lib/commons-io-2.16.1.jar" sourcepath="lib/commons-io-2.16.1-sources.jar"/>
<classpathentry kind="lib" path="lib/joda-time-2.3.jar" sourcepath="lib/joda-time-2.3-sources.jar"/> <classpathentry kind="lib" path="lib/commons-lang3-3.13.0.jar" sourcepath="lib/commons-lang3-3.13.0-sources.jar"/>
<classpathentry kind="lib" path="lib/hsqldb-2.3.0.jar"/> <classpathentry kind="lib" path="lib/devinsy-strings-0.17.0.jar" sourcepath="lib/devinsy-strings-0.17.0-sources.zip"/>
<classpathentry kind="lib" path="lib/devinsy-utils-0.2.12.jar" sourcepath="lib/devinsy-utils-0.2.12-sources.zip"/> <classpathentry kind="lib" path="lib/devinsy-xml-0.17.0.jar" sourcepath="lib/devinsy-xml-0.17.0-sources.zip"/>
<classpathentry kind="lib" path="lib/commons-codec-1.17.1.jar" sourcepath="lib/commons-codec-1.17.1-sources.jar"/>
<classpathentry kind="lib" path="lib/mariadb-java-client-3.4.1.jar"/>
<classpathentry kind="lib" path="lib/hsqldb-2.7.3.jar"/>
<classpathentry kind="lib" path="lib/Logs/log4j-api-2.23.1.jar"/>
<classpathentry kind="lib" path="lib/Logs/log4j-core-2.23.1.jar"/>
<classpathentry kind="lib" path="lib/Logs/log4j-slf4j2-impl-2.23.1.jar"/>
<classpathentry kind="lib" path="lib/Logs/slf4j-api-2.0.16.jar"/>
<classpathentry kind="lib" path="lib/commons-text-1.12.0.jar" sourcepath="lib/commons-text-1.12.0-sources.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View file

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View file

@ -1,11 +1,338 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=49
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_module_statements=16
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16
org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0
org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.blank_lines_before_field=0
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block=next_line
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line
org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line
org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=false
org.eclipse.jdt.core.formatter.comment.format_block_comments=false
org.eclipse.jdt.core.formatter.comment.format_header=false
org.eclipse.jdt.core.formatter.comment.format_html=true
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
org.eclipse.jdt.core.formatter.comment.format_source_code=true
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
org.eclipse.jdt.core.formatter.comment.line_length=80
org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
org.eclipse.jdt.core.formatter.compact_else_if=true
org.eclipse.jdt.core.formatter.continuation_indentation=2
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=false
org.eclipse.jdt.core.formatter.indent_empty_lines=false
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
org.eclipse.jdt.core.formatter.indentation.size=4
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.join_lines_in_comments=true
org.eclipse.jdt.core.formatter.join_wrapped_lines=true
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
org.eclipse.jdt.core.formatter.lineSplit=200
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines
org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines
org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines
org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines
org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines
org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines
org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines
org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines
org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines
org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=tab
org.eclipse.jdt.core.formatter.tabulation.size=4
org.eclipse.jdt.core.formatter.use_on_off_tags=false
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true
org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true
org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true
org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true

View file

@ -0,0 +1,116 @@
cleanup.add_default_serial_version_id=false
cleanup.add_generated_serial_version_id=true
cleanup.add_missing_annotations=true
cleanup.add_missing_deprecated_annotations=true
cleanup.add_missing_methods=false
cleanup.add_missing_nls_tags=false
cleanup.add_missing_override_annotations=true
cleanup.add_missing_override_annotations_interface_methods=true
cleanup.add_serial_version_id=true
cleanup.always_use_blocks=true
cleanup.always_use_parentheses_in_expressions=false
cleanup.always_use_this_for_non_static_field_access=true
cleanup.always_use_this_for_non_static_method_access=false
cleanup.convert_functional_interfaces=false
cleanup.convert_to_enhanced_for_loop=false
cleanup.correct_indentation=false
cleanup.format_source_code=true
cleanup.format_source_code_changes_only=false
cleanup.insert_inferred_type_arguments=false
cleanup.make_local_variable_final=false
cleanup.make_parameters_final=true
cleanup.make_private_fields_final=false
cleanup.make_type_abstract_if_missing_method=false
cleanup.make_variable_declarations_final=true
cleanup.never_use_blocks=false
cleanup.never_use_parentheses_in_expressions=true
cleanup.organize_imports=false
cleanup.qualify_static_field_accesses_with_declaring_class=false
cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=false
cleanup.qualify_static_member_accesses_with_declaring_class=true
cleanup.qualify_static_method_accesses_with_declaring_class=false
cleanup.remove_private_constructors=true
cleanup.remove_redundant_type_arguments=false
cleanup.remove_trailing_whitespaces=true
cleanup.remove_trailing_whitespaces_all=true
cleanup.remove_trailing_whitespaces_ignore_empty=false
cleanup.remove_unnecessary_casts=true
cleanup.remove_unnecessary_nls_tags=true
cleanup.remove_unused_imports=true
cleanup.remove_unused_local_variables=false
cleanup.remove_unused_private_fields=true
cleanup.remove_unused_private_members=false
cleanup.remove_unused_private_methods=true
cleanup.remove_unused_private_types=true
cleanup.sort_members=true
cleanup.sort_members_all=false
cleanup.use_anonymous_class_creation=false
cleanup.use_blocks=true
cleanup.use_blocks_only_for_return_and_throw=false
cleanup.use_lambda=true
cleanup.use_parentheses_in_expressions=false
cleanup.use_this_for_non_static_field_access=true
cleanup.use_this_for_non_static_field_access_only_if_necessary=false
cleanup.use_this_for_non_static_method_access=false
cleanup.use_this_for_non_static_method_access_only_if_necessary=true
cleanup_profile=_SikevaDB
cleanup_settings_version=2
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_SikevaDB
formatter_settings_version=13
jautodoc.cleanup.add_header=false
jautodoc.cleanup.replace_header=false
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
sp_cleanup.add_missing_annotations=true
sp_cleanup.add_missing_deprecated_annotations=true
sp_cleanup.add_missing_methods=false
sp_cleanup.add_missing_nls_tags=false
sp_cleanup.add_missing_override_annotations=true
sp_cleanup.add_missing_override_annotations_interface_methods=true
sp_cleanup.add_serial_version_id=false
sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=true
sp_cleanup.always_use_this_for_non_static_method_access=false
sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=true
sp_cleanup.format_source_code=true
sp_cleanup.format_source_code_changes_only=false
sp_cleanup.make_local_variable_final=false
sp_cleanup.make_parameters_final=true
sp_cleanup.make_private_fields_final=false
sp_cleanup.make_type_abstract_if_missing_method=false
sp_cleanup.make_variable_declarations_final=true
sp_cleanup.never_use_blocks=false
sp_cleanup.never_use_parentheses_in_expressions=true
sp_cleanup.on_save_use_additional_actions=true
sp_cleanup.organize_imports=true
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
sp_cleanup.remove_private_constructors=true
sp_cleanup.remove_trailing_whitespaces=false
sp_cleanup.remove_trailing_whitespaces_all=true
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
sp_cleanup.remove_unnecessary_casts=true
sp_cleanup.remove_unnecessary_nls_tags=true
sp_cleanup.remove_unused_imports=true
sp_cleanup.remove_unused_local_variables=false
sp_cleanup.remove_unused_private_fields=true
sp_cleanup.remove_unused_private_members=false
sp_cleanup.remove_unused_private_methods=true
sp_cleanup.remove_unused_private_types=true
sp_cleanup.sort_members=true
sp_cleanup.sort_members_all=false
sp_cleanup.use_blocks=true
sp_cleanup.use_blocks_only_for_return_and_throw=false
sp_cleanup.use_parentheses_in_expressions=false
sp_cleanup.use_this_for_non_static_field_access=true
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=false
sp_cleanup.use_this_for_non_static_method_access=false
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true

View file

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<faceted-project> <faceted-project>
<runtime name="Apache Tomcat v7.0"/>
<fixed facet="java"/> <fixed facet="java"/>
<fixed facet="jst.utility"/> <fixed facet="jst.utility"/>
<installed facet="java" version="1.6"/>
<installed facet="jst.utility" version="1.0"/> <installed facet="jst.utility" version="1.0"/>
<installed facet="java" version="17"/>
</faceted-project> </faceted-project>

38
README.md Normal file
View file

@ -0,0 +1,38 @@
# Welcome
SikevaDB is a Simple KEy VAlue DataBase.
Features:
* double key value
* single session only
* connector to file persistence
* connector to SQL persistence
Why build a single session database? Because, in so many cases, I need a single session only in my application.
Actually, the following backends are supported:
* file system
* MySQL Database
* HSQL Database
# LICENSE
SikevaDB is released under the GNU AGPL license. Enjoy!
# AUTHOR
Christian Pierre MOMON <christian.momon@devinsy.fr>
# Developer install
TODO
## Unit test environment
For unit tests, install the TestNG:
* https://marketplace.eclipse.org/content/testng-eclipse
* Eclipse menu > Help > Eclipse Marketplace > Find "TestNG" > TestNG for Eclipse: Install button
# LOGO
Author: Christian Pierre MOMON <christian.momon@devinsy.fr>
License: Creative Commons BY-ND-SA
Made with: Image from LibreOffice

View file

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Sat Feb 08 16:31:19 CET 2014 #Fri Aug 23 12:19:51 CEST 2024
build.number=11 build.number=1

View file

@ -1,3 +1,3 @@
product.name=sikevadb product.name=sikevadb
product.revision.major=0 product.revision.major=1
product.revision.minor=1 product.revision.minor=17

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,9 +1,20 @@
Description of used libraries: Description of used libraries:
- commons-codec: digest tools
- commons-lang: useful tools (StringUtils...) - Logs/
- hamcrest-core: required by junit - log4j log API
- hsqldb: SQL Database for unit test. - slf4j-api facade log API
- junit: unit tests API - slf4j-log4j12 adaptation layer between slf4j and log4j
- log4j: log API
- slf4j-api: facade log API - UnitTesting/
- slf4j-log4j12: adaptation layer between slf4j and log4j - hamcrest-core required by junit
- hsqldb SQL Database for unit test.
- junit unit tests API
- other:
- commons-codec digest tools
- commons-io
- commons-lang useful tools (StringUtils...)
- devinsy-strings
- devinsy-xml
- hsqldb
- mysql-jdbc

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/commons-io-2.16.1.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/commons-text-1.12.0.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/devinsy-xml-0.17.0.jar Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/hsqldb-2.7.3.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

12
log4j.properties Normal file
View file

@ -0,0 +1,12 @@
# Log configuration
# #################
# priority setting: DEBUG < INFO < WARN < ERROR
log4j.rootLogger = DEBUG, console
log4j.logger.fr.devinsy.util.xml = INFO
#--
log4j.appender.console = org.apache.log4j.ConsoleAppender
log4j.appender.console.layout = org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern = %d{ISO8601} - SikevaDB [%-5p] %34.34c.%25M - %m%n

View file

@ -1,164 +0,0 @@
/**
* Copyright (C) 2013, 2014 Christian Pierre MOMON, DEVINSY
*
* 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;
import org.apache.commons.codec.digest.DigestUtils;
import org.joda.time.DateTime;
/**
*
*
* @author Christian P. Momon
*/
public class Element {
public static final long NO_ID = -1;
private long id;
private DateTime creationDate;
private DateTime editionDate;
private DateTime archiveDate;
private String key;
private String subkey;
private long size;
private String digest;
private String value;
/**
*
* @param key
* @param value
*/
public Element() {
this.id = NO_ID;
}
/**
*
* @param key
* @param value
*/
public Element(final String key, final String subkey, final String value) {
update(value);
this.archiveDate = null;
this.key = key;
this.subkey = subkey;
}
/**
*
*/
public void archive() {
this.archiveDate = DateTime.now();
}
public DateTime getArchiveDate() {
return this.archiveDate;
}
public DateTime getCreationDate() {
return this.creationDate;
}
public String getDigest() {
return this.digest;
}
public DateTime getEditionDate() {
return this.editionDate;
}
public long getId() {
return this.id;
}
public String getKey() {
return this.key;
}
public long getSize() {
return this.size;
}
public String getSubkey() {
return this.subkey;
}
public String getValue() {
return this.value;
}
public void setArchiveDate(final DateTime date) {
this.archiveDate = date;
}
public void setCreationDate(final DateTime date) {
this.creationDate = date;
}
public void setDigest(final String digest) {
this.digest = digest;
}
public void setEditionDate(final DateTime date) {
this.editionDate = date;
}
public void setId(final long id) {
this.id = id;
}
public void setKey(final String key) {
this.key = key;
}
public void setSize(final long size) {
this.size = size;
}
public void setSubkey(final String subkey) {
this.subkey = subkey;
}
public void setValue(final String value) {
this.value = value;
}
public void update(final String value) {
//
setValue(value);
//
this.editionDate = DateTime.now();
//
if (value == null) {
this.size = 0;
this.digest = null;
} else {
this.size = this.value.length();
this.digest = DigestUtils.md5Hex(this.value);
}
//
if (this.creationDate == null) {
this.creationDate = this.editionDate;
}
}
}

View file

@ -1,366 +0,0 @@
/**
* Copyright (C) 2013, 2014 Christian Pierre MOMON, DEVINSY
*
* 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;
import java.io.File;
import org.joda.time.DateTime;
import fr.devinsy.util.StringList;
/**
*
*
* @author Christian P. Momon
*/
public class FileSikevaDB implements SikevaDB {
/**
*
* @param path
*/
public FileSikevaDB(final File path) {
}
/**
*
* @param path
*/
public FileSikevaDB(final String path) {
}
@Override
public void archive(final String key) throws Exception {
// TODO Auto-generated method stub
}
@Override
public void archive(final String key, final String subkey) throws Exception {
// TODO Auto-generated method stub
}
@Override
public void clearAllArchive() throws Exception {
// TODO Auto-generated method stub
}
@Override
public void clearArchive(final DateTime beforeDate) throws Exception {
// TODO Auto-generated method stub
}
@Override
public void clearArchive(final int maxDays) throws Exception {
// TODO Auto-generated method stub
}
@Override
public void clearDatabase() throws Exception {
// TODO Auto-generated method stub
}
@Override
public void close() {
// TODO Auto-generated method stub
}
@Override
public long countOfAllElements() {
// TODO Auto-generated method stub
return 0;
}
@Override
public long countOfAllElements(final String key) {
// TODO Auto-generated method stub
return 0;
}
@Override
public long countOfAllElements(final String key, final String subkey) {
// TODO Auto-generated method stub
return 0;
}
@Override
public long countOfArchivedElements() {
// TODO Auto-generated method stub
return 0;
}
@Override
public long countOfArchivedElements(final String key) {
// TODO Auto-generated method stub
return 0;
}
@Override
public long countOfArchivedElements(final String key, final String subkey) {
// TODO Auto-generated method stub
return 0;
}
@Override
public long countOfElements() {
// TODO Auto-generated method stub
return 0;
}
@Override
public long countOfElements(final String key) {
// TODO Auto-generated method stub
return 0;
}
@Override
public long countOfElements(final String key, final String subkey) {
// TODO Auto-generated method stub
return 0;
}
@Override
public Elements getAllElements() throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public Elements getAllElements(final String key) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public Elements getAllElements(final String key, final String subkey) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public StringList getAllKeys() throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public StringList getAllSubkeys(final String key) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public StringList getAllValues(final String key) {
// TODO Auto-generated method stub
return null;
}
@Override
public StringList getAllValues(final String key, final String subkey) {
// TODO Auto-generated method stub
return null;
}
@Override
public StringList getArchivedValues(final String key) {
// TODO Auto-generated method stub
return null;
}
@Override
public StringList getArchivedValues(final String key, final String subkey) {
// TODO Auto-generated method stub
return null;
}
@Override
public Element getElement(final String key) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public Element getElement(final String key, final String subkey) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public Elements getElements(final String key) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public Elements getElements(final String key, final String subkey) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public StringList getKeys() throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public StringList getSubkeys(final String key) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public String getValue(final String key) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public String getValue(final String key, final String subkey) {
// TODO Auto-generated method stub
return null;
}
@Override
public StringList getValues(final String key) {
// TODO Auto-generated method stub
return null;
}
@Override
public long memorySize() {
// TODO Auto-generated method stub
return 0;
}
@Override
public long memorySize(final String key) {
// TODO Auto-generated method stub
return 0;
}
@Override
public long memorySize(final String key, final String subkey) {
// TODO Auto-generated method stub
return 0;
}
@Override
public long memorySizeOfAll() throws Exception {
// TODO Auto-generated method stub
return 0;
}
@Override
public long memorySizeOfAll(final String key) throws Exception {
// TODO Auto-generated method stub
return 0;
}
@Override
public long memorySizeOfArchive() throws Exception {
// TODO Auto-generated method stub
return 0;
}
@Override
public long memorySizeOfArchive(final String key) throws Exception {
// TODO Auto-generated method stub
return 0;
}
@Override
public long memorySizeOfArchive(final String key, final String subkey) throws Exception {
// TODO Auto-generated method stub
return 0;
}
@Override
public void open() {
// TODO Auto-generated method stub
}
@Override
public void put(final Element element) throws Exception {
// TODO Auto-generated method stub
}
@Override
public void put(final String key, final String value) {
// TODO Auto-generated method stub
}
@Override
public void put(final String key, final String subkey, final String value) {
// TODO Auto-generated method stub
}
@Override
public void remove(final String key) throws Exception {
// TODO Auto-generated method stub
}
@Override
public void remove(final String key, final String subkey) throws Exception {
// TODO Auto-generated method stub
}
@Override
public void removeAll(final String key) throws Exception {
// TODO Auto-generated method stub
}
@Override
public void removeMany(final String key, final String... subkeys) throws Exception {
// TODO Auto-generated method stub
}
@Override
public void renameKey(final String oldKey, final String newKey) throws Exception {
// TODO Auto-generated method stub
}
@Override
public void replaceInValue(final String key, final String... tokens) throws Exception {
// TODO Auto-generated method stub
}
@Override
public void replaceInValues(final String key, final String... tokens) throws Exception {
// TODO Auto-generated method stub
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,109 +0,0 @@
/**
* Copyright (C) 2013, 2014 Christian Pierre MOMON, DEVINSY
*
* 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;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.net.URL;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.util.FileTools;
import fr.devinsy.util.StringList;
/**
*
*
* @author Christian P. Momon
*/
public class SQLSikevaDBTools {
private static final Logger logger = LoggerFactory.getLogger(SQLSikevaDBTools.class);
/**
*
* @param source
* @throws IOException
*/
public static StringList loadSQLScript(final URL source) throws IOException {
StringList result;
String script = FileTools.load(source);
result = splitSQLCommands(script);
//
return result;
}
/**
*
* @param source
* @throws IOException
*/
public static StringList splitSQLCommands(final String source) throws IOException {
StringList result;
//
result = new StringList();
//
if (source != null) {
//
BufferedReader in = new BufferedReader(new StringReader(source));
boolean ended = false;
StringList sql = new StringList();
while (!ended) {
String line = in.readLine();
if (line == null) {
ended = true;
} else {
if ((StringUtils.isNotBlank(line)) && (!line.startsWith("--"))) {
//
if (line.endsWith(";")) {
//
sql.append(line.substring(0, line.length() - 1));
//
result.add(sql.toString());
//
sql.clear();
} else {
//
sql.append(line).append(' ');
}
}
}
}
//
in.close();
}
//
return result;
}
}

View file

@ -1,139 +0,0 @@
/**
* Copyright (C) 2013, 2014 Christian Pierre MOMON, DEVINSY
*
* 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;
import org.joda.time.DateTime;
import fr.devinsy.util.StringList;
/**
* All elements = archived elements + elements.
*
*
*
* @author Christian P. Momon
*/
public interface SikevaDB {
public void archive(final String key) throws Exception;
public void archive(final String key, final String subkey) throws Exception;
public void clearAllArchive() throws Exception;
public void clearArchive(final DateTime beforeDate) throws Exception;
public void clearArchive(final int maxDays) throws Exception;
public void clearDatabase() throws Exception;
public void close() throws Exception;
public long countOfAllElements() throws Exception;
public long countOfAllElements(String key) throws Exception;
public long countOfAllElements(String key, String subkey) throws Exception;
public long countOfArchivedElements() throws Exception;
public long countOfArchivedElements(String key) throws Exception;
public long countOfArchivedElements(String key, String subkey) throws Exception;
public long countOfElements() throws Exception;
public long countOfElements(String key) throws Exception;
public long countOfElements(String key, String subkey) throws Exception;
public Elements getAllElements() throws Exception;
public Elements getAllElements(String key) throws Exception;
public Elements getAllElements(String key, String subkey) throws Exception;
public StringList getAllKeys() throws Exception;
public StringList getAllSubkeys(String key) throws Exception;
public StringList getAllValues(String key) throws Exception;
public StringList getAllValues(String key, String subkey) throws Exception;
public StringList getArchivedValues(String key) throws Exception;
public StringList getArchivedValues(String key, String subkey) throws Exception;
public Element getElement(String key) throws Exception;
public Element getElement(String key, String subkey) throws Exception;
public Elements getElements(String key) throws Exception;
public Elements getElements(String key, String subkey) throws Exception;
public StringList getKeys() throws Exception;
public StringList getSubkeys(String key) throws Exception;
public String getValue(String key) throws Exception;
public String getValue(String key, String subkey) throws Exception;
public StringList getValues(String key) throws Exception;
public long memorySize() throws Exception;
public long memorySize(String key) throws Exception;
public long memorySize(String key, String subkey) throws Exception;
public long memorySizeOfAll() throws Exception;
long memorySizeOfAll(String key) throws Exception;
public long memorySizeOfArchive() throws Exception;
long memorySizeOfArchive(String key) throws Exception;
long memorySizeOfArchive(String key, String subkey) throws Exception;
public void open() throws Exception;
public void put(Element element) throws Exception;
public void put(String key, String value) throws Exception;
public void put(String key, String subkey, String value) throws Exception;
public void remove(final String key) throws Exception;
public void remove(final String key, final String subkey) throws Exception;
public void removeAll(final String key) throws Exception;
public void removeMany(final String key, final String... subkeys) throws Exception;
public void renameKey(final String oldKey, final String newKey) throws Exception;
public void replaceInValue(final String key, final String... tokens) throws Exception;
public void replaceInValues(final String key, final String... tokens) throws Exception;
}

View file

@ -0,0 +1,84 @@
/*
* Copyright (C) 2013-2024 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;
import java.io.File;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.sikevadb.cli.SikevaDBCLI;
import fr.devinsy.sikevadb.demo.SikevaDBDemo;
/**
* The Class SikevaDBLauncher.
*/
public final class SikevaDBLauncher
{
private static Logger logger = LoggerFactory.getLogger(SikevaDBLauncher.class);
/**
* Instantiates a new SikevaDB launcher.
*/
private SikevaDBLauncher()
{
}
/**
* The main method.
*
* @param args
* the arguments
*/
public static void main(final String[] args)
{
// Configure log.
File loggerConfig = new File("log4j.properties");
if (loggerConfig.exists())
{
Configurator.initialize(null, loggerConfig.getAbsolutePath());
logger.info("Dedicated log configuration done.");
logger.info("Configuration file was found in [{}].", loggerConfig.getAbsoluteFile());
}
else
{
Configurator.initialize(new DefaultConfiguration());
logger.info("Basic log configuration done.");
logger.info("Configuration file was not found in [{}].", loggerConfig.getAbsoluteFile());
}
// Run.
if (args.length == 0)
{
// TODO
// SikevaGUI.run();
}
else if (ArrayUtils.contains(args, "-demo"))
{
SikevaDBDemo.run(args);
}
else
{
SikevaDBCLI.run(args);
}
}
}

View file

@ -1,283 +0,0 @@
/**
* Copyright (C) 2013, 2014 Christian Pierre MOMON, DEVINSY
*
* 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;
import java.io.File;
import java.io.OutputStream;
import javax.xml.stream.XMLStreamException;
import org.apache.commons.lang3.StringEscapeUtils;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.util.xml.XMLBadFormatException;
import fr.devinsy.util.xml.XMLReader;
import fr.devinsy.util.xml.XMLTag;
import fr.devinsy.util.xml.XMLTag.TagType;
import fr.devinsy.util.xml.XMLWriter;
import fr.devinsy.util.xml.XMLZipWriter;
/**
* This class represents a AccountManager File reader and writer.
*
* @author TIP
*/
public class XMLSikevaDB {
private static final Logger logger = LoggerFactory.getLogger(XMLSikevaDB.class);
/**
* Saves a net in a file.
*
* @param file
* Target.
* @param source
* Source.
*
*/
public static void export(final OutputStream out, final SikevaDB source) throws Exception {
//
String fileName = "sikevadb-" + DateTime.now().toString("yyyy-MM-dd-HH'h'mm'mn'ss's'") + ".xml.zip";
//
export(out, source, fileName);
}
/**
* Saves a net in a file.
*
* @param file
* Target.
* @param source
* Source.
*
*/
public static void export(final OutputStream out, final SikevaDB source, final String fileName) throws Exception {
if (out == null) {
throw new NullPointerException("out is null.");
} else if (source == null) {
throw new NullPointerException("source is null.");
} else if (fileName == null) {
export(out, source, fileName);
} else {
//
XMLZipWriter target = null;
try {
//
target = new XMLZipWriter(out, fileName, "Generated by SikevaDB.");
//
target.writeXMLHeader();
//
write(target, source);
} finally {
if (target != null) {
target.close();
}
}
}
}
/**
*
* @param file
* @return
*/
public static void importData(final SikevaDB database, final File file) throws Exception {
// XMLReader in = null;
// try {
// in = new XMLZipReader(file);
// result = readAccountManager(in);
// } finally {
// if (in != null) {
// in.close();
// }
// }
}
/**
*
* @param target
* @param in
* @throws XMLBadFormatException
* @throws XMLStreamException
* @throws Exception
*/
public static Element readElement(final XMLReader in) throws XMLStreamException, XMLBadFormatException {
Element result;
//
XMLTag tag = in.readStartTag("element");
//
{
//
long id = Long.parseLong(tag.attributes().getByLabel("id").getValue());
String key = StringEscapeUtils.unescapeXml(in.readContentTag("key").getContent());
String subkey = StringEscapeUtils.unescapeXml(in.readNullableContentTag("subkey").getContent());
String value = StringEscapeUtils.unescapeXml(in.readContentTag("value").getContent());
int size = Integer.parseInt(tag.attributes().getByLabel("size").getValue());
String digest = in.readContentTag("digest").getContent();
DateTime creationDate = DateTime.parse(in.readContentTag("creation_date").getContent());
DateTime editionDate = DateTime.parse(in.readContentTag("edition_date").getContent());
DateTime archiveDate;
String archiveDateValue = in.readNullableContentTag("archive_date").getContent();
if (archiveDateValue == null) {
archiveDate = null;
} else {
archiveDate = DateTime.parse(archiveDateValue);
}
//
result = new Element();
result.setId(id);
result.setKey(key);
result.setSubkey(subkey);
result.setValue(value);
result.setSize(size);
result.setDigest(digest);
result.setCreationDate(creationDate);
result.setEditionDate(editionDate);
result.setArchiveDate(archiveDate);
}
//
in.readEndTag("element");
//
return result;
}
/**
*
* @param target
* @param in
* @throws Exception
*/
public static void readElements(final SikevaDB target, final XMLReader in) throws Exception {
//
XMLTag list = in.readListTag("elements");
//
if (list.getType() != TagType.EMPTY) {
while (in.hasNextStartTag("element")) {
//
Element element = readElement(in);
//
target.put(element);
}
//
in.readEndTag("elements");
}
}
/**
*
* @param source
* @return
*/
public static void write(final XMLWriter out, final Element source) {
if (out == null) {
throw new NullPointerException("out is null.");
} else if (source == null) {
throw new NullPointerException("element is null.");
} else {
//
out.writeStartTag("element");
//
{
out.writeTag("id", String.valueOf(source.getId()));
out.writeTag("key", StringEscapeUtils.escapeXml(source.getKey()));
if (source.getSubkey() == null) {
out.writeTag("subkey", null);
} else {
out.writeTag("subkey", StringEscapeUtils.escapeXml(source.getSubkey()));
}
out.writeTag("value", StringEscapeUtils.escapeXml(source.getValue()));
out.writeTag("size", String.valueOf(source.getSize()));
out.writeTag("digest", source.getDigest());
out.writeTag("creation_date", source.getCreationDate().toString());
out.writeTag("edition_date", source.getEditionDate().toString());
if (source.getArchiveDate() == null) {
out.writeTag("archive_date", null);
} else {
out.writeTag("archive_date", source.getArchiveDate().toString());
}
}
//
out.writeEndTag("element");
}
}
/**
*
* @param out
* @param source
* @throws Exception
*/
public static void write(final XMLWriter out, final SikevaDB source) throws Exception {
if (out == null) {
//
throw new NullPointerException("out is null.");
} else if (source == null) {
//
out.writeEmptyTag("elements");
} else {
//
out.writeStartTag("elements");
for (String key : source.getAllKeys()) {
//
Elements elements = source.getAllElements(key);
for (Element element : elements) {
write(out, element);
}
//
for (String subkey : source.getSubkeys(key)) {
Elements subElements = source.getAllElements(key, subkey);
for (Element subElement : subElements) {
write(out, subElement);
}
}
}
out.writeEndTag("elements");
}
}
}

View file

@ -0,0 +1,168 @@
/*
* Copyright (C) 2013-2024 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.cli;
import java.io.File;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.sikevadb.core.SikevaDBException;
import fr.devinsy.strings.StringList;
import utils.BuildInformation;
/**
* The Class <code>SikevaDBCLI</code> manages a Command Line Interface for
* SikevaDB.
*
*/
public final class SikevaDBCLI
{
private static Logger logger = LoggerFactory.getLogger(SikevaDBCLI.class);
/**
* Instantiates a new SikevaDBCLI.
*/
private SikevaDBCLI()
{
}
/**
* This method displays the CLI help.
*
*/
public static void help()
{
StringList message = new StringList();
message.append("SikevaDB CLI version ").appendln(BuildInformation.instance().version());
message.appendln("Usage:");
message.appendln(" sikevadbcli [ -h | -help | --help ]");
message.appendln(" sikevadbcli get key");
message.appendln(" sikevadbcli get key subkey");
System.out.println(message.toString());
}
/**
* The main method.
*
* @param args
* the arguments
*/
public static void main(final String[] args)
{
// Configure log.
File loggerConfig = new File("log4j.properties");
if (loggerConfig.exists())
{
Configurator.initialize(null, loggerConfig.getAbsolutePath());
logger.info("Dedicated log configuration done.");
logger.info("Configuration file was found in [{}].", loggerConfig.getAbsoluteFile());
}
else
{
Configurator.initialize(new DefaultConfiguration());
logger.info("Basic log configuration done.");
logger.info("Configuration file was not found in [{}].", loggerConfig.getAbsoluteFile());
}
// Run.
SikevaDBCLI.run(args);
}
/**
*
* This method launch CLI.
*
* @param args
* necessary arguments
*/
public static void run(final String[] args)
{
try
{
// Set default catch.
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()
{
@Override
public void uncaughtException(final Thread thread, final Throwable exception)
{
String message;
if (exception instanceof OutOfMemoryError)
{
message = "Java ran out of memory!\n\n";
}
else
{
message = String.format("An error occured: %1s(%2s)", exception.getClass(), exception.getMessage());
}
logger.error("uncaughtException ", exception);
logger.error(message);
logger.info("Oups, an unexpected error occured. Please try again.");
}
});
// This part implements an automate.
int parameterCount = args.length;
if (parameterCount == 0)
{
help();
}
else if (StringUtils.equals(args[0], "-h") || StringUtils.equals(args[0], "-help") || StringUtils.equals(args[0], "--help"))
{
help();
}
else if (StringUtils.equals(args[0], "get"))
{
switch (parameterCount)
{
case 2:
{
}
break;
case 3:
{
}
break;
default:
throw new SikevaDBException("Bad parameter count.");
}
}
else
{
System.out.println("Bad usage detected.");
help();
}
}
catch (SikevaDBException exception)
{
System.err.println("SikevaDBException = " + exception.getMessage());
logger.error(exception.getMessage(), exception);
help();
}
}
}

View file

@ -0,0 +1,72 @@
/*
* Copyright (C) 2013-2017 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.cli;
import fr.devinsy.sikevadb.core.SikevaDBException;
/**
* The Class SikevaDBCLIException.
*/
public class SikevaDBCLIException extends SikevaDBException
{
private static final long serialVersionUID = 2986878456227891377L;
/**
* Instantiates a new SikevaDBCLI exception.
*/
public SikevaDBCLIException()
{
super();
}
/**
* Instantiates a new SikevaDBCLI exception.
*
* @param message
* the message
*/
public SikevaDBCLIException(final String message)
{
super(message);
}
/**
* Instantiates a new SikevaDBCLI exception.
*
* @param message
* the message
* @param cause
* the cause
*/
public SikevaDBCLIException(final String message, final Throwable cause)
{
super(message, cause);
}
/**
* Instantiates a new SikevaDBCLI exception.
*
* @param cause
* the cause
*/
public SikevaDBCLIException(final Throwable cause)
{
super(cause);
}
}

View file

@ -0,0 +1,78 @@
/*
* Copyright (C) 2013-2024 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;
/**
* The Interface Archiver.
*/
public interface Archiver
{
public enum Status
{
ACTIVATED,
SUSPENDED
}
/**
* Activate.
*/
void activate();
/**
* Archive.
*
* @param element
* the element
* @throws SikevaDBException
* the sikeva DB exception
*/
void archive(Element element) throws SikevaDBException;
/**
* Clear.
*
* @throws SikevaDBException
* the sikeva DB exception
*/
void clear() throws SikevaDBException;
/**
* Close.
*/
void close();
/**
* Checks if is activated.
*
* @return true, if is activated
*/
boolean isActivated();
/**
* Checks if is suspended.
*
* @return true, if is suspended
*/
boolean isSuspended();
/**
* Suspend.
*/
void suspend();
}

View file

@ -0,0 +1,70 @@
/*
* Copyright (C) 2018-2024 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;
/**
* The Class ClosedDatabaseException.
*/
public class ClosedDatabaseException extends SikevaDBException
{
private static final long serialVersionUID = 8364599416669077052L;
/**
* Instantiates a new closed database exception.
*/
public ClosedDatabaseException()
{
super("Invalid database status for this operation: closed.");
}
/**
* Instantiates a new closed database exception.
*
* @param message
* the message
*/
public ClosedDatabaseException(final String message)
{
super(message);
}
/**
* Instantiates a new closed database exception.
*
* @param message
* the message
* @param cause
* the cause
*/
public ClosedDatabaseException(final String message, final Throwable cause)
{
super(message, cause);
}
/**
* Instantiates a new closed database exception.
*
* @param cause
* the cause
*/
public ClosedDatabaseException(final Throwable cause)
{
super(cause);
}
}

View file

@ -0,0 +1,300 @@
/*
* Copyright (C) 2013-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;
import java.time.LocalDateTime;
import org.apache.commons.codec.digest.DigestUtils;
/**
* The Class Element.
*
* @author Christian Pierre MOMON
*/
public class Element
{
public static final long NO_ID = -1;
private long id;
private LocalDateTime creationDate;
private LocalDateTime editionDate;
/* archiveDate field is reserved for journalizer. */
private LocalDateTime archiveDate;
private String key;
private String subkey;
private long size;
private String digest;
private String value;
/**
* Instantiates a new element.
*/
public Element()
{
this.id = NO_ID;
}
/**
* Instantiates a new element.
*
* @param key
* the key
* @param subkey
* the subkey
* @param value
* the value
*/
public Element(final String key, final String subkey, final String value)
{
update(value);
this.archiveDate = null;
this.key = key;
this.subkey = subkey;
}
/**
* Archive.
*/
public void archive()
{
this.archiveDate = LocalDateTime.now();
}
/**
* Gets the archive date.
*
* @return the archive date
*/
public LocalDateTime getArchiveDate()
{
return this.archiveDate;
}
/**
* Gets the creation date.
*
* @return the creation date
*/
public LocalDateTime getCreationDate()
{
return this.creationDate;
}
/**
* Gets the digest.
*
* @return the digest
*/
public String getDigest()
{
return this.digest;
}
/**
* Gets the edition date.
*
* @return the edition date
*/
public LocalDateTime getEditionDate()
{
return this.editionDate;
}
/**
* Gets the id.
*
* @return the id
*/
public long getId()
{
return this.id;
}
/**
* Gets the key.
*
* @return the key
*/
public String getKey()
{
return this.key;
}
/**
* Gets the size.
*
* @return the size
*/
public long getSize()
{
return this.size;
}
/**
* Gets the subkey.
*
* @return the subkey
*/
public String getSubkey()
{
return this.subkey;
}
/**
* Gets the value.
*
* @return the value
*/
public String getValue()
{
return this.value;
}
/**
* Sets the archive date.
*
* @param date
* the new archive date
*/
public void setArchiveDate(final LocalDateTime date)
{
this.archiveDate = date;
}
/**
* Sets the creation date.
*
* @param date
* the new creation date
*/
public void setCreationDate(final LocalDateTime date)
{
this.creationDate = date;
}
/**
* Sets the digest.
*
* @param digest
* the new digest
*/
public void setDigest(final String digest)
{
this.digest = digest;
}
/**
* Sets the edition date.
*
* @param date
* the new edition date
*/
public void setEditionDate(final LocalDateTime date)
{
this.editionDate = date;
}
/**
* Sets the id.
*
* @param id
* the new id
*/
public void setId(final long id)
{
this.id = id;
}
/**
* Sets the key.
*
* @param key
* the new key
*/
public void setKey(final String key)
{
this.key = key;
}
/**
* Sets the size.
*
* @param size
* the new size
*/
public void setSize(final long size)
{
this.size = size;
}
/**
* Sets the subkey.
*
* @param subkey
* the new subkey
*/
public void setSubkey(final String subkey)
{
this.subkey = subkey;
}
/**
* Sets the value.
*
* @param value
* the new value
*/
public void setValue(final String value)
{
this.value = value;
}
/**
* Update.
*
* @param value
* the value
*/
public void update(final String value)
{
//
setValue(value);
//
this.editionDate = LocalDateTime.now();
//
if (value == null)
{
this.size = 0;
this.digest = DigestUtils.md5Hex("");
}
else
{
this.size = this.value.length();
this.digest = DigestUtils.md5Hex(this.value);
}
//
if (this.creationDate == null)
{
this.creationDate = this.editionDate;
}
}
}

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2013, 2014 Christian Pierre MOMON, DEVINSY * Copyright (C) 2013-2017 Christian Pierre MOMON <christian.momon@devinsy.fr>
* *
* This file is part of SikevaDB, simple key value database. * This file is part of SikevaDB, simple key value database.
* *
@ -16,31 +16,35 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with SikevaDB. If not, see <http://www.gnu.org/licenses/>. * along with SikevaDB. If not, see <http://www.gnu.org/licenses/>.
*/ */
package fr.devinsy.sikevadb; package fr.devinsy.sikevadb.core;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
* The Class Elements.
* *
* * @author Christian Pierre MOMON (christian.momon@devinsy.fr)
* @author Christian P. Momon
*/ */
public class Elements extends ArrayList<Element> { public class Elements extends ArrayList<Element>
{
private static final long serialVersionUID = 6298920093179395791L; private static final long serialVersionUID = 6298920093179395791L;
/** /**
* * Instantiates a new elements.
*/ */
public Elements() { public Elements()
{
super(); super();
} }
/** /**
* Instantiates a new elements.
* *
* @param initialCapacity
* the initial capacity
*/ */
public Elements(final int initialCapacity) { public Elements(final int initialCapacity)
{
super(initialCapacity); super(initialCapacity);
} }
} }

View file

@ -0,0 +1,70 @@
/*
* Copyright (C) 2018-2024 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;
/**
* The Class OpenedDatabaseException.
*/
public class OpenedDatabaseException extends SikevaDBException
{
private static final long serialVersionUID = 8364599416669077052L;
/**
* Instantiates a new opened database exception.
*/
public OpenedDatabaseException()
{
super("Invalid database status for this operation: opened.");
}
/**
* Instantiates a new opened database exception.
*
* @param message
* the message
*/
public OpenedDatabaseException(final String message)
{
super(message);
}
/**
* Instantiates a new opened database exception.
*
* @param message
* the message
* @param cause
* the cause
*/
public OpenedDatabaseException(final String message, final Throwable cause)
{
super(message, cause);
}
/**
* Instantiates a new opened database exception.
*
* @param cause
* the cause
*/
public OpenedDatabaseException(final Throwable cause)
{
super(cause);
}
}

View file

@ -0,0 +1,492 @@
/*
* Copyright (C) 2013-2024 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;
import fr.devinsy.strings.StringList;
/**
* The Interface SikevaDB.
*
* @author Christian Pierre MOMON
*/
public interface SikevaDB
{
/**
* Archiver.
*
* @return the archiver
* @throws SikevaDBException
* the sikeva DB exception
*/
public Archiver archiver() throws SikevaDBException;
/**
* 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 sub key.
*
* @param key
* the key
* @param subkey
* the sub key
* @return the long
* @throws SikevaDBException
* the SikevaDB exception
*/
public long countOfElements(String key, long subkey) throws SikevaDBException;
/**
* Count of elements by key and sub key.
*
* @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;
/**
* Delete an database element with its key.
*
* @param key
* the key
* @throws SikevaDBException
* the SikevaDB exception
*/
void delete(final String key) throws SikevaDBException;
/**
* Delete an database element with its key and subkey.
*
* @param key
* the key
* @param subkey
* the sub key
* @throws SikevaDBException
* the SikevaDB exception
*/
void delete(final String key, final long subkey) throws SikevaDBException;
/**
* Delete an database element with its key and subkey.
*
* @param key
* the key
* @param subkey
* the sub key
* @throws SikevaDBException
* the SikevaDB exception
*/
void delete(final String key, final String subkey) throws SikevaDBException;
/**
* Delete many database elements from key and sub keys.
*
* @param key
* the key
* @param subkeys
* the subkeys
* @throws SikevaDBException
* the SikevaDB exception
*/
void deleteMany(final String key, final String... subkeys) throws SikevaDBException;
/**
* Destroy.
*
* @throws SikevaDBException
* the sikeva DB exception
*/
public void destroy() throws SikevaDBException;
/**
* Checks if is created.
*
* @return true, if is created
* @throws SikevaDBException
* the SikevaDB exception
*/
public boolean exists() 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, long subkey) 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;
/**
* 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 all the top keys.
*
* @return the keys
* @throws SikevaDBException
* the SikevaDB exception
*/
public StringList getTopKeys() 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, long subkey) 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.
*
* @param key
* the key
* @return the values
* @throws SikevaDBException
* the sikeva DB exception
*/
public StringList getValues(String key) throws SikevaDBException;
/**
* Checks if is archive activated.
*
* @return true, if is archive activated
*/
boolean isArchiveActivated();
/**
* Checks if is archive suspended.
*
* @return true, if is archive suspended
*/
boolean isArchiveSuspended();
/**
* Checks if is closed.
*
* @return true, if is closed
*/
public boolean isClosed();
/**
* 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, long subkey) 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 and a sub key in current opened database.
*
* @param key
* the key
* @param subkey
* the sub key
* @param value
* the value
* @throws SikevaDBException
* the SikevaDB exception
*/
void put(String key, long subkey, String value) 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 sub key
* @param value
* the value
* @throws SikevaDBException
* the SikevaDB exception
*/
void put(String key, String subkey, String value) 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 long oldSubKey, final long newSubKey) 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;
}

View file

@ -0,0 +1,72 @@
/*
* Copyright (C) 2013-2017 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;
/**
* The Class SikevaDBException.
*
* @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/
public class SikevaDBException extends Exception
{
private static final long serialVersionUID = 8323299610751708972L;
/**
* Instantiates a new SikevaDB exception.
*/
public SikevaDBException()
{
super();
}
/**
* Instantiates a new SikevaDB exception.
*
* @param message
* the message
*/
public SikevaDBException(final String message)
{
super(message);
}
/**
* Instantiates a new SikevaDB exception.
*
* @param message
* the message
* @param cause
* the cause
*/
public SikevaDBException(final String message, final Throwable cause)
{
super(message, cause);
}
/**
* Instantiates a new SikevaDB exception.
*
* @param cause
* the cause
*/
public SikevaDBException(final Throwable cause)
{
super(cause);
}
}

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2013, 2014 Christian Pierre MOMON, DEVINSY * Copyright (C) 2013-2017 Christian Pierre MOMON <christian.momon@devinsy.fr>
* *
* This file is part of SikevaDB, simple key value database. * This file is part of SikevaDB, simple key value database.
* *
@ -16,36 +16,54 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with SikevaDB. If not, see <http://www.gnu.org/licenses/>. * along with SikevaDB. If not, see <http://www.gnu.org/licenses/>.
*/ */
package fr.devinsy.sikevadb; package fr.devinsy.sikevadb.core;
import java.io.File; import java.io.File;
import fr.devinsy.sikevadb.filetree.FileTreeSikevaDB;
import fr.devinsy.sikevadb.sql.SQLSikevaDB;
/** /**
* A factory for creating SikevaDB objects.
* *
* * @author Christian Pierre MOMON
* @author Christian P. Momon
*/ */
public class SikevaDBFactory { public class SikevaDBFactory
{
/** /**
* Gets a SikevaDB instance from its database home directory.
* *
* @param path * @param path
* @return * the path of the database home directory
*
* @return a SikevaDB instance
*
* @throws SikevaDBException
* the SikevaDB exception
*/ */
public static SikevaDB get(final File path) { public static SikevaDB get(final File path) throws SikevaDBException
{
SikevaDB result; SikevaDB result;
result = new FileSikevaDB(path); result = new FileTreeSikevaDB(path, null, null);
// //
return result; return result;
} }
/** /**
* Gets a SikevaDB instance from a context.
* *
* @param path * @param contextName
* @return * the context name
*
* @return a SikevaDB instance
*
* @throws SikevaDBException
* the SikevaDB exception
*/ */
public static SikevaDB get(final String contextName) { public static SikevaDB get(final String contextName)
{
SikevaDB result; SikevaDB result;
result = new SQLSikevaDB(contextName); result = new SQLSikevaDB(contextName);
@ -55,14 +73,21 @@ public class SikevaDBFactory {
} }
/** /**
* Gets a SikevaDB instance from dabase parameters.
* *
* @param driverClassName * @param driverClassName
* the driver class name
* @param url * @param url
* the url
* @param login * @param login
* the login
* @param password * @param password
* @return * the password
*
* @return the SikevaDB
*/ */
public static SikevaDB get(final String driverClassName, final String url, final String login, final String password) { public static SikevaDB get(final String driverClassName, final String url, final String login, final String password)
{
SikevaDB result; SikevaDB result;
result = new SQLSikevaDB(driverClassName, url, login, password); result = new SQLSikevaDB(driverClassName, url, login, password);

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2013, 2014 Christian Pierre MOMON, DEVINSY * Copyright (C) 2013-2017 Christian Pierre MOMON <christian.momon@devinsy.fr>
* *
* This file is part of SikevaDB, simple key value database. * This file is part of SikevaDB, simple key value database.
* *
@ -16,17 +16,24 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with SikevaDB. If not, see <http://www.gnu.org/licenses/>. * along with SikevaDB. If not, see <http://www.gnu.org/licenses/>.
*/ */
package fr.devinsy.sikevadb; package fr.devinsy.sikevadb.core;
import java.util.Date; import java.util.Date;
/** /**
* The Class SikevaDBUtils.
* *
* * @author Christian Pierre MOMON
* @author Christian P. Momon
*/ */
public class SikevaDBUtils { public class SikevaDBUtils
public static long now() { {
/**
* Gets the current time in long format.
*
* @return the long
*/
public static long now()
{
return new Date().getTime(); return new Date().getTime();
} }
} }

View file

@ -0,0 +1,381 @@
/*
* Copyright (C) 2013-2024 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;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import javax.xml.stream.XMLStreamException;
import org.apache.commons.lang3.StringEscapeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.xml.XMLBadFormatException;
import fr.devinsy.xml.XMLReader;
import fr.devinsy.xml.XMLTag;
import fr.devinsy.xml.XMLTag.TagType;
import fr.devinsy.xml.XMLWriter;
import fr.devinsy.xml.XMLZipWriter;
/**
* The Class XMLSikevaDB represents a XML persister.
*/
public class XMLSikevaDB
{
private static final Logger logger = LoggerFactory.getLogger(XMLSikevaDB.class);
/**
* Export.
*
* @param out
* the out
* @param source
* the source
* @throws SikevaDBException
* the sikeva DB exception
* @throws FileNotFoundException
* the file not found exception
*/
public static void export(final File out, final SikevaDB source) throws SikevaDBException, FileNotFoundException
{
export(new FileOutputStream(out), source, out.getName());
}
/**
* Export.
*
* @param out
* the out
* @param source
* the source
* @throws SikevaDBException
* the SikevaDB exception
*/
public static void export(final OutputStream out, final SikevaDB source) throws SikevaDBException
{
//
String fileName = "sikevadb-" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd-HH'h'mm'mn'ss's'")) + ".xml.zip";
//
export(out, source, fileName);
}
/**
* Export.
*
* @param out
* the out
* @param source
* the source
* @param fileName
* the file name
* @throws SikevaDBException
* the SikevaDB exception
*/
public static void export(final OutputStream out, final SikevaDB source, final String fileName) throws SikevaDBException
{
if (out == null)
{
throw new IllegalArgumentException("out is null.");
}
else if (source == null)
{
throw new IllegalArgumentException("source is null.");
}
else if (fileName == null)
{
export(out, source, fileName);
}
else
{
XMLZipWriter target = null;
try
{
//
target = new XMLZipWriter(out, fileName, "Generated by SikevaDB.");
//
target.writeXMLHeader();
//
write(target, source);
}
catch (IOException exception)
{
throw new SikevaDBException("Problem writing element.", exception);
}
finally
{
if (target != null)
{
try
{
target.close();
}
catch (IOException exception)
{
logger.warn("Problem closing stream.", exception);
}
}
}
}
}
/**
* Import data.
*
* @param database
* the database
* @param file
* the file
*/
public static void importData(final SikevaDB database, final File file)
{
// TODO
// XMLReader in = null;
// try {
// in = new XMLZipReader(file);
// result = readAccountManager(in);
// } finally {
// if (in != null) {
// in.close();
// }
// }
}
/**
* Read element.
*
* @param in
* the in
* @return the element
* @throws SikevaDBException
* the sikeva DB exception
*/
public static Element readElement(final XMLReader in) throws SikevaDBException
{
Element result;
try
{
//
XMLTag tag = in.readStartTag("element");
//
{
//
long id = Long.parseLong(tag.attributes().getByLabel("id").getValue());
String key = StringEscapeUtils.unescapeXml(in.readContentTag("key").getContent());
String subkey = StringEscapeUtils.unescapeXml(in.readNullableContentTag("subkey").getContent());
String value = StringEscapeUtils.unescapeXml(in.readContentTag("value").getContent());
int size = Integer.parseInt(tag.attributes().getByLabel("size").getValue());
String digest = in.readContentTag("digest").getContent();
LocalDateTime creationDate = LocalDateTime.parse(in.readContentTag("creation_date").getContent());
LocalDateTime editionDate = LocalDateTime.parse(in.readContentTag("edition_date").getContent());
LocalDateTime archiveDate;
String archiveDateValue = in.readNullableContentTag("archive_date").getContent();
if (archiveDateValue == null)
{
archiveDate = null;
}
else
{
archiveDate = LocalDateTime.parse(archiveDateValue);
}
//
result = new Element();
result.setId(id);
result.setKey(key);
result.setSubkey(subkey);
result.setValue(value);
result.setSize(size);
result.setDigest(digest);
result.setCreationDate(creationDate);
result.setEditionDate(editionDate);
result.setArchiveDate(archiveDate);
}
//
in.readEndTag("element");
}
catch (XMLStreamException exception)
{
throw new SikevaDBException("Problem reading element.", exception);
}
catch (XMLBadFormatException exception)
{
throw new SikevaDBException("Problem reading element.", exception);
}
//
return result;
}
/**
* Read elements.
*
* @param target
* the target
* @param in
* the in
* @throws SikevaDBException
* the sikeva DB exception
*/
public static void readElements(final SikevaDB target, final XMLReader in) throws SikevaDBException
{
try
{
XMLTag list = in.readListTag("elements");
//
if (list.getType() != TagType.EMPTY)
{
//
while (in.hasNextStartTag("element"))
{
Element element = readElement(in);
target.put(element);
}
//
in.readEndTag("elements");
}
}
catch (XMLStreamException exception)
{
throw new SikevaDBException("Problem reading element.", exception);
}
catch (XMLBadFormatException exception)
{
throw new SikevaDBException("Problem reading element.", exception);
}
}
/**
* Write.
*
* @param out
* the out
* @param source
* the source
*/
public static void write(final XMLWriter out, final Element source)
{
if (out == null)
{
throw new IllegalArgumentException("Parameter out is null.");
}
else if (source == null)
{
throw new IllegalArgumentException("Parameter element is null.");
}
else
{
//
out.writeStartTag("element");
//
{
out.writeTag("id", String.valueOf(source.getId()));
out.writeTag("key", StringEscapeUtils.escapeXml(source.getKey()));
if (source.getSubkey() == null)
{
out.writeTag("subkey", null);
}
else
{
out.writeTag("subkey", StringEscapeUtils.escapeXml(source.getSubkey()));
}
out.writeTag("value", StringEscapeUtils.escapeXml(source.getValue()));
out.writeTag("size", String.valueOf(source.getSize()));
out.writeTag("digest", source.getDigest());
out.writeTag("creation_date", source.getCreationDate().toString());
out.writeTag("edition_date", source.getEditionDate().toString());
if (source.getArchiveDate() == null)
{
out.writeTag("archive_date", null);
}
else
{
out.writeTag("archive_date", source.getArchiveDate().toString());
}
}
//
out.writeEndTag("element");
}
}
/**
* Write in an XML writer the elements of a database, sorting by keys and
* sub keys.
*
* @param out
* the out
* @param source
* the source
* @throws SikevaDBException
* the sikeva DB exception
*/
public static void write(final XMLWriter out, final SikevaDB source) throws SikevaDBException
{
if (out == null)
{
throw new IllegalArgumentException("out is null.");
}
else if (source == null)
{
out.writeEmptyTag("elements");
}
else
{
out.writeStartTag("elements");
for (String topkey : source.getTopKeys().sort())
{
//
Element topElement = source.getElement(topkey);
if (topElement != null)
{
write(out, topElement);
}
//
for (String subkey : source.getSubkeys(topkey).sort())
{
Element subElement = source.getElement(topkey, subkey);
write(out, subElement);
}
}
out.writeEndTag("elements");
}
}
}

View file

@ -0,0 +1,263 @@
/*
* Copyright (C) 2013-2024 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.demo;
import java.io.File;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.sikevadb.core.SikevaDB;
import fr.devinsy.sikevadb.core.SikevaDBException;
import fr.devinsy.sikevadb.core.SikevaDBFactory;
import fr.devinsy.strings.StringList;
import utils.BuildInformation;
/**
* The Class SikevaDBDemo is a demo for SikevaDB.
*/
public final class SikevaDBDemo
{
private static Logger logger = LoggerFactory.getLogger(SikevaDBDemo.class);
/**
* SikevaDBDemo class has to be not instanciated.
*/
private SikevaDBDemo()
{
}
/**
* Demo.
*
* @throws SikevaDBException
* the SikevaDB exception
*/
public static void demo() throws SikevaDBException
{
SikevaDB database = null;
try
{
//
File homeDirectory = new File("/tmp/footest");
database = SikevaDBFactory.get(homeDirectory);
if (database.exists())
{
database.destroy();
}
database.create();
database.open();
// Single key value.
{
database.put("alpha", "alpha value");
database.put("bravo", "bravo value");
database.put("charlie", "charlie value");
String value = database.getValue("alpha");
if (StringUtils.equals(value, "alpha value"))
{
System.out.println("alpha is correctly stored.");
}
else
{
System.out.println("alpha is NOT correctly stored.");
}
//
database.delete("alpha");
if (database.getValue("alpha") == null)
{
System.out.println("alpha is correctly deleted.");
}
else
{
System.out.println("alpha is NOT correctly deleted.");
}
}
// Double key values.
{
for (int index = 0; index < 10; index++)
{
database.put("victor", index, "victor" + index);
}
String value = database.getValue("victor", 7);
if (StringUtils.equals(value, "victor7"))
{
System.out.println("victor is correctly stored.");
}
else
{
System.out.println("victor is NOT correctly stored.");
}
//
database.delete("victor", 5);
if (database.getValue("victor", 5) == null)
{
System.out.println("(victor, 5) is correctly deleted.");
}
else
{
System.out.println("(victor, 5) is NOT correctly deleted.");
}
}
//
System.out.println(String.format("Database values:\t %d elements", database.countOfElements()));
System.out.println(String.format("Database memory:\t %d bytes", database.memorySize()));
//
database.close();
}
finally
{
if ((database != null) && (database.exists()))
{
database.destroy();
}
}
}
/**
* This method displays the CLI help.
*
*/
public static void help()
{
StringList message = new StringList();
message.append("SikevaDB Demo version ").appendln(BuildInformation.instance().version());
message.appendln("Usage:");
message.appendln(" sikevadbdemo [ -h | -help | --help ]");
message.appendln(" sikevadb -demo [ -h | -help | --help ]");
System.out.println(message.toString());
}
/**
* The main method.
*
* @param args
* the arguments
*/
public static void main(final String[] args)
{
// Configure log.
File loggerConfig = new File("log4j.properties");
if (loggerConfig.exists())
{
Configurator.initialize(null, loggerConfig.getAbsolutePath());
logger.info("Dedicated log configuration done.");
logger.info("Configuration file was found in [{}].", loggerConfig.getAbsoluteFile());
}
else
{
Configurator.initialize(new DefaultConfiguration());
logger.info("Basic log configuration done.");
logger.info("Configuration file was not found in [{}].", loggerConfig.getAbsoluteFile());
}
// Run.
SikevaDBDemo.run(args);
}
/**
*
* This method launch CLI.
*
* @param args
* necessary arguments
*/
public static void run(final String[] args)
{
try
{
// Set default catch.
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()
{
@Override
public void uncaughtException(final Thread thread, final Throwable exception)
{
String message;
if (exception instanceof OutOfMemoryError)
{
message = "Java ran out of memory!\n\n";
}
else
{
message = String.format("An error occured: %1s(%2s)", exception.getClass(), exception.getMessage());
}
logger.error("uncaughtException ", exception);
logger.error(message);
logger.info("Oups, an unexpected error occured. Please try again.");
}
});
// This part implements an automate.
int parameterCount = args.length;
if (parameterCount == 0)
{
demo();
}
else if (StringUtils.equals(args[0], "-h") || StringUtils.equals(args[0], "-help") || StringUtils.equals(args[0], "--help"))
{
help();
}
else if (StringUtils.equals(args[0], "get"))
{
switch (parameterCount)
{
case 2:
{
}
break;
case 3:
{
}
break;
default:
throw new SikevaDBException("Bad parameter count.");
}
}
else
{
System.out.println("Bad usage detected.");
help();
}
}
catch (SikevaDBException exception)
{
System.err.println("SibaException = " + exception.getMessage());
logger.error(exception.getMessage(), exception);
help();
}
}
}

View file

@ -0,0 +1,72 @@
/*
* Copyright (C) 2013-2017 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.demo;
import fr.devinsy.sikevadb.core.SikevaDBException;
/**
* The Class SikevaDBDemoException.
*/
public class SikevaDBDemoException extends SikevaDBException
{
private static final long serialVersionUID = 1162267847144476595L;
/**
* Instantiates a new SikevaDB demo exception.
*/
public SikevaDBDemoException()
{
super();
}
/**
* Instantiates a new SikevaDB demo exception.
*
* @param message
* the message
*/
public SikevaDBDemoException(final String message)
{
super(message);
}
/**
* Instantiates a new SikevaDB demo exception.
*
* @param message
* the message
* @param cause
* the cause
*/
public SikevaDBDemoException(final String message, final Throwable cause)
{
super(message, cause);
}
/**
* Instantiates a new SikevaDB demo exception.
*
* @param cause
* the cause
*/
public SikevaDBDemoException(final Throwable cause)
{
super(cause);
}
}

View file

@ -0,0 +1,165 @@
/*
* Copyright (C) 2013-2017 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.filetree;
import java.io.File;
import fr.devinsy.sikevadb.core.Archiver;
import fr.devinsy.sikevadb.core.Element;
import fr.devinsy.sikevadb.core.SikevaDB;
import fr.devinsy.sikevadb.core.SikevaDBException;
/**
* The Class FileTreeArchiver.
*
* @author Christian Pierre MOMON
*/
public class FileTreeArchiver implements Archiver
{
private static final String ARCHIVE_PATH = "archive";
private Status status;
private File archiveDirectory;
private SikevaDB database;
/**
* Instantiates a new file tree archiver.
*
* @param source
* the source
*
* @throws SikevaDBException
* the SikevaDB exception
*/
public FileTreeArchiver(final FileTreeSikevaDB source) throws SikevaDBException
{
if (source == null)
{
throw new IllegalArgumentException("Null parameter.");
}
else
{
this.status = Status.ACTIVATED;
this.archiveDirectory = new File(source.getFileTreeDirectory(), ARCHIVE_PATH);
if (this.archiveDirectory.exists())
{
if (!this.archiveDirectory.isDirectory())
{
throw new SikevaDBException("Archive directory unavailable.");
}
}
else
{
this.archiveDirectory.mkdir();
}
this.database = source;
}
}
/* (non-Javadoc)
* @see fr.devinsy.sikevadb.core.Archiver#activate()
*/
@Override
public void activate()
{
this.status = Status.ACTIVATED;
}
/* (non-Javadoc)
* @see fr.devinsy.sikevadb.core.Archiver#archive(fr.devinsy.sikevadb.core.Element)
*/
@Override
public void archive(final Element element) throws SikevaDBException
{
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see fr.devinsy.sikevadb.core.Archiver#clear()
*/
@Override
public void clear() throws SikevaDBException
{
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see fr.devinsy.sikevadb.core.Archiver#close()
*/
@Override
public void close()
{
// TODO
}
/**
* Gets the path.
*
* @return the path
*/
public File getPath()
{
return this.archiveDirectory;
}
/* (non-Javadoc)
* @see fr.devinsy.sikevadb.core.Archiver#isActivated()
*/
@Override
public boolean isActivated()
{
boolean result;
if (this.status == Status.ACTIVATED)
{
result = true;
}
else
{
result = false;
}
//
return result;
}
/* (non-Javadoc)
* @see fr.devinsy.sikevadb.core.Archiver#isSuspended()
*/
@Override
public boolean isSuspended()
{
boolean result;
result = !isActivated();
//
return result;
}
/* (non-Javadoc)
* @see fr.devinsy.sikevadb.core.Archiver#suspend()
*/
@Override
public void suspend()
{
this.status = Status.SUSPENDED;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,218 @@
/*
* Copyright (C) 2013-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.filetree;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.time.LocalDateTime;
import javax.xml.stream.XMLStreamException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.sikevadb.core.Element;
import fr.devinsy.sikevadb.core.SikevaDBException;
import fr.devinsy.xml.XMLBadFormatException;
import fr.devinsy.xml.XMLReader;
import fr.devinsy.xml.XMLWriter;
/**
* The Class FileTreeSikevaDBTools.
*
* @author Christian Pierre MOMON
*/
public class FileTreeSikevaDBTools
{
private static final Logger LOGGER = LoggerFactory.getLogger(FileTreeSikevaDBTools.class);
/**
* Load element.
*
* @param source
* the source
* @return the element
* @throws SikevaDBException
* the SikevaDB exception
*/
public static Element loadElement(final File source) throws SikevaDBException
{
Element result;
if (source == null)
{
result = null;
}
else if (!source.isFile())
{
result = null;
}
else
{
XMLReader in = null;
try
{
result = new Element();
in = new XMLReader(source);
in.readXMLHeader();
in.readStartTag("element");
{
// private long id; IN
long id = Long.parseLong(in.readContentTag("id").getContent());
result.setId(id);
// private DateTime creationDate; IN
LocalDateTime creationDate = LocalDateTime.parse(in.readContentTag("creation_date").getContent());
result.setCreationDate(creationDate);
// private DateTime editionDate; IN
LocalDateTime editionDate = LocalDateTime.parse(in.readContentTag("edition_date").getContent());
result.setEditionDate(editionDate);
// private long size; IN
long size = Long.parseLong(in.readContentTag("size").getContent());
result.setSize(size);
// private String digest; IN
String digest = in.readContentTag("digest").getContent();
result.setDigest(digest);
// private String value; IN
String value = in.readContentTag("value").getContent();
result.setValue(value);
}
in.readEndTag("element");
}
catch (XMLStreamException exception)
{
throw new SikevaDBException("Error loading element.", exception);
}
catch (XMLBadFormatException exception)
{
throw new SikevaDBException("Error loading element.", exception);
}
catch (FileNotFoundException exception)
{
throw new SikevaDBException("Error loading element.", exception);
}
finally
{
if (in != null)
{
try
{
in.close();
}
catch (XMLStreamException exception)
{
LOGGER.error("Finally close failed.", exception);
}
}
}
}
//
return result;
}
/**
* Save element.
*
* @param target
* the target
* @param source
* the source
* @throws SikevaDBException
* the SikevaDB exception
*/
public static void saveElement(final File target, final Element source) throws SikevaDBException
{
LOGGER.debug("[target={}]", target);
if (target == null)
{
throw new IllegalArgumentException("Target file is null.");
}
else if (target.isDirectory())
{
throw new IllegalArgumentException("Target is a directory.");
}
else
{
XMLWriter out = null;
try
{
out = new XMLWriter(target);
out.writeXMLHeader();
out.writeStartTag("element");
{
// private long id; IN
out.writeTag("id", source.getId());
// private DateTime creationDate; IN
out.writeTag("creation_date", source.getCreationDate().toString());
// private DateTime editionDate; IN
out.writeTag("edition_date", source.getEditionDate().toString());
// private long size; IN
out.writeTag("size", source.getSize());
// private String digest; IN
out.writeTag("digest", source.getDigest());
// private String value; IN
out.writeTag("value", source.getValue());
}
out.writeEndTag("element");
}
catch (UnsupportedEncodingException exception)
{
throw new SikevaDBException("Error saving element.", exception);
}
catch (FileNotFoundException exception)
{
throw new SikevaDBException("File Not Found saving element.", exception);
}
finally
{
if (out != null)
{
try
{
out.close();
}
catch (IOException exception)
{
LOGGER.error("Finally close failed.", exception);
}
}
}
}
}
}

View file

@ -0,0 +1,136 @@
/*
* Copyright (C) 2013-2024 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.sql;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.sikevadb.core.Archiver;
import fr.devinsy.sikevadb.core.Element;
import fr.devinsy.sikevadb.core.SikevaDBException;
/**
* The Class SQLArchiver.
*/
public class SQLArchiver implements Archiver
{
private static final Logger logger = LoggerFactory.getLogger(SQLArchiver.class);;
private Status status;
private SQLSikevaDB database;
/**
* Instantiates a new SQL archiver.
*
* @param source
* the source
*/
public SQLArchiver(final SQLSikevaDB source)
{
if (source == null)
{
throw new IllegalArgumentException("Null parameter.");
}
else
{
this.status = Status.ACTIVATED;
this.database = source;
}
}
/* (non-Javadoc)
* @see fr.devinsy.sikevadb.core.Archiver#activate()
*/
@Override
public void activate()
{
this.status = Status.ACTIVATED;
}
/* (non-Javadoc)
* @see fr.devinsy.sikevadb.core.Archiver#archive(fr.devinsy.sikevadb.core.Element)
*/
@Override
public void archive(final Element element) throws SikevaDBException
{
// TODO
}
/* (non-Javadoc)
* @see fr.devinsy.sikevadb.core.Archiver#clear()
*/
@Override
public void clear() throws SikevaDBException
{
// TODO
}
/* (non-Javadoc)
* @see fr.devinsy.sikevadb.core.Archiver#close()
*/
@Override
public void close()
{
// TODO
}
/* (non-Javadoc)
* @see fr.devinsy.sikevadb.core.Archiver#isActivated()
*/
@Override
public boolean isActivated()
{
boolean result;
if (this.status == Status.ACTIVATED)
{
result = true;
}
else
{
result = false;
}
//
return result;
}
/* (non-Javadoc)
* @see fr.devinsy.sikevadb.core.Archiver#isSuspended()
*/
@Override
public boolean isSuspended()
{
boolean result;
result = !isActivated();
//
return result;
}
/* (non-Javadoc)
* @see fr.devinsy.sikevadb.core.Archiver#suspend()
*/
@Override
public void suspend()
{
this.status = Status.SUSPENDED;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,202 @@
/*
* Copyright (C) 2013-2024 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.sql;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Date;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
/**
* The Class SQLSikevaDBTools.
*
* @author Christian Pierre MOMON
*/
public class SQLSikevaDBTools
{
private static final Logger logger = LoggerFactory.getLogger(SQLSikevaDBTools.class);
/**
* Load SQL script.
*
* @param source
* the source
* @return the string list
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static StringList loadSQLScript(final URL source) throws IOException
{
StringList result;
String script = IOUtils.toString(source, StandardCharsets.UTF_8);
result = splitSQLCommands(script);
//
return result;
}
/**
* Split SQL commands.
*
* @param source
* the source
* @return the string list
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static StringList splitSQLCommands(final String source) throws IOException
{
StringList result;
//
result = new StringList();
//
if (source != null)
{
//
BufferedReader in = new BufferedReader(new StringReader(source));
boolean ended = false;
StringList sql = new StringList();
while (!ended)
{
String line = in.readLine();
if (line == null)
{
ended = true;
}
else
{
if ((StringUtils.isNotBlank(line)) && (!line.startsWith("--")))
{
if (line.endsWith(";"))
{
sql.append(line.substring(0, line.length() - 1));
result.add(sql.toString());
sql.clear();
}
else
{
sql.append(line).append(' ');
}
}
}
}
//
in.close();
}
//
return result;
}
/**
* To date time.
*
* @param source
* the source
* @return the date time
*/
public static LocalDateTime toDateTime(final java.sql.Timestamp source)
{
LocalDateTime result;
if (source == null)
{
result = null;
}
else
{
long seconds = source.getTime() / 1000;
long nanos = (source.getTime() - seconds * 1000) * 1000000;
result = LocalDateTime.ofEpochSecond(seconds, (int) nanos, ZoneOffset.UTC);
}
//
return result;
}
/**
* To timestamp.
*
* @param source
* the source
* @return the java.sql. timestamp
*/
public static java.sql.Timestamp toTimestamp(final Date source)
{
java.sql.Timestamp result;
if (source == null)
{
result = null;
}
else
{
result = new java.sql.Timestamp(source.getTime() * 1000);
}
//
return result;
}
/**
* To timestamp.
*
* @param source
* the source
* @return the java.sql. timestamp
*/
public static java.sql.Timestamp toTimestamp(final LocalDateTime source)
{
java.sql.Timestamp result;
if (source == null)
{
result = null;
}
else
{
long seconds = source.toEpochSecond(ZoneOffset.UTC);
long milliseconds = source.getNano() / 1000000;
result = new java.sql.Timestamp(seconds * 1000 + milliseconds);
}
//
return result;
}
}

View file

@ -0,0 +1,226 @@
/*
* Copyright (C) 2013-2017 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 utils;
import java.io.IOException;
import java.net.URL;
import java.util.Properties;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class BuildInformation.
*
* @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/
public class BuildInformation
{
private static class SingletonHolder
{
private static final BuildInformation instance = new BuildInformation();
}
private static final Logger logger = LoggerFactory.getLogger(BuildInformation.class);
private static String BUILD_INFORMATION_FILE = "/fr/devinsy/sikevadb/build_information.properties";
private String productName;
private String majorRevision;
private String minorRevision;
private String buildNumber;
private String buildDate;
private String generator;
private String buildAuthor;
/**
* Instantiates a new builds the information.
*/
private BuildInformation()
{
Properties build = new Properties();
try
{
//
URL buildInformationFile = BuildInformation.class.getResource(BUILD_INFORMATION_FILE);
if (buildInformationFile != null)
{
build.load(BuildInformation.class.getResource(BUILD_INFORMATION_FILE).openStream());
}
//
this.productName = build.getProperty("product.name", "DevInProgress");
this.majorRevision = build.getProperty("product.revision.major", "d");
this.minorRevision = build.getProperty("product.revision.minor", "e");
this.buildNumber = build.getProperty("product.revision.build", "v");
this.buildDate = build.getProperty("product.revision.date", "today");
this.generator = build.getProperty("product.revision.generator", "n/a");
this.buildAuthor = build.getProperty("product.revision.author", "n/a");
}
catch (IOException exception)
{
logger.error("Error loading the build.properties file: " + exception.getMessage());
logger.error(ExceptionUtils.getStackTrace(exception));
this.productName = "n/a";
this.majorRevision = "n/a";
this.minorRevision = "n/a";
this.buildNumber = "n/a";
this.buildDate = "n/a";
this.generator = "n/a";
this.buildAuthor = "n/a";
}
}
/**
* Builds the author.
*
* @return the string
*/
public String buildAuthor()
{
return this.buildAuthor;
}
/**
* Builds the date.
*
* @return the string
*/
public String buildDate()
{
return this.buildDate;
}
/**
* Builds the number.
*
* @return the string
*/
public String buildNumber()
{
return this.buildNumber;
}
/**
* Generator.
*
* @return the string
*/
public String generator()
{
return this.generator;
}
/**
* Major revision.
*
* @return the string
*/
public String majorRevision()
{
return this.majorRevision;
}
/**
* Minor revision.
*
* @return the string
*/
public String minorRevision()
{
return this.minorRevision;
}
/**
* Product name.
*
* @return the string
*/
public String productName()
{
return this.productName;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
String result;
result = String.format("%s %s.%s.%s built on %s by %s", this.productName, this.majorRevision, this.minorRevision, this.buildNumber, this.buildDate, this.buildAuthor);
//
return result;
}
/**
* Version.
*
* @return the string
*/
public String version()
{
String result;
result = String.format("%s.%s.%s", this.majorRevision, this.minorRevision, this.buildNumber);
//
return result;
}
/**
* Instance.
*
* @return the builds the information
*/
public static BuildInformation instance()
{
return SingletonHolder.instance;
}
/**
* Checks if is defined.
*
* @return true, if is defined
*/
public static boolean isDefined()
{
boolean result;
if (BuildInformation.class.getResource(BUILD_INFORMATION_FILE) == null)
{
result = false;
}
else
{
result = true;
}
//
return result;
}
}

View file

@ -0,0 +1,739 @@
/*
* Copyright (C) 2013-2024 Christian Pierre MOMON, DEVINSY
*
* 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.filetree;
import java.io.File;
import java.time.LocalDateTime;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import fr.devinsy.sikevadb.core.Element;
import fr.devinsy.sikevadb.core.Elements;
import fr.devinsy.sikevadb.core.SikevaDBException;
import fr.devinsy.sikevadb.core.XMLSikevaDB;
import fr.devinsy.strings.StringList;
/**
* The Class TreeFileSikevaDBTest.
*
* @author Christian Pierre MOMON
*/
public class TreeFileSikevaDBTest
{
private static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TreeFileSikevaDBTest.class);
private static FileTreeSikevaDB database;
@Test
public void testExport01() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
database.put("alpha01", "qlskjfmlqja");
database.put("alpha01", "qlskjfmlqjb");
database.put("alpha02", "qlskjfmlqj");
database.put("alpha03", "qlskjfmlqj");
database.put("alpha04", "qlskjfmlqj");
database.put("alpha05", "qlskjfmlqj");
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.delete("alpha01s", "bravo3");
File file = File.createTempFile("sikevadb-", ".tmp");
XMLSikevaDB.export(file, database);
Assert.assertTrue(file.exists());
file.delete();
//
logger.debug("===== test done.");
}
/**
* Test get keyse 01.
*
* @throws Exception
* the exception
*/
@Test
public void testGetKeyse01() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
database.put("alpha01", "1234567890");
database.put("alpha01", "qlskjfmlqj");
database.put("alpha02", "qlskjfmlqj");
database.put("alpha03", "qlskjfmlqj");
database.put("alpha04", "qlskjfmlqj");
database.put("alpha05", "qlskjfmlqj");
database.put("alpha01s", "bravo1", "1234567890");
database.put("alpha01s", "bravo1", "qlskjfmlqj");
database.put("alpha01s", "bravo2", "qlskjfmlqj");
database.put("alpha01s", "bravo3", "qlskjfmlqj");
database.put("alpha01s", "bravo4", "qlskjfmlqj");
database.put("alpha01s", "bravo5", "qlskjfmlqj");
Assert.assertEquals(0, database.getSubkeys("none").size());
//
logger.debug("===== test done.");
}
/**
* Test get keyse 02.
*
* @throws Exception
* the exception
*/
@Test
public void testGetKeyse02() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
database.put("alpha01", "1234567890");
database.put("alpha01", "qlskjfmlqj");
database.put("alpha02", "qlskjfmlqj");
database.put("alpha03", "qlskjfmlqj");
database.put("alpha04", "qlskjfmlqj");
database.put("alpha05", "qlskjfmlqj");
database.put("alpha01s", "bravo1", "1234567890");
database.put("alpha01s", "bravo1", "qlskjfmlqj");
database.put("alpha01s", "bravo2", "qlskjfmlqj");
database.put("alpha01s", "bravo3", "qlskjfmlqj");
database.put("alpha01s", "bravo4", "qlskjfmlqj");
database.put("alpha01s", "bravo5", "qlskjfmlqj");
StringList keys = database.getTopKeys();
Assert.assertEquals(6, keys.size());
Assert.assertTrue(keys.contains("alpha03"));
Assert.assertEquals(0, database.getSubkeys("alpha03s").size());
Assert.assertEquals(5, database.getSubkeys("alpha01s").size());
//
logger.debug("===== test done.");
}
/**
* Test memory size 01.
*
* @throws Exception
* the exception
*/
@Test
public void testMemorySize01() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
Assert.assertEquals(0, database.memorySize());
database.put("alpha01", "1234567890");
database.put("alpha01", "qlskjfmlqj");
database.put("alpha02", "qlskjfmlqj");
database.put("alpha03", "qlskjfmlqj");
database.put("alpha04", "qlskjfmlqj");
database.put("alpha05", "qlskjfmlqj");
database.put("alpha01s", "bravo1", "1234567890");
database.put("alpha01s", "bravo1", "qlskjfmlqj");
database.put("alpha01s", "bravo2", "qlskjfmlqj");
database.put("alpha01s", "bravo3", "qlskjfmlqj");
database.put("alpha01s", "bravo4", "qlskjfmlqj");
database.put("alpha01s", "bravo5", "qlskjfmlqj");
Assert.assertEquals(100, database.memorySize());
Assert.assertEquals(10, database.memorySize("alpha03"));
Assert.assertEquals(50, database.memorySize("alpha01s"));
Assert.assertEquals(10, database.memorySize("alpha01s", "bravo1"));
database.clear();
Assert.assertEquals(0, database.memorySize());
//
logger.debug("===== test done.");
}
/**
* Test put 01.
*
* @throws Exception
* the exception
*/
@Test
public void testPut01() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
String source = "bonjour";
database.put("alpha01", source);
String target = database.getValue("alpha01");
Assert.assertEquals(source, target);
//
logger.debug("===== test done.");
}
/**
* Test put 02.
*
* @throws Exception
* the exception
*/
@Test
public void testPut02() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
String source = "bonjour";
database.put("alpha01", source);
String target = database.getValue("alpha01");
Assert.assertEquals(source, target);
//
logger.debug("===== test done.");
}
/**
* Test put 03.
*
* @throws Exception
* the exception
*/
@Test(expected = IllegalArgumentException.class)
public void testPut03() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
database.getValue("foo", null);
//
logger.debug("===== test done.");
}
/**
* Test put 04.
*
* @throws Exception
* the exception
*/
@Test
public void testPut04() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
String source = "bonjour";
database.put("alpha02", "bravo", source);
String target = database.getValue("alpha02", "bravo");
Assert.assertEquals(source, target);
//
logger.debug("===== test done.");
}
/**
* Test put 05.
*
* @throws Exception
* the exception
*/
@Test
public void testPut05() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
String source = "bonjour";
database.put("alpha01", source);
String target = database.getValue("alpha01");
Assert.assertEquals(source, target);
String source2 = "au revoir";
database.put("alpha01", source2);
target = database.getValue("alpha01");
Assert.assertEquals(source2, target);
// TODO StringList targets = database.getArchivedValues("alpha01");
// TODO Assert.assertEquals(1, targets.size());
// TODO Assert.assertEquals(source, targets.get(0));
//
logger.debug("===== test done.");
}
/**
* Test put 06.
*
* @throws Exception
* the exception
*/
@Test
public void testPut06() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
String source = "bonjour";
database.put("alpha01", "bravo", source);
String target = database.getValue("alpha01", "bravo");
Assert.assertEquals(source, target);
String source2 = "au revoir";
database.put("alpha01", "bravo", source2);
target = database.getValue("alpha01", "bravo");
Assert.assertEquals(source2, target);
// TODO StringList targets = database.getArchivedValues("alpha01",
// "bravo");
// TODO Assert.assertEquals(1, targets.size());
// TODO Assert.assertEquals(source, targets.get(0));
//
logger.debug("===== test done.");
}
/**
* Test put element 01.
*
* @throws Exception
* the exception
*/
@Test
public void testPutElement01() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
Element element = new Element();
element.setKey("alpha");
element.setSubkey(null);
element.setSize(10);
element.setDigest("qsdkfqskjf");
element.setCreationDate(LocalDateTime.now().minusDays(11));
element.setEditionDate(LocalDateTime.now().minusDays(11));
element.setArchiveDate(LocalDateTime.now().minusDays(10));
element.setValue("bonjour");
database.put(element);
Assert.assertEquals(1, database.countOfElements());
// TODO Assert.assertEquals(1, database.countOfArchivedElements());
// TODO Assert.assertEquals(1, database.countOfAllElements());
//
logger.debug("===== test done.");
}
/**
* Test put element 02.
*
* @throws Exception
* the exception
*/
@Test
public void testPutElement02() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
logger.debug("count={}", database.countOfElements());
Element element = new Element();
element.setId(123);
element.setKey("alpha");
element.setSubkey(null);
element.setSize(10);
element.setDigest("qsdkfqskjf");
element.setCreationDate(LocalDateTime.now().minusDays(11));
element.setEditionDate(LocalDateTime.now().minusDays(11));
element.setArchiveDate(LocalDateTime.now().minusDays(10));
element.setValue("bonjour");
database.put(element);
Assert.assertEquals(1, database.countOfElements());
// TODO Assert.assertEquals(1, database.countOfArchivedElements());
// TODO Assert.assertEquals(1, database.countOfAllElements());
//
logger.debug("===== test done.");
}
/**
* Test put element 03.
*
* @throws Exception
* the exception
*/
@Test
public void testPutElement03() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
{
Element element = new Element();
element.setId(123);
element.setKey("alpha");
element.setSubkey(null);
element.setSize(10);
element.setDigest("qsdkfqskjf");
element.setCreationDate(LocalDateTime.now().minusDays(11));
element.setEditionDate(LocalDateTime.now().minusDays(11));
element.setArchiveDate(LocalDateTime.now().minusDays(10));
element.setValue("bonjour");
database.put(element);
}
{
Element element = new Element();
element.setKey("bravo");
element.setSubkey(null);
element.setSize(10);
element.setDigest("qsdkfqskjf");
element.setCreationDate(LocalDateTime.now().minusDays(11));
element.setEditionDate(LocalDateTime.now().minusDays(11));
element.setArchiveDate(LocalDateTime.now().minusDays(10));
element.setValue("bonjour");
database.put(element);
}
// TODO Elements elements = database.getAllElements();
Elements elements = database.getElements();
Assert.assertEquals(2, elements.size());
Assert.assertEquals(2, database.countOfElements());
// TODO Assert.assertEquals(2, database.countOfArchivedElements());
// TODO Assert.assertEquals(2, database.countOfAllElements());
// TODO Assert.assertEquals(123, elements.get(0).getId());
// TODO Assert.assertEquals(124, elements.get(1).getId());
//
logger.debug("===== test done.");
}
/**
* Test random 01.
*
* @throws Exception
* the exception
*/
@Test
public void testRandom01() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
String surSource = RandomStringUtils.random(128);
String source = org.apache.commons.codec.binary.Base64.encodeBase64String(surSource.getBytes());
database.put("alpha01", source);
String target = database.getValue("alpha01");
Assert.assertEquals(source, target);
String surTarget = new String(Base64.decodeBase64(target));
Assert.assertEquals(surSource, surTarget);
//
logger.debug("===== test done.");
}
/**
* Test remove 01.
*
* @throws Exception
* the exception
*/
@Test
public void testRemove01() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
String source = "bonjour";
database.put("alpha01", "bravo", source);
String target = database.getValue("alpha01", "bravo");
Assert.assertEquals(source, target);
String source2 = "au revoir";
database.put("alpha01", "bravo", source2);
target = database.getValue("alpha01", "bravo");
Assert.assertEquals(source2, target);
// TODO StringList targets = database.getArchivedValues("alpha01",
// "bravo");
// TODO Assert.assertEquals(1, targets.size());
// TODO Assert.assertEquals(source, targets.get(0));
//
logger.debug("===== test done.");
}
/**
* Test remove many 01.
*
* @throws Exception
* the exception
*/
@Test
public void testRemoveMany01() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
database.put("alpha01", "alpha", "Allo");
database.put("alpha01", "bravo", "Bonjour");
database.put("alpha01", "charlie", "Courage");
database.put("alpha01", "delta", "Droiture");
database.put("alpha01", "echo", "Europe");
database.put("alpha01", "fox", "Force");
database.put("alpha02", "alpha", "Allo");
database.put("alpha02", "bravo", "Bonjour");
database.put("alpha02", "charlie", "Courage");
database.put("alpha02", "delta", "Droiture");
database.put("alpha02", "echo", "Europe");
database.put("alpha02", "fox", "Force");
Assert.assertEquals(12, database.countOfElements());
database.deleteMany("alpha01", "bravo", "delta", "fox");
Assert.assertEquals(9, database.countOfElements());
//
logger.debug("===== test done.");
}
/**
* Test rename key 01.
*
* @throws Exception
* the exception
*/
@Test
public void testRenameKey01() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
database.put("alpha01", "val-alpha01");
database.put("alpha01s", "sub-alpha01", "val-alpha01");
database.put("alpha01s", "sub-alpha02", "val-alpha02");
database.put("alpha01s", "sub-alpha03", "val-alpha03");
database.put("alpha02s", "sub-alpha01", "val-alpha01");
database.put("alpha03s", "sub-alpha02", "val-alpha02");
database.put("alpha04s", "sub-alpha03", "val-alpha03");
database.renameKey("alpha01s", "november");
Elements targets = database.getElements();
Assert.assertEquals(7, targets.size());
Assert.assertEquals(3, database.getValues("november").size());
//
logger.debug("===== test done.");
}
/**
* Test size 01.
*
* @throws Exception
* the exception
*/
@Test
public void testSize01() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
Assert.assertEquals(0, database.countOfElements());
// TODO Assert.assertEquals(0, database.countOfArchivedElements());
// TODO Assert.assertEquals(0, database.countOfAllElements());
database.put("alpha01", "qlskjfmlqja");
database.put("alpha01", "qlskjfmlqjb");
database.put("alpha02", "qlskjfmlqj");
database.put("alpha03", "qlskjfmlqj");
database.put("alpha04", "qlskjfmlqj");
database.put("alpha05", "qlskjfmlqj");
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.delete("alpha01s", "bravo3");
// System.out.println(database.countOfElements() + " " +
// database.countOfArchivedElements() + " " +
// database.countOfAllElements());
Assert.assertEquals(8, database.countOfElements());
// TODO Assert.assertEquals(4, database.countOfArchivedElements());
// TODO Assert.assertEquals(10, database.countOfAllElements());
database.clear();
Assert.assertEquals(0, database.countOfElements());
// TODO Assert.assertEquals(0, database.countOfArchivedElements());
// TODO Assert.assertEquals(0, database.countOfAllElements());
//
logger.debug("===== test done.");
}
/**
* Test tittle 01.
*
* @throws Exception
* the exception
*/
@Test
public void testTittle01() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
String source = "ME ME MEààààà ıııı éééé";
database.put("alpha01", source);
String target = database.getValue("alpha01");
Assert.assertEquals(source, target);
//
logger.debug("===== test done.");
}
/**
* After class.
*
* @throws SikevaDBException
* the SikevaDB exception
*/
@AfterClass
public static void afterClass() throws SikevaDBException
{
if (database != null)
{
database.close();
database.destroy();
}
}
/**
* Before class.
*
* @throws SikevaDBException
* the SikevaDB exception
*/
@BeforeClass
public static void beforeClass() throws SikevaDBException
{
Configurator.initialize(new DefaultConfiguration());
Configurator.setRootLevel(Level.DEBUG);
// Add ?profileSQL=true to generate huge logs.
// database = new SQLSikevaDB("com.mysql.jdbc.Driver",
// "jdbc:mysql://localhost:3306/sikevadb-test", "sikevadb-test",
// "12345678");
File homeDirectory = new File("/tmp/footest");
database = new FileTreeSikevaDB(homeDirectory, null, null);
if (!database.exists())
{
database.create();
}
database.open();
}
}

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2013, 2014 Christian Pierre MOMON, DEVINSY * Copyright (C) 2013-2024 Christian Pierre MOMON, DEVINSY
* *
* This file is part of SikevaDB, simple key value database. * This file is part of SikevaDB, simple key value database.
* *
@ -16,44 +16,45 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with SikevaDB. If not, see <http://www.gnu.org/licenses/>. * along with SikevaDB. If not, see <http://www.gnu.org/licenses/>.
*/ */
package fr.devinsy.sikevadb; package fr.devinsy.sikevadb.sql;
import java.io.IOException; import java.time.LocalDateTime;
import java.sql.SQLException;
import javax.naming.NamingException;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.apache.log4j.BasicConfigurator; import org.apache.logging.log4j.Level;
import org.apache.log4j.Level; import org.apache.logging.log4j.core.config.Configurator;
import org.apache.log4j.Logger; import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.joda.time.DateTime;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Assert; import org.junit.Assert;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import fr.devinsy.util.StringList; import fr.devinsy.sikevadb.core.Element;
import fr.devinsy.sikevadb.core.Elements;
import fr.devinsy.sikevadb.core.SikevaDBException;
import fr.devinsy.strings.StringList;
/** /**
* The Class SQLSikevaDBTest.
* *
* @author Christian P. Momon * @author Christian Pierre MOMON
*/ */
public class SQLSikevaDBTest { public class SQLSikevaDBTest
{
private static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(SQLSikevaDBTest.class); private static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(SQLSikevaDBTest.class);
private static SQLSikevaDB database; private static SQLSikevaDB database;
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testClearArchive01() throws Exception { public void testClearArchive01() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
Element element = new Element(); Element element = new Element();
@ -61,20 +62,20 @@ public class SQLSikevaDBTest {
element.setSubkey(null); element.setSubkey(null);
element.setSize(10); element.setSize(10);
element.setDigest("qsdkfqskjf"); element.setDigest("qsdkfqskjf");
element.setCreationDate(DateTime.now().minusDays(11)); element.setCreationDate(LocalDateTime.now().minusDays(11));
element.setEditionDate(DateTime.now().minusDays(11)); element.setEditionDate(LocalDateTime.now().minusDays(11));
element.setArchiveDate(DateTime.now().minusDays(10)); element.setArchiveDate(LocalDateTime.now().minusDays(10));
element.setValue("bonjour"); element.setValue("bonjour");
database.put(element); database.put(element);
database.put("alpha", "bravo", "toto"); database.put("alpha", "bravo", "toto");
database.clearArchive(5); // TODO database.clearArchive(5);
Assert.assertEquals(1, database.countOfElements()); Assert.assertEquals(1, database.countOfElements());
Assert.assertEquals(0, database.countOfArchivedElements()); // TODO Assert.assertEquals(0, database.countOfArchivedElements());
Assert.assertEquals(1, database.countOfAllElements()); // TODO Assert.assertEquals(1, database.countOfAllElements());
// //
logger.debug("===== test done."); logger.debug("===== test done.");
@ -82,14 +83,14 @@ public class SQLSikevaDBTest {
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testClearArchive02() throws Exception { public void testClearArchive02() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
Element element = new Element(); Element element = new Element();
@ -97,20 +98,20 @@ public class SQLSikevaDBTest {
element.setSubkey(null); element.setSubkey(null);
element.setSize(10); element.setSize(10);
element.setDigest("qsdkfqskjf"); element.setDigest("qsdkfqskjf");
element.setCreationDate(DateTime.now()); element.setCreationDate(LocalDateTime.now());
element.setEditionDate(DateTime.now()); element.setEditionDate(LocalDateTime.now());
element.setArchiveDate(DateTime.now().minusDays(10)); element.setArchiveDate(LocalDateTime.now().minusDays(10));
element.setValue("bonjour"); element.setValue("bonjour");
database.put(element); database.put(element);
database.put("alpha", "bravo", "toto"); database.put("alpha", "bravo", "toto");
database.clearArchive(DateTime.now().minusDays(5)); // TODO database.clearArchive(DateTime.now().minusDays(5));
Assert.assertEquals(1, database.countOfElements()); Assert.assertEquals(1, database.countOfElements());
Assert.assertEquals(0, database.countOfArchivedElements()); // TODO Assert.assertEquals(0, database.countOfArchivedElements());
Assert.assertEquals(1, database.countOfAllElements()); // TODO Assert.assertEquals(1, database.countOfAllElements());
// //
logger.debug("===== test done."); logger.debug("===== test done.");
@ -118,14 +119,14 @@ public class SQLSikevaDBTest {
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testGeKeyse01() throws Exception { public void testGeKeyse01() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
database.put("alpha01", "1234567890"); database.put("alpha01", "1234567890");
database.put("alpha01", "qlskjfmlqj"); database.put("alpha01", "qlskjfmlqj");
@ -148,14 +149,14 @@ public class SQLSikevaDBTest {
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testGeKeyse02() throws Exception { public void testGeKeyse02() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
database.put("alpha01", "1234567890"); database.put("alpha01", "1234567890");
database.put("alpha01", "qlskjfmlqj"); database.put("alpha01", "qlskjfmlqj");
@ -170,7 +171,7 @@ public class SQLSikevaDBTest {
database.put("alpha01", "bravo4", "qlskjfmlqj"); database.put("alpha01", "bravo4", "qlskjfmlqj");
database.put("alpha01", "bravo5", "qlskjfmlqj"); database.put("alpha01", "bravo5", "qlskjfmlqj");
StringList keys = database.getKeys(); StringList keys = database.getTopKeys();
Assert.assertEquals(5, keys.size()); Assert.assertEquals(5, keys.size());
Assert.assertTrue(keys.contains("alpha03")); Assert.assertTrue(keys.contains("alpha03"));
@ -183,14 +184,14 @@ public class SQLSikevaDBTest {
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testMemorySize01() throws Exception { public void testMemorySize01() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
Assert.assertEquals(0, database.memorySize()); Assert.assertEquals(0, database.memorySize());
@ -207,12 +208,12 @@ public class SQLSikevaDBTest {
database.put("alpha01", "bravo4", "qlskjfmlqj"); database.put("alpha01", "bravo4", "qlskjfmlqj");
database.put("alpha01", "bravo5", "qlskjfmlqj"); database.put("alpha01", "bravo5", "qlskjfmlqj");
Assert.assertEquals(120, database.memorySize()); Assert.assertEquals(100, database.memorySize());
Assert.assertEquals(60, database.memorySize("alpha01")); Assert.assertEquals(60, database.memorySize("alpha01"));
Assert.assertEquals(10, database.memorySize("alpha03")); Assert.assertEquals(10, database.memorySize("alpha03"));
Assert.assertEquals(10, database.memorySize("alpha01", "bravo1")); Assert.assertEquals(10, database.memorySize("alpha01", "bravo1"));
database.clearDatabase(); database.clear();
Assert.assertEquals(0, database.memorySize()); Assert.assertEquals(0, database.memorySize());
@ -222,14 +223,14 @@ public class SQLSikevaDBTest {
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testPut01() throws Exception { public void testPut01() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
String source = "bonjour"; String source = "bonjour";
database.put("alpha01", source); database.put("alpha01", source);
@ -242,14 +243,14 @@ public class SQLSikevaDBTest {
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testPut02() throws Exception { public void testPut02() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
String source = "bonjour"; String source = "bonjour";
database.put("alpha01", source); database.put("alpha01", source);
@ -257,8 +258,22 @@ public class SQLSikevaDBTest {
String target = database.getValue("alpha01"); String target = database.getValue("alpha01");
Assert.assertEquals(source, target); Assert.assertEquals(source, target);
target = database.getValue("alpha01", null); //
Assert.assertEquals(source, target); logger.debug("===== test done.");
}
/**
* @throws Exception
*/
@Test(expected = IllegalArgumentException.class)
public void testPut03() throws Exception
{
//
logger.debug("===== test starting...");
database.clear();
database.getValue("foo", null);
// //
logger.debug("===== test done."); logger.debug("===== test done.");
@ -266,38 +281,14 @@ public class SQLSikevaDBTest {
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testPut03() throws Exception { public void testPut04() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
String source = "bonjour";
database.put("alpha01", null, source);
String target = database.getValue("alpha01");
Assert.assertEquals(source, target);
target = database.getValue("alpha01", null);
Assert.assertEquals(source, target);
//
logger.debug("===== test done.");
}
/**
* @throws Exception
*
*/
@Test
public void testPut04() throws Exception {
//
logger.debug("===== test starting...");
database.clearDatabase();
String source = "bonjour"; String source = "bonjour";
database.put("alpha02", "bravo", source); database.put("alpha02", "bravo", source);
@ -311,14 +302,14 @@ public class SQLSikevaDBTest {
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testPut05() throws Exception { public void testPut05() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
String source = "bonjour"; String source = "bonjour";
database.put("alpha01", source); database.put("alpha01", source);
@ -332,9 +323,9 @@ public class SQLSikevaDBTest {
target = database.getValue("alpha01"); target = database.getValue("alpha01");
Assert.assertEquals(source2, target); Assert.assertEquals(source2, target);
StringList targets = database.getArchivedValues("alpha01"); // TODO StringList targets = database.getArchivedValues("alpha01");
Assert.assertEquals(1, targets.size()); // TODO Assert.assertEquals(1, targets.size());
Assert.assertEquals(source, targets.get(0)); // TODO Assert.assertEquals(source, targets.get(0));
// //
logger.debug("===== test done."); logger.debug("===== test done.");
@ -342,14 +333,14 @@ public class SQLSikevaDBTest {
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testPut06() throws Exception { public void testPut06() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
String source = "bonjour"; String source = "bonjour";
database.put("alpha01", "bravo", source); database.put("alpha01", "bravo", source);
@ -363,9 +354,10 @@ public class SQLSikevaDBTest {
target = database.getValue("alpha01", "bravo"); target = database.getValue("alpha01", "bravo");
Assert.assertEquals(source2, target); Assert.assertEquals(source2, target);
StringList targets = database.getArchivedValues("alpha01", "bravo"); // TODO StringList targets = database.getArchivedValues("alpha01",
Assert.assertEquals(1, targets.size()); // "bravo");
Assert.assertEquals(source, targets.get(0)); // TODO Assert.assertEquals(1, targets.size());
// TODO Assert.assertEquals(source, targets.get(0));
// //
logger.debug("===== test done."); logger.debug("===== test done.");
@ -373,14 +365,14 @@ public class SQLSikevaDBTest {
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testPutElement01() throws Exception { public void testPutElement01() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
Element element = new Element(); Element element = new Element();
@ -388,16 +380,16 @@ public class SQLSikevaDBTest {
element.setSubkey(null); element.setSubkey(null);
element.setSize(10); element.setSize(10);
element.setDigest("qsdkfqskjf"); element.setDigest("qsdkfqskjf");
element.setCreationDate(DateTime.now().minusDays(11)); element.setCreationDate(LocalDateTime.now().minusDays(11));
element.setEditionDate(DateTime.now().minusDays(11)); element.setEditionDate(LocalDateTime.now().minusDays(11));
element.setArchiveDate(DateTime.now().minusDays(10)); element.setArchiveDate(LocalDateTime.now().minusDays(10));
element.setValue("bonjour"); element.setValue("bonjour");
database.put(element); database.put(element);
Assert.assertEquals(0, database.countOfElements()); Assert.assertEquals(0, database.countOfElements());
Assert.assertEquals(1, database.countOfArchivedElements()); // TODO Assert.assertEquals(1, database.countOfArchivedElements());
Assert.assertEquals(1, database.countOfAllElements()); // TODO Assert.assertEquals(1, database.countOfAllElements());
// //
logger.debug("===== test done."); logger.debug("===== test done.");
@ -405,14 +397,14 @@ public class SQLSikevaDBTest {
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testPutElement02() throws Exception { public void testPutElement02() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
Element element = new Element(); Element element = new Element();
@ -421,16 +413,16 @@ public class SQLSikevaDBTest {
element.setSubkey(null); element.setSubkey(null);
element.setSize(10); element.setSize(10);
element.setDigest("qsdkfqskjf"); element.setDigest("qsdkfqskjf");
element.setCreationDate(DateTime.now().minusDays(11)); element.setCreationDate(LocalDateTime.now().minusDays(11));
element.setEditionDate(DateTime.now().minusDays(11)); element.setEditionDate(LocalDateTime.now().minusDays(11));
element.setArchiveDate(DateTime.now().minusDays(10)); element.setArchiveDate(LocalDateTime.now().minusDays(10));
element.setValue("bonjour"); element.setValue("bonjour");
database.put(element); database.put(element);
Assert.assertEquals(0, database.countOfElements()); Assert.assertEquals(0, database.countOfElements());
Assert.assertEquals(1, database.countOfArchivedElements()); // TODO Assert.assertEquals(1, database.countOfArchivedElements());
Assert.assertEquals(1, database.countOfAllElements()); // TODO Assert.assertEquals(1, database.countOfAllElements());
// //
logger.debug("===== test done."); logger.debug("===== test done.");
@ -438,14 +430,14 @@ public class SQLSikevaDBTest {
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testPutElement03() throws Exception { public void testPutElement03() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
{ {
Element element = new Element(); Element element = new Element();
@ -455,9 +447,9 @@ public class SQLSikevaDBTest {
element.setSubkey(null); element.setSubkey(null);
element.setSize(10); element.setSize(10);
element.setDigest("qsdkfqskjf"); element.setDigest("qsdkfqskjf");
element.setCreationDate(DateTime.now().minusDays(11)); element.setCreationDate(LocalDateTime.now().minusDays(11));
element.setEditionDate(DateTime.now().minusDays(11)); element.setEditionDate(LocalDateTime.now().minusDays(11));
element.setArchiveDate(DateTime.now().minusDays(10)); element.setArchiveDate(LocalDateTime.now().minusDays(10));
element.setValue("bonjour"); element.setValue("bonjour");
database.put(element); database.put(element);
@ -470,22 +462,23 @@ public class SQLSikevaDBTest {
element.setSubkey(null); element.setSubkey(null);
element.setSize(10); element.setSize(10);
element.setDigest("qsdkfqskjf"); element.setDigest("qsdkfqskjf");
element.setCreationDate(DateTime.now().minusDays(11)); element.setCreationDate(LocalDateTime.now().minusDays(11));
element.setEditionDate(DateTime.now().minusDays(11)); element.setEditionDate(LocalDateTime.now().minusDays(11));
element.setArchiveDate(DateTime.now().minusDays(10)); element.setArchiveDate(LocalDateTime.now().minusDays(10));
element.setValue("bonjour"); element.setValue("bonjour");
database.put(element); database.put(element);
} }
Elements elements = database.getAllElements(); // TODO Elements elements = database.getAllElements();
Elements elements = database.getElements();
Assert.assertEquals(0, database.countOfElements()); Assert.assertEquals(0, database.countOfElements());
Assert.assertEquals(2, database.countOfArchivedElements()); // TODO Assert.assertEquals(2, database.countOfArchivedElements());
Assert.assertEquals(2, database.countOfAllElements()); // TODO Assert.assertEquals(2, database.countOfAllElements());
Assert.assertEquals(123, elements.get(0).getId()); // TODO Assert.assertEquals(123, elements.get(0).getId());
Assert.assertEquals(124, elements.get(1).getId()); // TODO Assert.assertEquals(124, elements.get(1).getId());
// //
logger.debug("===== test done."); logger.debug("===== test done.");
@ -493,18 +486,18 @@ public class SQLSikevaDBTest {
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testRandom01() throws Exception { public void testRandom01() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
String surSource = RandomStringUtils.random(128); String surSource = RandomStringUtils.random(128);
String source = org.apache.commons.codec.binary.Base64.encodeBase64String(surSource.getBytes()); String source = org.apache.commons.codec.binary.Base64.encodeBase64String(surSource.getBytes());
database.put("alpha01", null, source); database.put("alpha01", source);
String target = database.getValue("alpha01"); String target = database.getValue("alpha01");
Assert.assertEquals(source, target); Assert.assertEquals(source, target);
@ -518,14 +511,14 @@ public class SQLSikevaDBTest {
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testRemove01() throws Exception { public void testRemove01() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
String source = "bonjour"; String source = "bonjour";
database.put("alpha01", "bravo", source); database.put("alpha01", "bravo", source);
@ -539,9 +532,10 @@ public class SQLSikevaDBTest {
target = database.getValue("alpha01", "bravo"); target = database.getValue("alpha01", "bravo");
Assert.assertEquals(source2, target); Assert.assertEquals(source2, target);
StringList targets = database.getArchivedValues("alpha01", "bravo"); // TODO StringList targets = database.getArchivedValues("alpha01",
Assert.assertEquals(1, targets.size()); // "bravo");
Assert.assertEquals(source, targets.get(0)); // TODO Assert.assertEquals(1, targets.size());
// TODO Assert.assertEquals(source, targets.get(0));
// //
logger.debug("===== test done."); logger.debug("===== test done.");
@ -549,14 +543,14 @@ public class SQLSikevaDBTest {
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testRemoveMany01() throws Exception { public void testRemoveMany01() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
database.put("alpha01", "alpha", "Allo"); database.put("alpha01", "alpha", "Allo");
database.put("alpha01", "bravo", "Bonjour"); database.put("alpha01", "bravo", "Bonjour");
@ -574,7 +568,7 @@ public class SQLSikevaDBTest {
Assert.assertEquals(12, database.countOfElements()); Assert.assertEquals(12, database.countOfElements());
database.removeMany("alpha01", "bravo", "delta", "fox"); database.deleteMany("alpha01", "bravo", "delta", "fox");
Assert.assertEquals(9, database.countOfElements()); Assert.assertEquals(9, database.countOfElements());
@ -584,14 +578,14 @@ public class SQLSikevaDBTest {
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testRenameKey01() throws Exception { public void testRenameKey01() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
database.put("alpha01", "val-alpha01"); database.put("alpha01", "val-alpha01");
database.put("alpha01", "sub-alpha01", "val-alpha01"); database.put("alpha01", "sub-alpha01", "val-alpha01");
@ -603,7 +597,7 @@ public class SQLSikevaDBTest {
database.renameKey("alpha01", "november"); database.renameKey("alpha01", "november");
Elements targets = database.getAllElements(); Elements targets = database.getElements();
Assert.assertEquals(7, targets.size()); Assert.assertEquals(7, targets.size());
Assert.assertEquals(3, database.getValues("november").size()); Assert.assertEquals(3, database.getValues("november").size());
@ -614,18 +608,18 @@ public class SQLSikevaDBTest {
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testSize01() throws Exception { public void testSize01() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
Assert.assertEquals(0, database.countOfElements()); Assert.assertEquals(0, database.countOfElements());
Assert.assertEquals(0, database.countOfArchivedElements()); // TODO Assert.assertEquals(0, database.countOfArchivedElements());
Assert.assertEquals(0, database.countOfAllElements()); // TODO Assert.assertEquals(0, database.countOfAllElements());
database.put("alpha01", "qlskjfmlqja"); database.put("alpha01", "qlskjfmlqja");
database.put("alpha01", "qlskjfmlqjb"); database.put("alpha01", "qlskjfmlqjb");
@ -633,30 +627,28 @@ public class SQLSikevaDBTest {
database.put("alpha03", "qlskjfmlqj"); database.put("alpha03", "qlskjfmlqj");
database.put("alpha04", "qlskjfmlqj"); database.put("alpha04", "qlskjfmlqj");
database.put("alpha05", "qlskjfmlqj"); database.put("alpha05", "qlskjfmlqj");
database.archive("alpha02"); database.delete("alpha03");
database.remove("alpha03");
database.put("alpha01", "bravo1", "qlskjfmlqja"); database.put("alpha01", "bravo1", "qlskjfmlqja");
database.put("alpha01", "bravo1", "qlskjfmlqjb"); database.put("alpha01", "bravo1", "qlskjfmlqjb");
database.put("alpha01", "bravo2", "qlskjfmlqj"); database.put("alpha01", "bravo2", "qlskjfmlqj");
database.put("alpha01", "bravo3", "qlskjfmlqj"); database.put("alpha01", "bravo3", "qlskjfmlqj");
database.put("alpha01", "bravo4", "qlskjfmlqj"); database.put("alpha01", "bravo4", "qlskjfmlqj");
database.put("alpha01", "bravo5", "qlskjfmlqj"); database.put("alpha01", "bravo5", "qlskjfmlqj");
database.archive("alpha01", "bravo2"); database.delete("alpha01", "bravo3");
database.remove("alpha01", "bravo3");
// System.out.println(database.countOfElements() + " " + // System.out.println(database.countOfElements() + " " +
// database.countOfArchivedElements() + " " + // database.countOfArchivedElements() + " " +
// database.countOfAllElements()); // database.countOfAllElements());
Assert.assertEquals(6, database.countOfElements()); Assert.assertEquals(8, database.countOfElements());
Assert.assertEquals(4, database.countOfArchivedElements()); // TODO Assert.assertEquals(4, database.countOfArchivedElements());
Assert.assertEquals(10, database.countOfAllElements()); // TODO Assert.assertEquals(10, database.countOfAllElements());
database.clearDatabase(); database.clear();
Assert.assertEquals(0, database.countOfElements()); Assert.assertEquals(0, database.countOfElements());
Assert.assertEquals(0, database.countOfArchivedElements()); // TODO Assert.assertEquals(0, database.countOfArchivedElements());
Assert.assertEquals(0, database.countOfAllElements()); // TODO Assert.assertEquals(0, database.countOfAllElements());
// //
logger.debug("===== test done."); logger.debug("===== test done.");
@ -664,14 +656,14 @@ public class SQLSikevaDBTest {
/** /**
* @throws Exception * @throws Exception
*
*/ */
@Test @Test
public void testTittle01() throws Exception { public void testTittle01() throws Exception
{
// //
logger.debug("===== test starting..."); logger.debug("===== test starting...");
database.clearDatabase(); database.clear();
String source = "ME ME MEààààà ıııı éééé"; String source = "ME ME MEààààà ıııı éééé";
database.put("alpha01", source); database.put("alpha01", source);
@ -686,25 +678,22 @@ public class SQLSikevaDBTest {
* *
*/ */
@AfterClass @AfterClass
public static void afterClass() { public static void afterClass()
if (database != null) { {
if (database != null)
{
database.close(); database.close();
} }
} }
/** /**
* @throws NamingException * @throws SikevaDBException
* @throws SQLException
* @throws ClassNotFoundException
* @throws IllegalAccessException
* @throws InstantiationException
* @throws IOException
*
*/ */
@BeforeClass @BeforeClass
public static void beforeClass() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException, NamingException, IOException { public static void beforeClass() throws SikevaDBException
BasicConfigurator.configure(); {
Logger.getRootLogger().setLevel(Level.ERROR); Configurator.initialize(new DefaultConfiguration());
Configurator.setRootLevel(Level.DEBUG);
// Add ?profileSQL=true to generate huge logs. // Add ?profileSQL=true to generate huge logs.
@ -713,8 +702,7 @@ public class SQLSikevaDBTest {
// "12345678"); // "12345678");
database = new SQLSikevaDB("org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:sikevadb-unittest;sql.syntax_mys=true", "sa", ""); database = new SQLSikevaDB("org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:sikevadb-unittest;sql.syntax_mys=true", "sa", "");
database.create();
database.open(); database.open();
database.createSchema();
} }
} }