Compare commits

..

No commits in common. "0.17" and "0.4" have entirely different histories.
0.17 ... 0.4

39 changed files with 1136 additions and 3382 deletions

View file

@ -2,16 +2,17 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-17-openjdk-amd64">
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="lib" path="lib/commons-lang3-3.1.jar" sourcepath="lib/commons-lang3-3.1-sources.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="module" value="true"/>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/Logs/slf4j-api-1.7.5.jar" sourcepath="lib/Logs/slf4j-api-1.7.5-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/slf4j-log4j12-1.7.5.jar" sourcepath="lib/Logs/slf4j-log4j12-1.7.5-sources.jar"/>
<classpathentry kind="lib" path="lib/UnitTesting/hamcrest-core-1.3.jar" sourcepath="lib/UnitTesting/hamcrest-core-1.3-sources.jar"/>
<classpathentry kind="lib" path="lib/UnitTesting/junit-4.11.jar" sourcepath="lib/UnitTesting/junit-4.11-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/log4j-1.2.17.jar" sourcepath="lib/Logs/log4j-1.2.17-source.zip"/>
<classpathentry kind="lib" path="lib/UnitTesting/junit-4.12.jar" sourcepath="lib/UnitTesting/junit-4.12-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/slf4j-api-1.7.25.jar" sourcepath="lib/Logs/slf4j-api-1.7.25-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/slf4j-log4j12-1.7.25.jar" sourcepath="lib/Logs/slf4j-log4j12-1.7.25-sources.jar"/>
<classpathentry kind="lib" path="lib/commons-lang3-3.13.0.jar" sourcepath="lib/commons-lang3-3.13.0-sources.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -10,25 +10,16 @@ org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes=
org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
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.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17
org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false
org.eclipse.jdt.core.formatter.align_with_spaces=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
@ -36,41 +27,25 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_c
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_binary_expression=16
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0
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_record_components=16
org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0
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_shift_operator=0
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_record_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_last_class_body_declaration=0
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=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
@ -79,7 +54,6 @@ 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_statement_group_in_switch=0
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
@ -89,17 +63,11 @@ 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_record_constructor=next_line
org.eclipse.jdt.core.formatter.brace_position_for_record_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.align_tags_descriptions_grouped=false
org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false
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
@ -108,11 +76,9 @@ 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.indent_tag_description=false
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
org.eclipse.jdt.core.formatter.comment.line_length=120
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
@ -126,7 +92,6 @@ 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_record_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
@ -135,7 +100,6 @@ 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
@ -144,7 +108,6 @@ org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do
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
@ -158,14 +121,11 @@ 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_arrow_in_switch_case=insert
org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=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_binary_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
@ -191,16 +151,10 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arg
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_record_components=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=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_not_operator=do not 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
@ -217,7 +171,6 @@ org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not ins
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_record_declaration=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
@ -226,19 +179,13 @@ 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_arrow_in_switch_case=insert
org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=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_binary_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
@ -255,7 +202,6 @@ org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not in
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_record_declaration=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
@ -282,15 +228,10 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_ar
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_record_components=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_switch_case_expressions=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
@ -302,8 +243,6 @@ org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_
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_record_constructor=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_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
@ -319,7 +258,6 @@ 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_record_declaration=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
@ -330,12 +268,9 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser
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
@ -347,62 +282,20 @@ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_decla
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_annotation_declaration_on_one_line=one_line_never
org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never
org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never
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_enum_constant_declaration_on_one_line=one_line_never
org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never
org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_never
org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never
org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never
org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line=one_line_never
org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line=one_line_never
org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false
org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false
org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false
org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never
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_after_code_block=0
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0
org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=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_record_declaration=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.text_block_indentation=0
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_binary_operator=true
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true
org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true
org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter

View file

@ -11,38 +11,27 @@ 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.convert_to_enhanced_for_loop_if_loop_var_used=false
cleanup.correct_indentation=false
cleanup.format_source_code=true
cleanup.format_source_code_changes_only=false
cleanup.insert_inferred_type_arguments=false
cleanup.lazy_logical_operator=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.merge_conditional_blocks=false
cleanup.never_use_blocks=false
cleanup.never_use_parentheses_in_expressions=true
cleanup.number_suffix=false
cleanup.organize_imports=false
cleanup.push_down_negation=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=true
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_modifiers=false
cleanup.remove_redundant_semicolons=false
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_array_creation=false
cleanup.remove_unnecessary_casts=true
cleanup.remove_unnecessary_nls_tags=true
cleanup.remove_unused_imports=true
@ -51,31 +40,21 @@ 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.simplify_lambda_expression_and_method_ref=false
cleanup.sort_members=true
cleanup.sort_members_all=false
cleanup.use_anonymous_class_creation=false
cleanup.use_autoboxing=false
cleanup.use_blocks=true
cleanup.use_blocks_only_for_return_and_throw=false
cleanup.use_directly_map_method=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.use_unboxing=false
cleanup.use_var=false
cleanup_profile=_Devinsy-strings
cleanup_settings_version=2
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_Devinsy-strings
formatter_settings_version=19
jautodoc.cleanup.add_header=false
jautodoc.cleanup.javadoc=false
jautodoc.cleanup.replace_header=false
formatter_settings_version=12
org.eclipse.jdt.ui.exception.name=exception
org.eclipse.jdt.ui.gettersetter.use.is=true
org.eclipse.jdt.ui.keywordthis=false

View file

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

View file

@ -13,8 +13,8 @@ This software is released under the GNU LGPL.
## Requirements
- Java 11
- Eclipse 4.16 (202006).
- Java 1.6
- Eclipse Kepler
## Context
Several useful Java classes.

View file

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Thu Oct 14 15:55:30 CEST 2021
build.number=1
#Thu Dec 28 05:08:48 CET 2017
build.number=5

View file

@ -1,3 +1,3 @@
product.name=devinsy-strings
product.revision.major=0
product.revision.minor=17
product.revision.minor=4

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.

BIN
lib/commons-lang3-3.1.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
src/META-INF/MANIFEST.MF Normal file
View file

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013-2018 Christian Pierre MOMON
* Copyright (C) 2013-2017 Christian Pierre MOMON
*
* This file is part of Devinsy-strings.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/>
*/
package fr.devinsy.strings;
package fr.devinsy.util.strings;
import java.util.Comparator;
@ -71,8 +71,8 @@ public class StringLengthComparator implements Comparator<String>
*
* <pre>
* compare(null, null) = 0
* compare(null, bravo) &lt; 0
* compare(alpha, null) &gt; 0
* compare(null, bravo) < 0
* compare(alpha, null) > 0
* compare(alpha, bravo) = alpha.compareTo(bravo)
* </pre>
*

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2008-2021 Christian Pierre MOMON
* Copyright (C) 2008-2010,2013-2015,2017 Christian Pierre MOMON
*
* This file is part of Devinsy-strings.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/>
*/
package fr.devinsy.strings;
package fr.devinsy.util.strings;
import java.io.IOException;
import java.text.Collator;
@ -25,15 +25,14 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
/**
* The <code>StringList</code> class is a collection of String objects with specific methods. It makes possible to build
* a string without any copy. The goal is to optimize the building of strings where they are lot of concatenation
* action.
* The <code>StringList</code> class is a collection of String objects with
* specific methods. It makes possible to build a string without any copy. The
* goal is to optimize the building of strings where they are lot of
* concatenation action.
*
*/
public class StringList extends ArrayList<String> implements CharSequence, Appendable
@ -43,7 +42,8 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
public static final String LINE_SEPARATOR = "\n";
/**
* Constructs an empty list with an initial capacity of ten (see ArrayList constructor).
* Constructs an empty list with an initial capacity of ten (see ArrayList
* constructor).
*/
public StringList()
{
@ -51,53 +51,10 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Instantiates a new string list from an array of boolean.
*
* Constructs a list of string of the specified collection, in the order
* they are returned by the collection's iterator.
*
* @param source
* the source
*/
public StringList(final boolean[] source)
{
super();
if (source != null)
{
ensureCapacity(source.length);
for (boolean value : source)
{
add(String.valueOf(value));
}
}
}
/**
* Instantiates a new string list from an array of char.
*
* @param source
* the source
*/
public StringList(final char[] source)
{
super();
if (source != null)
{
ensureCapacity(source.length);
for (char value : source)
{
add(String.valueOf(value));
}
}
}
/**
* Constructs a list of string of the specified collection, in the order they are returned by the collection's
* iterator.
*
* @param source
* the source
*/
public StringList(final Collection<String> source)
{
@ -105,8 +62,10 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
if (source != null)
{
//
ensureCapacity(source.size());
//
for (String string : source)
{
this.add(string);
@ -114,106 +73,20 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
}
/**
* Instantiates a new string list from an array of double.
*
* @param source
* the source
*/
public StringList(final double[] source)
{
super();
if (source != null)
{
ensureCapacity(source.length);
for (double value : source)
{
add(String.valueOf(value));
}
}
}
/**
* Instantiates a new string list from an array of float.
*
* @param source
* the source
*/
public StringList(final float[] source)
{
super();
if (source != null)
{
ensureCapacity(source.length);
for (float value : source)
{
add(String.valueOf(value));
}
}
}
/**
* Constructs an empty list with the specified initial capacity.
*
*
* @param initialCapacity
* the initial capacity
*/
public StringList(final int initialCapacity)
{
super(initialCapacity);
}
/**
* Instantiates a new string list from an array of int.
*
* @param source
* the source
*/
public StringList(final int[] source)
{
super();
if (source != null)
{
ensureCapacity(source.length);
for (int value : source)
{
add(String.valueOf(value));
}
}
}
/**
* Instantiates a new string list from an array of long.
*
* @param source
* the source
*/
public StringList(final long[] source)
{
super();
if (source != null)
{
ensureCapacity(source.length);
for (long value : source)
{
add(String.valueOf(value));
}
}
}
/**
* Constructs a list of string from an Object array.
*
*
* @param source
* the source
*/
public StringList(final Object... source)
{
@ -223,46 +96,14 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
{
ensureCapacity(source.length);
for (Object value : source)
{
if (value == null)
{
add(null);
}
else
{
add(value.toString());
}
}
}
}
/**
* Instantiates a new string list from an array of short.
*
* @param source
* the source
*/
public StringList(final short[] source)
{
super();
if (source != null)
{
ensureCapacity(source.length);
for (short value : source)
{
add(String.valueOf(value));
}
append(source);
}
}
/**
* Constructs a list of string from a string array.
*
*
* @param source
* the source
*/
public StringList(final String... source)
{
@ -281,8 +122,36 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
}
/* (non-Javadoc)
* @see java.lang.Appendable#append(char)
/**
* Appends the string of the array argument to this string list.
*
* @param strings
* @return
*/
public StringList append(final boolean... values)
{
StringList result;
if (values != null)
{
for (boolean value : values)
{
this.append(value);
}
}
result = this;
//
return result;
}
/**
* Appends the string representation of the char argument to this string
* list.
*
* @param character
* @return
*/
@Override
public StringList append(final char character)
@ -336,11 +205,11 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Appends the string of the specified collection, in the order they are returned by the collection's iterator.
*
* Appends the string of the specified collection, in the order they are
* returned by the collection's iterator.
*
* @param strings
* the strings
* @return the string list
* @return
*/
public StringList append(final Collection<String> strings)
{
@ -361,11 +230,11 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Appends the string representation of the double argument to this string list.
*
* Appends the string representation of the double argument to this string
* list.
*
* @param value
* the value
* @return the string list
* @return
*/
public StringList append(final double value)
{
@ -378,11 +247,11 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Appends the string representation of the int argument to this string list.
* Appends the string representation of the int argument to this string
* list.
*
* @param value
* the value
* @return the string list
* @return
*/
public StringList append(final int value)
{
@ -395,11 +264,11 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Appends the string representation of the long argument to this string list.
*
* Appends the string representation of the long argument to this string
* list.
*
* @param value
* the value
* @return the string list
* @return
*/
public StringList append(final long value)
{
@ -412,11 +281,35 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Appends the string representation of the int argument to this string list.
*
* Appends the string of the array argument to this string list.
*
* @param values
* @return
*/
public StringList append(final Long... values)
{
StringList result;
if (values != null)
{
for (Long value : values)
{
this.append(value);
}
}
result = this;
//
return result;
}
/**
* Appends the string representation of the int argument to this string
* list.
*
* @param value
* the value
* @return the string list
* @return
*/
public StringList append(final Object value)
{
@ -435,10 +328,9 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
/**
* Appends the string of the array argument to this string list.
*
* @param values
* the values
* @return the string list
*
* @param strings
* @return
*/
public StringList append(final Object... values)
{
@ -459,11 +351,11 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Appends the string representation of the long argument to this string list.
*
* Appends the string representation of the long argument to this string
* list.
*
* @param value
* the value
* @return the string list
* @return
*/
public StringList append(final short value)
{
@ -477,10 +369,11 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
/**
* Appends the string argument to this string list.
*
*
* Check null parameter before add.
*
* @param string
* the string
* @return the string list
* @return
*/
public StringList append(final String string)
{
@ -499,10 +392,9 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
/**
* Appends the string of the array argument to this string list.
*
*
* @param strings
* the strings
* @return the string list
* @return
*/
public StringList append(final String... strings)
{
@ -524,8 +416,8 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
/**
* Appends a break line to this string list.
*
* @return the string list
*
* @return
*/
public StringList appendln()
{
@ -540,11 +432,11 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Appends the string representation of the char argument to this string list, then append a break line too.
*
* Appends the string representation of the char argument to this string
* list, then append a break line too.
*
* @param character
* the character
* @return the string list
* @return
*/
public StringList appendln(final char character)
{
@ -557,9 +449,8 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Appends the string of the specified collection, in the order they are returned by the collection's iterator. Then
* append a return line.
*
* Appendln.
*
* @param string
* the string
* @return the string list
@ -575,7 +466,7 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Appends the string representation of the double argument to this string list.
* Appendln.
*
* @param value
* the value
@ -592,7 +483,7 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Appends the string representation of the int argument to this string list.
* Appendln.
*
* @param value
* the value
@ -609,7 +500,7 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Appends the string representation of the long argument to this string list.
* Appendln.
*
* @param value
* the value
@ -627,10 +518,9 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
/**
* Appends the string of the array argument to this string list.
*
*
* @param values
* the values
* @return the string list
* @return
*/
public StringList appendln(final Object... values)
{
@ -645,7 +535,7 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Appends the string representation of the int argument to this string list.
* Appendln.
*
* @param value
* the value
@ -662,7 +552,7 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Appends the string representation of the long argument to this string list.
* Appendln.
*
* @param value
* the value
@ -679,7 +569,7 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Appends the string argument to this string list.
* Appendln.
*
* @param string
* the string
@ -696,7 +586,7 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Appends the string of the array argument to this string list.
* Appendln.
*
* @param strings
* the strings
@ -749,7 +639,8 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Deep copy and shallow copy have no sense about a list of immutable objects.
* Deep copy and shallow copy have no sense about a list of immutable
* objects.
*
* @return the string list
*/
@ -1140,144 +1031,6 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
return result;
}
/**
* Count blank strings.
*
* @return the blank string count.
*/
public int countBlankStrings()
{
int result;
result = 0;
for (String string : this)
{
if (StringUtils.isBlank(string))
{
result += 1;
}
}
//
return result;
}
/**
* Count not blank strings.
*
* @return the not blank string count.
*/
public int countNotBlankStrings()
{
int result;
result = 0;
for (String string : this)
{
if (StringUtils.isNotBlank(string))
{
result += 1;
}
}
//
return result;
}
/**
* Count strings matching a regex.
*
* @param regex
* the regex
* @return the string count matching the regex.
*/
public int countStrings(final String regex)
{
int result;
result = 0;
if (regex != null)
{
Pattern compiledPattern = Pattern.compile(regex);
for (String string : this)
{
if (string != null)
{
Matcher matcher = compiledPattern.matcher(string);
if (matcher.matches())
{
result += 1;
}
}
}
}
//
return result;
}
/**
* Filter the strings matching a regex.
*
* @param regex
* the regex to match.
* @return the string list matching the regex
*/
public StringList filter(final String regex)
{
StringList result;
result = new StringList(this.size());
if (regex != null)
{
Pattern compiledPattern = Pattern.compile(regex);
for (String string : this)
{
if (string != null)
{
Matcher matcher = compiledPattern.matcher(string);
if (matcher.matches())
{
result.add(string);
}
}
}
}
result.trimToSize();
//
return result;
}
/**
* Filter blank strings.
*
* @return the not Blank string list
*/
public StringList filterBlankStrings()
{
StringList result;
result = new StringList(this.size());
for (String string : this)
{
if (StringUtils.isNotBlank(string))
{
result.add(string);
}
}
//
return result;
}
/**
* Gets the by index.
*
@ -1318,9 +1071,8 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Gets the last.
*
* @return the last
*
* @return
*/
public String getLast()
{
@ -1725,7 +1477,8 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Returns the length of the string list concatenation. Null strings are ignored.
* Returns the length of the string list concatenation. Null strings are
* ignored.
*
* @return the int
*/
@ -1747,8 +1500,9 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Merge all strings of the list into in single string. At the end of operation, the new string is the first of the
* list and the size list is 1.
* Merge all strings of the list into in single string. At the end of
* operation, the new string is the first of the list and the size list is
* 1.
*
* @return the string list
*/
@ -1767,59 +1521,6 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
return result;
}
/**
* Removes the first.
*
* @return the string list
*/
public StringList removeFirst()
{
StringList result;
if (!isEmpty())
{
this.remove(0);
}
result = this;
//
return result;
}
/**
* Removes the first.
*
* @param count
* the count
* @return the string list
*/
public StringList removeFirst(final int count)
{
StringList result;
int counting;
if (count < 0)
{
counting = 0;
}
else if (count <= size())
{
counting = count;
}
else
{
counting = size();
}
removeRange(0, counting);
result = this;
//
return result;
}
/**
* Removes the last element of the list.
*
@ -1829,7 +1530,7 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
{
StringList result;
if (!isEmpty())
if (this.size() > 0)
{
this.remove(this.size() - 1);
}
@ -1840,47 +1541,6 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
return result;
}
/**
* Removes the last.
*
* @param count
* the count
* @return the string list
*/
public StringList removeLast(final int count)
{
StringList result;
int counting;
if (count < 0)
{
counting = 0;
}
else
{
counting = count;
}
boolean ended = false;
while (!ended)
{
if ((counting == 0) || (isEmpty()))
{
ended = true;
}
else
{
this.remove(this.size() - 1);
counting -= 1;
}
}
result = this;
//
return result;
}
/**
* Extends the list copying the last element a number of time.
*
@ -1966,7 +1626,7 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
{
StringList result;
sort(Collator.getInstance());
Collections.sort(this, Collator.getInstance());
//
result = this;
@ -1977,16 +1637,14 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
/**
* Sorts this list.
*
* @param comparator
* the comparator
* @return this string list
*
* @return This List.
*/
public StringList sortBy(final Comparator<? super String> comparator)
public StringList sort(final Comparator<String> comparator)
{
StringList result;
sort(comparator);
Collections.sort(this, comparator);
//
result = this;
@ -2030,9 +1688,9 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
/**
* Extracts a substring from this list.
*
* @param beginIndex
* @param start
* The first character of the substring.
* @param endIndex
* @param end
* The last character of the substring.
*
* @return The sublist targeted.
@ -2158,7 +1816,7 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
buffer.append(separator);
}
if ((separator != null) && (!isEmpty()))
if (separator != null)
{
buffer.removeLast();
}
@ -2172,7 +1830,8 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Returns an array containing all of the strings in this list in proper sequence (from first to last element).
* Returns an array containing all of the strings in this list in proper
* sequence (from first to last element).
*
* @return the string[]
*/
@ -2192,33 +1851,9 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
}
/**
* Returns a string containing the concatenation of the strings of this list. Between each string of this list, a
* separator argument string is concatenated too.
*
* @param separator
* the separator
* @return the string
*/
public String toStringSeparatedBy(final Character separator)
{
String result;
if (separator == null)
{
result = toStringSeparatedBy("");
}
else
{
result = toStringSeparatedBy("" + separator);
}
//
return result;
}
/**
* Returns a string containing the concatenation of the strings of this list. Between each string of this list, a
* separator argument string is concatenated too.
* Returns a string containing the concatenation of the strings of this
* list. Between each string of this list, a separator argument string is
* concatenated too.
*
* @param separator
* the separator

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2014-2015,2017-2018 Christian Pierre MOMON
* Copyright (C) 2014-2015,2017 Christian Pierre MOMON
*
* This file is part of Devinsy-strings.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/>
*/
package fr.devinsy.strings;
package fr.devinsy.util.strings;
import java.util.Iterator;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013-2015,2017-2018 Christian Pierre MOMON
* Copyright (C) 2013-2015,2017 Christian Pierre MOMON
*
* This file is part of Devinsy-strings.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/>
*/
package fr.devinsy.strings;
package fr.devinsy.util.strings;
/**
* This class manages a char position in a StringList object.

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013-2020 Christian Pierre MOMON
* Copyright (C) 2013-2015,2017 Christian Pierre MOMON
*
* This file is part of Devinsy-strings.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/>
*/
package fr.devinsy.strings;
package fr.devinsy.util.strings;
import java.io.IOException;
import java.io.InputStream;
@ -57,7 +57,7 @@ public class StringListInputStream extends InputStream
{
if (source == null)
{
throw new IllegalArgumentException("source is null.");
throw new NullPointerException("source is null.");
}
else
{

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013-2021 Christian Pierre MOMON
* Copyright (C) 2013-2017 Christian Pierre MOMON
*
* This file is part of Devinsy-strings.
*
@ -16,8 +16,9 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/>
*/
package fr.devinsy.strings;
package fr.devinsy.util.strings;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
@ -59,6 +60,8 @@ public class StringListReader extends Reader
{
int result;
BufferedReader a;
if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0))
{
throw new IndexOutOfBoundsException();

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013-2020 Christian Pierre MOMON
* Copyright (C) 2013-2017 Christian Pierre MOMON
*
* This file is part of Devinsy-strings.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/>
*/
package fr.devinsy.strings;
package fr.devinsy.util.strings;
import java.io.IOException;
import java.io.Writer;
@ -57,7 +57,7 @@ public class StringListWriter extends Writer
{
if (target == null)
{
throw new IllegalArgumentException("target is null.");
throw new NullPointerException("target is null.");
}
else
{

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2014-2018 Christian Pierre MOMON
* Copyright (C) 2014-2017 Christian Pierre MOMON
*
* This file is part of Devinsy-strings.
*
@ -16,14 +16,15 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/>
*/
package fr.devinsy.strings;
package fr.devinsy.util.strings;
import java.util.Collection;
import java.util.HashSet;
/**
* This class is a set of String objects with specific methods. It makes possible to build a string without any copy.
* The goal is to make easier the use of set of strings.
* This class is a set of String objects with specific methods. It makes
* possible to build a string without any copy. The goal is to make easier the
* use of set of strings.
*/
public class StringSet extends HashSet<String>
{
@ -38,8 +39,8 @@ public class StringSet extends HashSet<String>
}
/**
* Constructs a list of string of the specified collection, in the order they are returned by the collection's
* iterator.
* Constructs a list of string of the specified collection, in the order
* they are returned by the collection's iterator.
*
* @param source
* the source
@ -81,6 +82,7 @@ public class StringSet extends HashSet<String>
if (source != null)
{
//
for (String string : source)
{
this.add(string);
@ -100,6 +102,7 @@ public class StringSet extends HashSet<String>
if (source != null)
{
//
for (String string : source)
{
this.add(string);
@ -119,13 +122,15 @@ public class StringSet extends HashSet<String>
{
boolean result;
if (string == null)
if (string != null)
{
result = false;
//
result = super.add(string);
}
else
{
result = super.add(string);
//
result = false;
}
//
@ -158,7 +163,8 @@ public class StringSet extends HashSet<String>
}
/**
* Deep copy and shallow copy have no sense about a list of immutable objects.
* Deep copy and shallow copy have no sense about a list of immutable
* objects.
*
* @return the string set
*/

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2008-2020 Christian Pierre MOMON
* Copyright (C) 2008-2010,2013-2016,2017 Christian Pierre MOMON
*
* This file is part of Devinsy-strings.
*
@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/>
*/
package fr.devinsy.strings;
package fr.devinsy.util.strings;
import java.io.BufferedReader;
import java.io.File;
@ -53,9 +53,9 @@ public class StringsUtils
/**
* Capitalize.
*
* @param source
* the source
*
* @param sourceStringUtils
* .lo the source
*/
public static void capitalize(final StringList source)
{
@ -85,40 +85,6 @@ public class StringsUtils
}
}
/**
* Concatenates a string list.
*
* @param source
* the source
* @return the concatenate of source strings.
*/
public static String concatenate(final Collection<String> source)
{
String result;
result = new StringList(source).toString();
//
return result;
}
/**
* Concatenates strings.
*
* @param source
* the source
* @return the concatenate of source strings.
*/
public static String concatenate(final String... source)
{
String result;
result = new StringList(source).toString();
//
return result;
}
/**
* Builds a string concatenating many times a source string.
*
@ -151,86 +117,29 @@ public class StringsUtils
{
boolean result;
if ((token == null) || (strings == null))
boolean ended = false;
int index = 0;
result = false;
while (!ended)
{
result = false;
}
else
{
boolean ended = false;
int index = 0;
result = false;
while (!ended)
if (index < strings.length)
{
if (index < strings.length)
{
String current = strings[index];
String current = strings[index];
if (StringUtils.contains(token, current))
{
ended = true;
result = true;
}
else
{
index += 1;
}
if (StringUtils.contains(token, current))
{
ended = true;
result = true;
}
else
{
ended = true;
result = false;
index += 1;
}
}
}
//
return result;
}
/**
* Contains any.
*
* @param token
* the token
* @param strings
* the strings
* @return true, if successful
*/
public static boolean containsAny(final String token, final StringList strings)
{
boolean result;
if ((token == null) || (strings == null))
{
result = false;
}
else
{
boolean ended = false;
int index = 0;
result = false;
while (!ended)
else
{
if (index < strings.size())
{
String current = strings.get(index);
if (StringUtils.contains(token, current))
{
ended = true;
result = true;
}
else
{
index += 1;
}
}
else
{
ended = true;
result = false;
}
ended = true;
result = false;
}
}
@ -251,86 +160,29 @@ public class StringsUtils
{
boolean result;
if ((token == null) || (strings == null))
boolean ended = false;
int index = 0;
result = false;
while (!ended)
{
result = false;
}
else
{
boolean ended = false;
int index = 0;
result = false;
while (!ended)
if (index < strings.length)
{
if (index < strings.length)
{
String current = strings[index];
String current = strings[index];
if (StringUtils.containsIgnoreCase(token, current))
{
ended = true;
result = true;
}
else
{
index += 1;
}
if (StringUtils.containsIgnoreCase(token, current))
{
ended = true;
result = true;
}
else
{
ended = true;
result = false;
index += 1;
}
}
}
//
return result;
}
/**
* Contains any ignore case.
*
* @param token
* the token
* @param strings
* the strings
* @return true, if successful
*/
public static boolean containsAnyIgnoreCase(final String token, final StringList strings)
{
boolean result;
if ((token == null) || (strings == null))
{
result = false;
}
else
{
boolean ended = false;
int index = 0;
result = false;
while (!ended)
else
{
if (index < strings.size())
{
String current = strings.get(index);
if (StringUtils.containsIgnoreCase(token, current))
{
ended = true;
result = true;
}
else
{
index += 1;
}
}
else
{
ended = true;
result = false;
}
ended = true;
result = false;
}
}
@ -442,44 +294,6 @@ public class StringsUtils
return result;
}
/**
* Contains none.
*
* @param token
* the token
* @param strings
* the strings
* @return true, if successful
*/
public static boolean containsNone(final String token, final String... strings)
{
boolean result;
result = !containsAny(token, strings);
//
return result;
}
/**
* Contains none ignore case.
*
* @param token
* the token
* @param strings
* the strings
* @return true, if successful
*/
public static boolean containsNoneIgnoreCase(final String token, final String... strings)
{
boolean result;
result = !containsAnyIgnoreCase(token, strings);
//
return result;
}
/**
* Contains null.
*
@ -532,179 +346,6 @@ public class StringsUtils
return result;
}
/**
* Count blank strings.
*
* @param source
* the string list to compute.
* @return the blank string count.
*/
public static int countBlankStrings(final StringList source)
{
int result;
if (source == null)
{
result = 0;
}
else
{
result = source.countBlankStrings();
}
//
return result;
}
/**
* Count not blank strings.
*
* @param source
* the string list to compute.
* @return the not blank string count.
*/
public static int countNotBlankStrings(final StringList source)
{
int result;
if (source == null)
{
result = 0;
}
else
{
result = source.countNotBlankStrings();
}
//
return result;
}
/**
* Count strings matching a regex.
*
* @param source
* the string list to compute
* @param regex
* the regex
* @return the string count matching the regex.
*/
public static int countStrings(final StringList source, final String regex)
{
int result;
if (source == null)
{
result = 0;
}
else
{
result = source.countStrings(regex);
}
//
return result;
}
/**
* Ends with any.
*
* @param token
* the token
* @param strings
* the strings
* @return true, if successful
*/
public static boolean endsWithAny(final String token, final StringList strings)
{
boolean result;
if ((token == null) || (strings == null))
{
result = false;
}
else
{
boolean ended = false;
int index = 0;
result = false;
while (!ended)
{
if (index < strings.size())
{
String current = strings.get(index);
if (StringUtils.endsWith(token, current))
{
ended = true;
result = true;
}
else
{
index += 1;
}
}
else
{
ended = true;
result = false;
}
}
}
//
return result;
}
/**
* Ends with any ignore case.
*
* @param token
* the token
* @param strings
* the strings
* @return true, if successful
*/
public static boolean endsWithAnyIgnoreCase(final String token, final StringList strings)
{
boolean result;
if ((token == null) || (strings == null))
{
result = false;
}
else
{
boolean ended = false;
int index = 0;
result = false;
while (!ended)
{
if (index < strings.size())
{
String current = strings.get(index);
if (StringUtils.endsWithIgnoreCase(token, current))
{
ended = true;
result = true;
}
else
{
index += 1;
}
}
else
{
ended = true;
result = false;
}
}
}
//
return result;
}
/**
* Checks if is contained.
*
@ -743,56 +384,6 @@ public class StringsUtils
return result;
}
/**
* Filter the strings matching a regex.
*
* @param source
* the string list to compute.
* @param regex
* the regex to match.
* @return the string list matching the regex
*/
public static StringList filter(final StringList source, final String regex)
{
StringList result;
if (source == null)
{
result = new StringList();
}
else
{
result = source.filter(regex);
}
//
return result;
}
/**
* Filter blank strings.
*
* @param source
* the string list to compute.
* @return the not Blank string list
*/
public static StringList filterBlankStrings(final StringList source)
{
StringList result;
if (source == null)
{
result = new StringList();
}
else
{
result = source.filterBlankStrings();
}
//
return result;
}
/**
* Find longest.
*
@ -1038,10 +629,9 @@ public class StringsUtils
/**
* Checks if is blank.
*
*
* @param source
* the source
* @return true, if is blank
*/
public static boolean isBlank(final Collection<String> source)
{
@ -1123,88 +713,6 @@ public class StringsUtils
return result;
}
/**
* Checks if is matching.
*
* @param args
* the args
* @param regexps
* the regexps
* @return true, if is matching
*/
public static boolean isMatching(final String[] args, final String... regexps)
{
boolean result;
result = isMatching(new StringList(args), regexps);
//
return result;
}
/**
* Checks if is matching.
*
* @param args
* the args
* @param regexps
* the regexps
* @return true, if is matching
*/
public static boolean isMatching(final StringList args, final String... regexps)
{
boolean result;
if (((args == null) || (args.size() == 0)) && ((regexps == null) || (regexps.length == 0)))
{
result = true;
}
else if (((args == null) || (args.size() == 0)) && ((regexps != null) && (regexps.length != 0)))
{
result = false;
}
else if (((args != null) && (args.size() != 0)) && ((regexps == null) || (regexps.length == 0)))
{
result = false;
}
else if (args.size() != regexps.length)
{
result = false;
}
else
{
boolean ended = false;
int index = 0;
result = false;
while (!ended)
{
if (index < args.size())
{
String arg = args.get(index);
String regexp = regexps[index];
if (arg.matches(regexp))
{
index += 1;
}
else
{
ended = true;
result = false;
}
}
else
{
ended = true;
result = true;
}
}
}
//
return result;
}
/**
* Load.
*
@ -1402,8 +910,8 @@ public class StringsUtils
}
/**
* Save string of the list as lines.
*
* Save.
*
* @param file
* the file
* @param source
@ -1451,106 +959,6 @@ public class StringsUtils
}
}
/**
* Starts with any.
*
* @param token
* the token
* @param strings
* the strings
* @return true, if successful
*/
public static boolean startsWithAny(final String token, final StringList strings)
{
boolean result;
if ((token == null) || (strings == null))
{
result = false;
}
else
{
boolean ended = false;
int index = 0;
result = false;
while (!ended)
{
if (index < strings.size())
{
String current = strings.get(index);
if (StringUtils.startsWith(token, current))
{
ended = true;
result = true;
}
else
{
index += 1;
}
}
else
{
ended = true;
result = false;
}
}
}
//
return result;
}
/**
* Starts with any ignore case.
*
* @param token
* the token
* @param strings
* the strings
* @return true, if successful
*/
public static boolean startsWithAnyIgnoreCase(final String token, final StringList strings)
{
boolean result;
if ((token == null) || (strings == null))
{
result = false;
}
else
{
boolean ended = false;
int index = 0;
result = false;
while (!ended)
{
if (index < strings.size())
{
String current = strings.get(index);
if (StringUtils.startsWithIgnoreCase(token, current))
{
ended = true;
result = true;
}
else
{
index += 1;
}
}
else
{
ended = true;
result = false;
}
}
}
//
return result;
}
/**
* Swap case.
*
@ -1593,7 +1001,7 @@ public class StringsUtils
*
* @return A string concatenation of the argument.
*/
public static String toString(final String... source)
public static String toString(final String[] source)
{
String result;
@ -1985,8 +1393,8 @@ public class StringsUtils
*
* @param source
* the source
* @return If argument is null then returns an empty string, otherwise returns a string concatenation of the
* argument.
* @return If argument is null then returns an empty string, otherwise
* returns a string concatenation of the argument.
*/
public static String toStringNotNull(final String[] source)
{
@ -2055,32 +1463,6 @@ public class StringsUtils
return result;
}
/**
* To string separated by.
*
* @param source
* the source
* @param separator
* the separator
* @return the string
*/
public static String toStringSeparatedBy(final StringList source, final Character separator)
{
String result;
if (source == null)
{
result = null;
}
else
{
result = source.toStringSeparatedBy(separator);
}
//
return result;
}
/**
* To string separated by.
*
@ -2526,14 +1908,12 @@ public class StringsUtils
/**
* Writes the strings of this list into a {@code PrintWriter}.
*
* @param source
* the source
* @param out
* The {@code PrintWriter} where to write.
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void writeTo(final java.io.PrintWriter out, final StringList source) throws IOException
public static void writeTo(final StringList source, final java.io.PrintWriter out) throws IOException
{
if (source != null)
{
@ -2547,14 +1927,12 @@ public class StringsUtils
/**
* Writes the strings of this list into a {@code Writer}.
*
* @param source
* the source
* @param out
* The {@code Writer} where to write.
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void writeTo(final java.io.Writer out, final StringList source) throws IOException
public static void writeTo(final StringList source, final java.io.Writer out) throws IOException
{
if (source != null)
{
@ -2564,40 +1942,4 @@ public class StringsUtils
}
}
}
/**
* Save.
*
* @param file
* the file
* @param source
* the source
* @throws UnsupportedEncodingException
* the unsupported encoding exception
* @throws FileNotFoundException
* the file not found exception
*/
public static void writeToFile(final File file, final StringList source) throws UnsupportedEncodingException, FileNotFoundException
{
PrintWriter out = null;
try
{
out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), DEFAULT_CHARSET_NAME));
if (source != null)
{
for (String string : source)
{
out.print(string);
}
}
}
finally
{
if (out != null)
{
out.close();
}
}
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2021 Christian Pierre MOMON
* Copyright (C) 2017 Christian Pierre MOMON
*
* This file is part of Devinsy-strings.
*
@ -16,19 +16,20 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/>
*/
package fr.devinsy.strings.demo;
package fr.devinsy.util.strings.demo;
import java.util.ArrayList;
import java.util.Date;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
import fr.devinsy.util.strings.StringList;
import fr.devinsy.util.strings.StringsUtils;
/**
* The Class Demo.
*/
public class StringsDemo
{
/**
* The main method.
*
@ -58,14 +59,14 @@ public class StringsDemo
strings.appendln("========== DEMO #2;");
strings.appendln();
strings.appendln("Easy to concatenate different types.");
strings.append("Boolean: ").append(true).append(" ").appendln(Boolean.valueOf(false));
strings.append("Char: ").append('e').append(" ").appendln(Character.valueOf('e'));
strings.append("Byte : ").append((byte) 5).append(" ").appendln(Byte.valueOf((byte) 5));
strings.append("Short: ").append((short) 55).append(" ").appendln(Short.valueOf((short) 55));
strings.append("Integer: ").append(555).append(" ").appendln(Integer.valueOf(555));
strings.append("Long: ").append(5555L).append(" ").appendln(Long.valueOf(5555));
strings.append("Float: ").append((float) 5555.5).append(" ").appendln(Float.valueOf((float) 5555.5));
strings.append("Double: ").append(5555.55).append(" ").appendln(Double.valueOf(5555.55));
strings.append("Boolean: ").append(true).append(" ").appendln(new Boolean(false));
strings.append("Char: ").append('e').append(" ").appendln(new Character('e'));
strings.append("Byte : ").append((byte) 5).append(" ").appendln(new Byte((byte) 5));
strings.append("Short: ").append((short) 55).append(" ").appendln(new Short((short) 55));
strings.append("Integer: ").append(555).append(" ").appendln(new Integer(555));
strings.append("Long: ").append(5555L).append(" ").appendln(new Long(5555));
strings.append("Float: ").append((float) 5555.5).append(" ").appendln(new Float(5555.5));
strings.append("Double: ").append(5555.55).append(" ").appendln(new Double(5555.55));
strings.append("String: ").append("abcde").append(" ").appendln(new String("abcde"));
strings.append("Object: ").appendln(new Date());
strings.append("Array of booleans: ").appendln(StringsUtils.toStringList(new boolean[] { true, false, true }));
@ -109,7 +110,7 @@ public class StringsDemo
strings.appendln("========== DEMO #4;");
strings.appendln();
strings.appendln("Advanced features.");
strings.append("Boolean: ").append(true).append(" ").appendln(Boolean.valueOf(false));
strings.append("Boolean: ").append(true).append(" ").appendln(new Boolean(false));
System.out.println(strings.toString());
}
@ -121,7 +122,7 @@ public class StringsDemo
strings.appendln("========== DEMO #5;");
strings.appendln();
strings.appendln("Funny features.");
strings.append("Boolean: ").append(true).append(" ").appendln(Boolean.valueOf(false));
strings.append("Boolean: ").append(true).append(" ").appendln(new Boolean(false));
System.out.println(strings.toString());
}

File diff suppressed because it is too large Load diff

View file

@ -1,700 +0,0 @@
/*
* Copyright (C) 2013-2020 Christian Pierre MOMON
*
* This file is part of Devinsy-strings.
*
* Devinsy-strings is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Devinsy-strings 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/>
*/
package fr.devinsy.strings;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* The Class StringsUtilsTest.
*
* @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/
public class StringsUtilsTest
{
public final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(StringsUtilsTest.class);
/**
* Before.
*/
@Before
public void before()
{
BasicConfigurator.configure();
Logger.getRootLogger().setLevel(Level.ERROR);
}
/**
* Test contains any 01.
*/
@Test
public void testContainsAny01()
{
Assert.assertTrue(StringsUtils.containsAny("abc", "aaa", "bbb", "abc"));
Assert.assertFalse(StringsUtils.containsAny("abc", "aaa", "bbb", "aBc"));
Assert.assertTrue(StringsUtils.containsAny("abc", new StringList("aaa", "bbb", "abc")));
Assert.assertFalse(StringsUtils.containsAny("abc", new StringList("aaa", "bbb", "aBc")));
}
/**
* Test contains any ignore case 01.
*/
@Test
public void testContainsAnyIgnoreCatse01()
{
Assert.assertTrue(StringsUtils.containsAnyIgnoreCase("abc", "aaa", "bbb", "abc"));
Assert.assertTrue(StringsUtils.containsAnyIgnoreCase("abc", "aaa", "bbb", "aBc"));
Assert.assertFalse(StringsUtils.containsAnyIgnoreCase("abc", "aaa", "bbb", "ccc"));
Assert.assertTrue(StringsUtils.containsAnyIgnoreCase("abc", new StringList("aaa", "bbb", "abc")));
Assert.assertTrue(StringsUtils.containsAnyIgnoreCase("abc", new StringList("aaa", "bbb", "aBc")));
Assert.assertFalse(StringsUtils.containsAnyIgnoreCase("abc", new StringList("aaa", "bbb", "ccc")));
}
/**
* Test contains blank 01.
*/
@Test
public void testContainsBlank01()
{
Assert.assertFalse(StringsUtils.containsBlank((Collection<String>) null));
Assert.assertFalse(StringsUtils.containsBlank(new StringList("aaa", "bbb", "ccc")));
Assert.assertTrue(StringsUtils.containsBlank(new StringList("aaa", null, "ccc")));
Assert.assertTrue(StringsUtils.containsBlank(new StringList("aaa", "", "ccc")));
Assert.assertTrue(StringsUtils.containsBlank(new StringList("aaa", " ", "ccc")));
}
/**
* Test contains blank 02.
*/
@Test
public void testContainsBlank02()
{
Assert.assertFalse(StringsUtils.containsBlank((String[]) null));
Assert.assertFalse(StringsUtils.containsBlank("aaa", "bbb", "ccc"));
Assert.assertTrue(StringsUtils.containsBlank("aaa", null, "ccc"));
Assert.assertTrue(StringsUtils.containsBlank("aaa", "", "ccc"));
Assert.assertTrue(StringsUtils.containsBlank("aaa", " ", "ccc"));
}
/**
* Test contains blank 03.
*/
@Test
public void testContainsBlank03()
{
Assert.assertFalse(StringsUtils.containsBlank((ArrayList<String>) null));
ArrayList<String> source = new ArrayList<String>();
source.add("aaa");
source.add("bbb");
source.add("ccc");
Assert.assertFalse(StringsUtils.containsBlank(source));
source.set(1, null);
Assert.assertTrue(StringsUtils.containsBlank(source));
source.set(1, "");
Assert.assertTrue(StringsUtils.containsBlank(source));
source.set(1, " ");
Assert.assertTrue(StringsUtils.containsBlank(source));
}
/**
* Test contains empty 01.
*/
@Test
public void testContainsEmpty01()
{
Assert.assertFalse(StringsUtils.containsEmpty((Collection<String>) null));
Assert.assertFalse(StringsUtils.containsEmpty(new StringList("aaa", "bbb", "ccc")));
Assert.assertTrue(StringsUtils.containsEmpty(new StringList("aaa", null, "ccc")));
Assert.assertTrue(StringsUtils.containsEmpty(new StringList("aaa", "", "ccc")));
}
/**
* Test contains empty 02.
*/
@Test
public void testContainsEmpty02()
{
Assert.assertFalse(StringsUtils.containsEmpty((String[]) null));
Assert.assertFalse(StringsUtils.containsEmpty("aaa", "bbb", "ccc"));
Assert.assertTrue(StringsUtils.containsEmpty("aaa", null, "ccc"));
Assert.assertTrue(StringsUtils.containsEmpty("aaa", "", "ccc"));
}
/**
* Test contains empty 03.
*/
@Test
public void testContainsEmpty03()
{
Assert.assertFalse(StringsUtils.containsEmpty((ArrayList<String>) null));
ArrayList<String> source = new ArrayList<String>();
source.add("aaa");
source.add("bbb");
source.add("ccc");
Assert.assertFalse(StringsUtils.containsEmpty(source));
source.set(1, null);
Assert.assertTrue(StringsUtils.containsEmpty(source));
source.set(1, "");
Assert.assertTrue(StringsUtils.containsEmpty(source));
}
/**
* Test contains null 01.
*/
@Test
public void testContainsNull01()
{
Assert.assertFalse(StringsUtils.containsNull((Collection<String>) null));
Assert.assertFalse(StringsUtils.containsNull(new StringList("aaa", "bbb", "ccc")));
Assert.assertTrue(StringsUtils.containsNull(new StringList("aaa", null, "ccc")));
}
/**
* Test contains null 02.
*/
@Test
public void testContainsNull02()
{
Assert.assertFalse(StringsUtils.containsNull((String[]) null));
Assert.assertFalse(StringsUtils.containsNull("aaa", "bbb", "ccc"));
Assert.assertTrue(StringsUtils.containsNull("aaa", null, "ccc"));
}
/**
* Test contains null 03.
*/
@Test
public void testContainsNull03()
{
Assert.assertFalse(StringsUtils.containsNull((ArrayList<String>) null));
ArrayList<String> source = new ArrayList<String>();
source.add("aaa");
source.add("bbb");
source.add("ccc");
Assert.assertFalse(StringsUtils.containsNull(source));
source.set(1, null);
Assert.assertTrue(StringsUtils.containsNull(source));
}
/**
* Test count blank strings.
*/
@Test
public void testCountBlankStrings()
{
//
this.logger.debug("===== test starting...");
{
StringList source = new StringList();
Assert.assertEquals(0, StringsUtils.countBlankStrings(source));
}
{
StringList source = new StringList();
source.append("1aaa").append("2bbb").append("3ccc").append("4ddd").append("5eee");
Assert.assertEquals(0, StringsUtils.countBlankStrings(source));
}
{
StringList source = new StringList();
source.append("1aaa").append("2bbb").append("3ccc").append("4ddd").append("5eee");
source.set(1, null);
source.set(4, null);
Assert.assertEquals(2, StringsUtils.countBlankStrings(source));
}
//
this.logger.debug("===== test done.");
}
/**
* Test count blank strings.
*/
@Test
public void testCountNotBlankStrings()
{
//
this.logger.debug("===== test starting...");
{
StringList source = new StringList();
Assert.assertEquals(0, StringsUtils.countNotBlankStrings(source));
}
{
StringList source = new StringList();
source.append("1aaa").append("2bbb").append("3ccc").append("4ddd").append("5eee");
Assert.assertEquals(5, StringsUtils.countNotBlankStrings(source));
}
{
StringList source = new StringList();
source.append("1aaa").append("2bbb").append("3ccc").append("4ddd").append("5eee");
source.set(1, null);
source.set(4, null);
Assert.assertEquals(3, StringsUtils.countNotBlankStrings(source));
}
//
this.logger.debug("===== test done.");
}
/**
* Test count blank strings.
*/
@Test
public void testCountStrings()
{
//
this.logger.debug("===== test starting...");
{
StringList source = new StringList();
Assert.assertEquals(0, StringsUtils.countStrings(source, null));
}
{
StringList source = new StringList();
Assert.assertEquals(0, StringsUtils.countStrings(source, "a*"));
}
{
StringList source = new StringList();
source.append("1aaa").append("2bbb").append("3ccc").append("4ddd").append("5eee");
Assert.assertEquals(0, StringsUtils.countStrings(source, null));
}
{
StringList source = new StringList();
source.append("1aaa").append("2bbb").append("3ccc").append("4ddd").append("5eee");
Assert.assertEquals(5, StringsUtils.countStrings(source, ".*\\d.*"));
}
{
StringList source = new StringList();
source.append("1aaa").append("2bbb").append("3ccc").append("4ddd").append("5eee");
source.set(1, null);
source.set(4, null);
Assert.assertEquals(0, StringsUtils.countStrings(source, null));
}
{
StringList source = new StringList();
source.append("1aaa").append("2bbb").append("3ccc").append("4ddd").append("5eee");
source.set(1, null);
source.set(4, null);
Assert.assertEquals(3, StringsUtils.countStrings(source, ".*\\d.*"));
}
//
this.logger.debug("===== test done.");
}
/**
* Test ends with any 01.
*/
@Test
public void testEndsWithAny01()
{
Assert.assertTrue(StringsUtils.endsWithAny("abc", new StringList("aa", "bb", "bc")));
Assert.assertFalse(StringsUtils.endsWithAny("abc", new StringList("aa", "bb", "Bc")));
}
/**
* Test contains any ignore case 01.
*/
@Test
public void testEndsWithAnyIgnoreCatse01()
{
Assert.assertTrue(StringsUtils.endsWithAnyIgnoreCase("abc", new StringList("aa", "bb", "bc")));
Assert.assertTrue(StringsUtils.endsWithAnyIgnoreCase("abc", new StringList("aa", "bb", "Bc")));
Assert.assertFalse(StringsUtils.endsWithAnyIgnoreCase("abc", new StringList("aa", "bb", "cc")));
}
@Test
public void testEqualsAny01()
{
Assert.assertTrue(StringsUtils.equalsAny("abc", "aaa", "bbb", "abc"));
Assert.assertFalse(StringsUtils.equalsAny("abc", "aaa", "bbb", "aBc"));
}
@Test
public void testEqualsAnyIgnoreCase01()
{
Assert.assertTrue(StringsUtils.equalsAnyIgnoreCase("abc", "aaa", "bbb", "abc"));
Assert.assertTrue(StringsUtils.equalsAnyIgnoreCase("abc", "aaa", "bbb", "aBc"));
}
/**
* Test filter.
*/
@Test
public void testFilter()
{
//
this.logger.debug("===== test starting...");
{
StringList source = new StringList();
Assert.assertEquals(0, StringsUtils.filter(source, null).size());
}
{
StringList source = new StringList();
Assert.assertEquals(0, StringsUtils.filter(source, "a*").size());
}
{
StringList source = new StringList();
source.append("1aaa").append("2bbb").append("3ccc").append("4ddd").append("5eee");
Assert.assertEquals(0, StringsUtils.filter(source, null).size());
}
{
StringList source = new StringList();
source.append("1aaa").append("2bbb").append("3ccc").append("4ddd").append("5eee");
Assert.assertEquals(5, StringsUtils.filter(source, ".*\\d.*").size());
}
{
StringList source = new StringList();
source.append("1aaa").append("2bbb").append("3ccc").append("4ddd").append("5eee");
source.set(1, null);
source.set(4, null);
Assert.assertEquals(0, StringsUtils.filter(source, null).size());
}
{
StringList source = new StringList();
source.append("1aaa").append("2bbb").append("3ccc").append("4ddd").append("5eee");
source.set(1, null);
source.set(4, null);
Assert.assertEquals(3, StringsUtils.filter(source, ".*\\d.*").size());
}
//
this.logger.debug("===== test done.");
}
/**
* Test filter blank strings.
*/
@Test
public void testFilterBlankStrings()
{
//
this.logger.debug("===== test starting...");
{
StringList source = new StringList();
Assert.assertEquals(0, StringsUtils.filterBlankStrings(source).size());
}
{
StringList source = new StringList();
source.append("1aaa").append("2bbb").append("3ccc").append("4ddd").append("5eee");
Assert.assertEquals(5, StringsUtils.filterBlankStrings(source).size());
}
{
StringList source = new StringList();
source.append("1aaa").append("2bbb").append("3ccc").append("4ddd").append("5eee");
source.set(1, null);
source.set(4, null);
Assert.assertEquals(3, StringsUtils.filterBlankStrings(source).size());
}
//
this.logger.debug("===== test done.");
}
/**
* Test find smallest 01.
*/
@Test
public void testFindSmallest01()
{
// TODO
Assert.assertFalse(StringsUtils.containsNull((ArrayList<String>) null));
ArrayList<String> source = new ArrayList<String>();
source.add("aaa");
source.add("bbb");
source.add("ccc");
Assert.assertFalse(StringsUtils.containsNull(source));
source.set(1, null);
Assert.assertTrue(StringsUtils.containsNull(source));
}
/**
* Test is matching 01.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void testIsMatching01() throws IOException
{
//
StringList source = null;
String[] regexps = null;
//
Assert.assertEquals(true, StringsUtils.isMatching(source, regexps));
}
/**
* Test is matching 02.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void testIsMatching02() throws IOException
{
//
StringList source = new StringList();
String[] regexps = null;
//
Assert.assertEquals(true, StringsUtils.isMatching(source, regexps));
}
/**
* Test is matching 03.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void testIsMatching03() throws IOException
{
//
StringList source = null;
String[] regexps = new String[0];
//
Assert.assertEquals(true, StringsUtils.isMatching(source, regexps));
}
/**
* Test is matching 04.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void testIsMatching04() throws IOException
{
//
StringList source = new StringList();
String[] regexps = new String[0];
//
Assert.assertEquals(true, StringsUtils.isMatching(source, regexps));
}
/**
* Test is matching 05.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void testIsMatching05() throws IOException
{
//
StringList source = new StringList("aaa", "bbb", "ccc");
String[] regexps = null;
//
Assert.assertEquals(false, StringsUtils.isMatching(source, regexps));
}
/**
* Test is matching 06.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void testIsMatching06() throws IOException
{
//
StringList source = new StringList("aaa", "bbb", "ccc");
String[] regexps = new String[0];
//
Assert.assertEquals(false, StringsUtils.isMatching(source, regexps));
}
/**
* Test is matching 07.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void testIsMatching07() throws IOException
{
//
StringList source = new StringList("aaa", "bbb", "ccc");
String[] regexps = new String[] { "^a+$" };
//
Assert.assertEquals(false, StringsUtils.isMatching(source, regexps));
}
/**
* Test is matching 08.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void testIsMatching08() throws IOException
{
//
StringList source = new StringList("aaa", "bbb", "ccc");
String[] regexps = new String[] { "^a+$", "^b+$", "^c+$" };
//
Assert.assertEquals(true, StringsUtils.isMatching(source, regexps));
}
/**
* Test is matching 09.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void testIsMatching09() throws IOException
{
//
StringList source = null;
String[] regexps = new String[] { "^a+$", "^b+$", "^c+$" };
//
Assert.assertEquals(false, StringsUtils.isMatching(source, regexps));
}
/**
* Test is matching 10.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void testIsMatching10() throws IOException
{
//
StringList source = new StringList();
String[] regexps = new String[] { "^a+$", "^b+$", "^c+$" };
//
Assert.assertEquals(false, StringsUtils.isMatching(source, regexps));
}
/**
* Test is matching 11.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void testIsMatching11() throws IOException
{
//
StringList source = new StringList("aaa");
String[] regexps = new String[] { "^a+$", "^b+$", "^c+$" };
//
Assert.assertEquals(false, StringsUtils.isMatching(source, regexps));
}
/**
* Load to string list URL 01.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void testLoadResource01() throws IOException
{
//
StringList source = StringsUtils.load(StringsUtilsTest.class.getResource("/fr/devinsy/strings/lines.txt"));
//
Assert.assertEquals(4, source.size());
Assert.assertEquals("trois", source.get(3 - 1));
}
/**
* Test starts with any 01.
*/
@Test
public void testStartsWithAny01()
{
Assert.assertTrue(StringsUtils.startsWithAny("abc", new StringList("aaa", "bb", "ab")));
Assert.assertFalse(StringsUtils.startsWithAny("abc", new StringList("aaa", "bb", "aB")));
}
/**
* Test contains any ignore case 01.
*/
@Test
public void testStartsWithAnyIgnoreCatse01()
{
Assert.assertTrue(StringsUtils.startsWithAnyIgnoreCase("abc", new StringList("aa", "bb", "ab")));
Assert.assertTrue(StringsUtils.startsWithAnyIgnoreCase("abc", new StringList("aa", "bb", "aB")));
Assert.assertFalse(StringsUtils.startsWithAnyIgnoreCase("abc", new StringList("aa", "bb", "cc")));
}
}

View file

@ -1,4 +0,0 @@
un
deux
trois
quatre

View file

@ -0,0 +1,649 @@
/*
* Copyright (C) 2013,2014,2017 Christian Pierre MOMON
*
* This file is part of Devinsy-strings.
*
* Devinsy-strings is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Devinsy-strings 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/>
*/
package fr.devinsy.util.strings;
import java.util.Iterator;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* The Class StringListTest.
*
* @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/
public class StringListTest
{
public final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(StringListTest.class);
/**
* Before.
*/
@Before
public void before()
{
BasicConfigurator.configure();
Logger.getRootLogger().setLevel(Level.ERROR);
}
/**
* Test char at 01.
*/
@Test
public void testCharAt01()
{
//
this.logger.debug("===== test starting...");
//
StringList source = new StringList();
source.append("abcdefghijklm");
//
char target = source.charAt(0);
Assert.assertEquals(target, 'a');
//
target = source.charAt(4);
Assert.assertEquals(target, 'e');
//
target = source.charAt(11);
Assert.assertEquals(target, 'l');
//
this.logger.debug("===== test done.");
}
/**
* Test char at 02.
*/
@Test
public void testCharAt02()
{
//
this.logger.debug("===== test starting...");
//
StringList source = new StringList();
source.append("abc");
source.append("def");
source.append("ghi");
source.append("jkl");
source.append("mno");
//
char target = source.charAt(0);
Assert.assertEquals('a', target);
//
target = source.charAt(4);
Assert.assertEquals('e', target);
//
target = source.charAt(11);
Assert.assertEquals('l', target);
//
this.logger.debug("===== test done.");
}
/**
* Test char at exception 01.
*/
@Test(expected = IndexOutOfBoundsException.class)
public void testCharAtException01()
{
//
this.logger.debug("===== test starting...");
//
StringList source = new StringList();
source.append("abcdefghijklm");
//
char target = source.charAt(-2);
Assert.assertEquals('a', target);
//
this.logger.debug("===== test done.");
}
/**
* Test char at exception 02.
*/
@Test(expected = IndexOutOfBoundsException.class)
public void testCharAtException02()
{
//
this.logger.debug("===== test starting...");
//
StringList source = new StringList();
source.append("abcdefghijklm");
//
char target = source.charAt(100);
Assert.assertEquals('a', target);
//
this.logger.debug("===== test done.");
}
/**
* Test char at exception 03.
*/
@Test(expected = IndexOutOfBoundsException.class)
public void testCharAtException03()
{
//
this.logger.debug("===== test starting...");
//
StringList source = new StringList();
source.append("abcdefghijklm");
//
char target = source.charAt(source.length());
Assert.assertEquals('a', target);
//
this.logger.debug("===== test done.");
}
/**
* Test constructor 01.
*/
@Test
public void testConstructor01()
{
//
this.logger.debug("===== test starting...");
String[] source = { "a", "b", "c" };
//
StringList target = new StringList(source);
Assert.assertEquals(3, target.size());
//
this.logger.debug("===== test done.");
}
/**
* Test constructor 02.
*/
@Test
public void testConstructor02()
{
//
this.logger.debug("===== test starting...");
//
StringList target = new StringList("a", "b", "c");
Assert.assertEquals(3, target.size());
//
this.logger.debug("===== test done.");
}
/**
* Test contains 01.
*/
@Test
public void testContains01()
{
//
this.logger.debug("===== test starting...");
StringList buffer = new StringList();
buffer.append("abc");
buffer.append("def");
buffer.append("ghi");
Assert.assertTrue(buffer.contains("abc"));
Assert.assertTrue(buffer.contains("def"));
Assert.assertTrue(buffer.contains("ghi"));
Assert.assertFalse(buffer.contains("lmn"));
//
this.logger.debug("===== test done.");
}
/**
* Test contains 02.
*/
@Test
public void testContains02()
{
//
this.logger.debug("===== test starting...");
StringList buffer = new StringList();
buffer.append("abc");
buffer.append("def");
buffer.append("ghi");
Assert.assertTrue(buffer.contains(new StringBuffer().append("abc").toString()));
Assert.assertTrue(buffer.contains(new StringBuffer().append("def")));
Assert.assertTrue(buffer.contains(new StringBuffer().append("ghi")));
Assert.assertFalse(buffer.contains(new StringBuffer().append("lmn")));
//
this.logger.debug("===== test done.");
}
/**
* Test contains 02.
*/
@Test
public void testContains03()
{
//
this.logger.debug("===== test starting...");
StringList buffer = new StringList();
buffer.append("abc");
buffer.append("def");
buffer.append("ghi");
Assert.assertTrue(buffer.contains(new StringList().append("abc")));
Assert.assertTrue(buffer.contains(new StringList().append("def")));
Assert.assertTrue(buffer.contains(new StringList().append("ghi")));
Assert.assertFalse(buffer.contains(new StringList().append("lmn")));
//
this.logger.debug("===== test done.");
}
/**
* Test contains any 01.
*/
@Test
public void testContainsAny01()
{
//
this.logger.debug("===== test starting...");
StringList buffer = new StringList();
buffer.append("abc");
buffer.append("def");
buffer.append("ghi");
Assert.assertTrue(buffer.containsAny("abc"));
Assert.assertTrue(buffer.containsAny("def"));
Assert.assertTrue(buffer.containsAny("ghi"));
Assert.assertFalse(buffer.containsAny("aaa"));
//
this.logger.debug("===== test done.");
}
/**
* Test contains any 02.
*/
@Test
public void testContainsAny02()
{
//
this.logger.debug("===== test starting...");
StringList buffer = new StringList();
buffer.append("abc");
buffer.append("def");
buffer.append("ghi");
Assert.assertTrue(buffer.containsAny("aaa", "bbb", "abc"));
Assert.assertTrue(buffer.containsAny("aaa", "bbb", "def"));
Assert.assertTrue(buffer.containsAny("aaa", "bbb", "ghi"));
Assert.assertFalse(buffer.containsAny("aaa", "bbb", "ccc"));
//
this.logger.debug("===== test done.");
}
/**
* Test contains any 03.
*/
@Test
public void testContainsAny03()
{
//
this.logger.debug("===== test starting...");
StringList buffer = new StringList();
buffer.append("abc");
buffer.append("def");
buffer.append("ghi");
Assert.assertTrue(buffer.containsAny(new StringList("aaa", "bbb", "abc")));
Assert.assertTrue(buffer.containsAny(new StringList("aaa", "bbb", "def")));
Assert.assertTrue(buffer.containsAny(new StringList("aaa", "bbb", "ghi")));
Assert.assertFalse(buffer.containsAny(new StringList("aaa", "bbb", "aBc")));
Assert.assertFalse(buffer.containsAny(new StringList("aaa", "bbb", "ccc")));
//
this.logger.debug("===== test done.");
}
/**
* Test contains any 01.
*/
@Test
public void testContainsAnyIgnoreCase01()
{
//
this.logger.debug("===== test starting...");
StringList buffer = new StringList();
buffer.append("abc");
buffer.append("def");
buffer.append("ghi");
Assert.assertTrue(buffer.containsAnyIgnoreCase("aaa", "bbb", "abc"));
Assert.assertTrue(buffer.containsAnyIgnoreCase("aaa", "bbb", "dbf"));
Assert.assertTrue(buffer.containsAnyIgnoreCase("aaa", "bbb", "ghi"));
Assert.assertTrue(buffer.containsAnyIgnoreCase("aaa", "bbb", "Abc"));
Assert.assertTrue(buffer.containsAnyIgnoreCase("aaa", "bbb", "dEf"));
Assert.assertTrue(buffer.containsAnyIgnoreCase("aaa", "bbb", "ghI"));
Assert.assertFalse(buffer.containsAnyIgnoreCase("aaa", "bbb", "ccc"));
//
this.logger.debug("===== test done.");
}
/**
* Test contains any ignore case 02.
*/
@Test
public void testContainsAnyIgnoreCase02()
{
//
this.logger.debug("===== test starting...");
StringList buffer = new StringList();
buffer.append("abc");
buffer.append("def");
buffer.append("ghi");
Assert.assertTrue(buffer.containsAnyIgnoreCase(new StringList("aaa", "bbb", "abc")));
Assert.assertTrue(buffer.containsAnyIgnoreCase(new StringList("aaa", "bbb", "def")));
Assert.assertTrue(buffer.containsAnyIgnoreCase(new StringList("aaa", "bbb", "ghi")));
Assert.assertTrue(buffer.containsAnyIgnoreCase(new StringList("aaa", "bbb", "Abc")));
Assert.assertTrue(buffer.containsAnyIgnoreCase(new StringList("aaa", "bbb", "dEf")));
Assert.assertTrue(buffer.containsAnyIgnoreCase(new StringList("aaa", "bbb", "ghI")));
Assert.assertFalse(buffer.containsAnyIgnoreCase(new StringList("aaa", "bbb", "ccc")));
//
this.logger.debug("===== test done.");
}
/**
* Test iterator of char 01.
*/
@Test
public void testIteratorOfChar01()
{
//
this.logger.debug("===== test starting...");
//
StringList source = new StringList();
source.append("abc");
source.append("def");
source.append("ghi");
source.append("jkl");
source.append("mno");
//
Iterator<Character> iterator = source.iteratorOfChar();
for (int index = 0; index < source.length(); index++)
{
StringListCharPosition position = ((StringListCharIterator) iterator).nextPosition();
System.out.println(index + ":" + source.charAt(index) + " " + position.getCharIndex() + " " + position.getStringIndex() + " " + position.getLocalCharIndex());
Assert.assertTrue(iterator.hasNext());
Character character = ((StringListCharIterator) iterator).next();
Assert.assertEquals(character, new Character(source.charAt(index)));
}
//
this.logger.debug("===== test done.");
}
/**
* Test shrink 01.
*/
@Test
public void testShrink01()
{
//
this.logger.debug("===== test starting...");
//
StringList source = new StringList();
Assert.assertEquals(0, source.size());
source.shrink();
Assert.assertEquals(0, source.size());
//
this.logger.debug("===== test done.");
}
/**
* Test shrink 01.
*/
@Test
public void testShrink02()
{
//
this.logger.debug("===== test starting...");
//
StringList source = new StringList();
source.append("alpha");
source.append("bravo");
source.append("charlie");
source.append("delta");
Assert.assertEquals(4, source.size());
source.shrink();
Assert.assertEquals(1, source.size());
Assert.assertEquals("alphabravocharliedelta", source.get(0));
//
this.logger.debug("===== test done.");
}
/**
* Test substring 01.
*/
@Test
public void testSubstring01()
{
//
this.logger.debug("===== test starting...");
//
StringList source = new StringList();
source.append("hamburger");
//
StringList target = source.substring(4, 8);
Assert.assertEquals("urge", target.toString());
//
this.logger.debug("===== test done.");
}
/**
* Test substring 02.
*/
@Test
public void testSubstring02()
{
//
this.logger.debug("===== test starting...");
//
StringList source = new StringList();
source.append("ham").append("bur").append("ger");
//
StringList target = source.substring(4, 8);
Assert.assertEquals("urge", target.toString());
//
this.logger.debug("===== test done.");
}
/**
* Test substring 03.
*/
@Test
public void testSubstring03()
{
//
this.logger.debug("===== test starting...");
//
StringList source = new StringList();
source.append("smiles");
//
StringList target = source.substring(1, 5);
Assert.assertEquals("mile", target.toString());
//
this.logger.debug("===== test done.");
}
/**
* Test substring 04.
*/
@Test
public void testSubstring04()
{
//
this.logger.debug("===== test starting...");
//
StringList source = new StringList();
source.append("sm").append("il").append("es");
//
StringList target = source.substring(1, 5);
Assert.assertEquals("mile", target.toString());
//
this.logger.debug("===== test done.");
}
/**
* Test to string 01.
*/
@Test
public void testToString01()
{
//
this.logger.debug("===== test starting...");
//
StringList buffer = new StringList();
String target = buffer.toString();
Assert.assertTrue(target.equals(""));
//
this.logger.debug("===== test done.");
}
/**
* Test to string 02.
*/
@Test
public void testToString02()
{
//
this.logger.debug("===== test starting...");
//
String source = "abcdefghijklm";
StringList buffer = new StringList();
buffer.append(source);
String target = buffer.toString();
Assert.assertEquals(source, target);
Assert.assertTrue(target.equals(source));
//
this.logger.debug("===== test done.");
}
/**
* Test to string 03.
*/
@Test
public void testToString03()
{
//
this.logger.debug("===== test starting...");
//
String source1 = "abcdefghijklm";
String source2 = "other stuff";
StringList buffer = new StringList();
buffer.append(source1);
buffer.append(source2);
String target = buffer.toString();
Assert.assertTrue(target.equals(source1 + source2));
//
this.logger.debug("===== test done.");
}
}

View file

@ -0,0 +1,227 @@
/*
* Copyright (C) 2013,2014,2017 Christian Pierre MOMON
*
* This file is part of Devinsy-strings.
*
* Devinsy-strings is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Devinsy-strings 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/>
*/
package fr.devinsy.util.strings;
import java.util.ArrayList;
import java.util.Collection;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* The Class StringsUtilsTest.
*
* @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/
public class StringsUtilsTest
{
public final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(StringsUtilsTest.class);
/**
* Before.
*/
@Before
public void before()
{
BasicConfigurator.configure();
Logger.getRootLogger().setLevel(Level.ERROR);
}
/**
* Test contains any 01.
*/
@Test
public void testContainsAny01()
{
Assert.assertTrue(StringsUtils.containsAny("abc", "aaa", "bbb", "abc"));
Assert.assertFalse(StringsUtils.containsAny("abc", "aaa", "bbb", "aBc"));
}
/**
* Test contains any ignore case 01.
*/
@Test
public void testContainsAnyIgnoreCase01()
{
Assert.assertTrue(StringsUtils.containsAnyIgnoreCase("abc", "aaa", "bbb", "abc"));
Assert.assertTrue(StringsUtils.containsAnyIgnoreCase("abc", "aaa", "bbb", "aBc"));
Assert.assertFalse(StringsUtils.containsAnyIgnoreCase("abc", "aaa", "bbb", "ccc"));
}
/**
* Test contains blank 01.
*/
@Test
public void testContainsBlank01()
{
Assert.assertFalse(StringsUtils.containsBlank((Collection<String>) null));
Assert.assertFalse(StringsUtils.containsBlank(new StringList("aaa", "bbb", "ccc")));
Assert.assertTrue(StringsUtils.containsBlank(new StringList("aaa", null, "ccc")));
Assert.assertTrue(StringsUtils.containsBlank(new StringList("aaa", "", "ccc")));
Assert.assertTrue(StringsUtils.containsBlank(new StringList("aaa", " ", "ccc")));
}
/**
* Test contains blank 02.
*/
@Test
public void testContainsBlank02()
{
Assert.assertFalse(StringsUtils.containsBlank((String[]) null));
Assert.assertFalse(StringsUtils.containsBlank("aaa", "bbb", "ccc"));
Assert.assertTrue(StringsUtils.containsBlank("aaa", null, "ccc"));
Assert.assertTrue(StringsUtils.containsBlank("aaa", "", "ccc"));
Assert.assertTrue(StringsUtils.containsBlank("aaa", " ", "ccc"));
}
/**
* Test contains blank 03.
*/
@Test
public void testContainsBlank03()
{
Assert.assertFalse(StringsUtils.containsBlank((ArrayList<String>) null));
ArrayList<String> source = new ArrayList<String>();
source.add("aaa");
source.add("bbb");
source.add("ccc");
Assert.assertFalse(StringsUtils.containsBlank(source));
source.set(1, null);
Assert.assertTrue(StringsUtils.containsBlank(source));
source.set(1, "");
Assert.assertTrue(StringsUtils.containsBlank(source));
source.set(1, " ");
Assert.assertTrue(StringsUtils.containsBlank(source));
}
/**
* Test contains empty 01.
*/
@Test
public void testContainsEmpty01()
{
Assert.assertFalse(StringsUtils.containsEmpty((Collection<String>) null));
Assert.assertFalse(StringsUtils.containsEmpty(new StringList("aaa", "bbb", "ccc")));
Assert.assertTrue(StringsUtils.containsEmpty(new StringList("aaa", null, "ccc")));
Assert.assertTrue(StringsUtils.containsEmpty(new StringList("aaa", "", "ccc")));
}
/**
* Test contains empty 02.
*/
@Test
public void testContainsEmpty02()
{
Assert.assertFalse(StringsUtils.containsEmpty((String[]) null));
Assert.assertFalse(StringsUtils.containsEmpty("aaa", "bbb", "ccc"));
Assert.assertTrue(StringsUtils.containsEmpty("aaa", null, "ccc"));
Assert.assertTrue(StringsUtils.containsEmpty("aaa", "", "ccc"));
}
/**
* Test contains empty 03.
*/
@Test
public void testContainsEmpty03()
{
Assert.assertFalse(StringsUtils.containsEmpty((ArrayList<String>) null));
ArrayList<String> source = new ArrayList<String>();
source.add("aaa");
source.add("bbb");
source.add("ccc");
Assert.assertFalse(StringsUtils.containsEmpty(source));
source.set(1, null);
Assert.assertTrue(StringsUtils.containsEmpty(source));
source.set(1, "");
Assert.assertTrue(StringsUtils.containsEmpty(source));
}
/**
* Test contains null 01.
*/
@Test
public void testContainsNull01()
{
Assert.assertFalse(StringsUtils.containsNull((Collection<String>) null));
Assert.assertFalse(StringsUtils.containsNull(new StringList("aaa", "bbb", "ccc")));
Assert.assertTrue(StringsUtils.containsNull(new StringList("aaa", null, "ccc")));
}
/**
* Test contains null 02.
*/
@Test
public void testContainsNull02()
{
Assert.assertFalse(StringsUtils.containsNull((String[]) null));
Assert.assertFalse(StringsUtils.containsNull("aaa", "bbb", "ccc"));
Assert.assertTrue(StringsUtils.containsNull("aaa", null, "ccc"));
}
/**
* Test contains null 03.
*/
@Test
public void testContainsNull03()
{
Assert.assertFalse(StringsUtils.containsNull((ArrayList<String>) null));
ArrayList<String> source = new ArrayList<String>();
source.add("aaa");
source.add("bbb");
source.add("ccc");
Assert.assertFalse(StringsUtils.containsNull(source));
source.set(1, null);
Assert.assertTrue(StringsUtils.containsNull(source));
}
@Test
public void testEqualsAny01()
{
Assert.assertTrue(StringsUtils.equalsAny("abc", "aaa", "bbb", "abc"));
Assert.assertFalse(StringsUtils.equalsAny("abc", "aaa", "bbb", "aBc"));
}
@Test
public void testEqualsAnyIgnoreCase01()
{
Assert.assertTrue(StringsUtils.equalsAnyIgnoreCase("abc", "aaa", "bbb", "abc"));
Assert.assertTrue(StringsUtils.equalsAnyIgnoreCase("abc", "aaa", "bbb", "aBc"));
}
/**
* Test find smallest 01.
*/
@Test
public void testFindSmallest01()
{
// TODO
Assert.assertFalse(StringsUtils.containsNull((ArrayList<String>) null));
ArrayList<String> source = new ArrayList<String>();
source.add("aaa");
source.add("bbb");
source.add("ccc");
Assert.assertFalse(StringsUtils.containsNull(source));
source.set(1, null);
Assert.assertTrue(StringsUtils.containsNull(source));
}
}