Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-04-01 05:42:25 -0500
committerEike Stepper2006-04-01 05:42:25 -0500
commit0a20df97c9f1ead9e4111af0fb35d03ab96b8c65 (patch)
treea08f77588c5df9673592be01ec7e3f4adcc5a08c /plugins/org.eclipse.net4j.util
parent1cfb240f88d8c55390b4618bfee49918b560e39e (diff)
downloadcdo-0a20df97c9f1ead9e4111af0fb35d03ab96b8c65.tar.gz
cdo-0a20df97c9f1ead9e4111af0fb35d03ab96b8c65.tar.xz
cdo-0a20df97c9f1ead9e4111af0fb35d03ab96b8c65.zip
Initial source import.committers/estepper/initial001
Diffstat (limited to 'plugins/org.eclipse.net4j.util')
-rw-r--r--plugins/org.eclipse.net4j.util/.classpath10
-rw-r--r--plugins/org.eclipse.net4j.util/.cvsignore5
-rw-r--r--plugins/org.eclipse.net4j.util/.project28
-rw-r--r--plugins/org.eclipse.net4j.util/.settings/org.eclipse.jdt.core.prefs256
-rw-r--r--plugins/org.eclipse.net4j.util/.settings/org.eclipse.jdt.ui.prefs19
-rw-r--r--plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF41
-rw-r--r--plugins/org.eclipse.net4j.util/build.properties12
-rw-r--r--plugins/org.eclipse.net4j.util/config/log4j.dtd166
-rw-r--r--plugins/org.eclipse.net4j.util/config/log4j.xml78
-rw-r--r--plugins/org.eclipse.net4j.util/epl-v10.html319
-rw-r--r--plugins/org.eclipse.net4j.util/plugin.properties2
-rw-r--r--plugins/org.eclipse.net4j.util/plugin.xml7
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Argument.java75
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Assert.java96
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/AssertionFailedError.java23
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BeanException.java53
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BeanHelper.java286
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BitHelper.java26
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/DateHelper.java168
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/DigestHelper.java89
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/IOHelper.java683
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ImplementationError.java42
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/MathHelper.java48
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Net4jException.java53
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Net4jUtilPlugin.java63
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Pair.java55
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/StringHelper.java578
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ThreadInterruptedException.java53
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/TimeOutException.java53
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/UnderlyingIOException.java53
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/AbstractPlugin.java253
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ClassLoaderFactory.java17
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/Element.java72
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ElementRegistry.java56
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExamplePlugin.java36
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExecutableElement.java46
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExtensionConfigException.java53
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExtensionParser.java182
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ListExtensionParser.java54
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/RegistryExtensionParser.java51
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ResourcesHelper.java157
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/IStateMachine.java31
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/StateMachine.java149
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/thread/DeadlockDetector.java135
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/thread/Worker.java336
45 files changed, 5068 insertions, 0 deletions
diff --git a/plugins/org.eclipse.net4j.util/.classpath b/plugins/org.eclipse.net4j.util/.classpath
new file mode 100644
index 0000000000..bdcf047b18
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/.classpath
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/"/>
+ <classpathentry kind="src" path="config"/>
+ <classpathentry exported="true" kind="lib" path="lib/commons-logging.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/log4j-1.2.9.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.net4j.util/.cvsignore b/plugins/org.eclipse.net4j.util/.cvsignore
new file mode 100644
index 0000000000..eb65b4b8f2
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/.cvsignore
@@ -0,0 +1,5 @@
+tmp
+bin
+dist
+build
+runtime
diff --git a/plugins/org.eclipse.net4j.util/.project b/plugins/org.eclipse.net4j.util/.project
new file mode 100644
index 0000000000..b52e9e4cf3
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.net4j.util</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.net4j.util/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.net4j.util/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000..bebcb41b95
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,256 @@
+#Mon Mar 13 12:05:55 CET 2006
+eclipse.preferences.version=1
+org.eclipse.jdt.core.codeComplete.argumentPrefixes=
+org.eclipse.jdt.core.codeComplete.argumentSuffixes=
+org.eclipse.jdt.core.codeComplete.fieldPrefixes=
+org.eclipse.jdt.core.codeComplete.fieldSuffixes=
+org.eclipse.jdt.core.codeComplete.localPrefixes=
+org.eclipse.jdt.core.codeComplete.localSuffixes=
+org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
+org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+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_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=2
+org.eclipse.jdt.core.formatter.blank_lines_after_package=2
+org.eclipse.jdt.core.formatter.blank_lines_before_field=1
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=2
+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_type_declarations=2
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false
+org.eclipse.jdt.core.formatter.comment.format_comments=false
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=100
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=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_at_end_of_file_if_missing=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_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
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_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
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_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_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=true
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=100
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.tabulation.char=space
+org.eclipse.jdt.core.formatter.tabulation.size=2
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
diff --git a/plugins/org.eclipse.net4j.util/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.net4j.util/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000000..6b2f797e54
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,19 @@
+#Mon Mar 13 08:16:19 CET 2006
+comment_clear_blank_lines=false
+comment_format_comments=false
+comment_format_header=false
+comment_format_html=true
+comment_format_source_code=true
+comment_indent_parameter_description=true
+comment_indent_root_tags=true
+comment_line_length=100
+comment_new_line_for_parameter=true
+comment_separate_root_tags=true
+eclipse.preferences.version=1
+formatter_settings_version=10
+org.eclipse.jdt.ui.exception.name=ex
+org.eclipse.jdt.ui.gettersetter.use.is=true
+org.eclipse.jdt.ui.ignorelowercasenames=true
+org.eclipse.jdt.ui.importorder=org.eclipse.net4j;org.eclipse.emf;org.eclipse;org.apache;org;com;java.lang;java.util;java.io;java.nio;java.net;java;javax;
+org.eclipse.jdt.ui.keywordthis=false
+org.eclipse.jdt.ui.ondemandthreshold=99
diff --git a/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..2fa6dc2816
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF
@@ -0,0 +1,41 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.net4j.util
+Bundle-Version: 1.0.0
+Bundle-ClassPath: net4j.util.jar,
+ lib/commons-logging.jar,
+ lib/log4j-1.2.9.jar
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Export-Package: META-INF,
+ org.apache.commons.logging,
+ org.apache.commons.logging.impl,
+ org.apache.log4j,
+ org.apache.log4j.chainsaw,
+ org.apache.log4j.config,
+ org.apache.log4j.helpers,
+ org.apache.log4j.jdbc,
+ org.apache.log4j.jmx,
+ org.apache.log4j.lf5,
+ org.apache.log4j.lf5.config,
+ org.apache.log4j.lf5.util,
+ org.apache.log4j.lf5.viewer,
+ org.apache.log4j.lf5.viewer.categoryexplorer,
+ org.apache.log4j.lf5.viewer.configure,
+ org.apache.log4j.lf5.viewer.images,
+ org.apache.log4j.net,
+ org.apache.log4j.nt,
+ org.apache.log4j.or,
+ org.apache.log4j.or.sax,
+ org.apache.log4j.spi,
+ org.apache.log4j.varia,
+ org.apache.log4j.xml,
+ org.eclipse.net4j.util,
+ org.eclipse.net4j.util.eclipse,
+ org.eclipse.net4j.util.fsm,
+ org.eclipse.net4j.util.thread
+Require-Bundle: org.eclipse.core.runtime;visibility:=reexport,
+ org.eclipse.core.resources;visibility:=reexport
+Eclipse-LazyStart: true
+Bundle-Activator: org.eclipse.net4j.util.Net4jUtilPlugin
diff --git a/plugins/org.eclipse.net4j.util/build.properties b/plugins/org.eclipse.net4j.util/build.properties
new file mode 100644
index 0000000000..d2f1a67244
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/build.properties
@@ -0,0 +1,12 @@
+src.includes = src/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ config/,\
+ plugin.properties,\
+ net4j.util.jar,\
+ lib/,\
+ epl-v10.html
+jars.compile.order = net4j.util.jar
+source.net4j.util.jar = src/,\
+ config/
+output.net4j.util.jar = bin/
diff --git a/plugins/org.eclipse.net4j.util/config/log4j.dtd b/plugins/org.eclipse.net4j.util/config/log4j.dtd
new file mode 100644
index 0000000000..d92a6e7bc6
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/config/log4j.dtd
@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!-- Authors: Chris Taylor, Ceki Gulcu. -->
+
+<!-- Version: 1.2 -->
+
+<!-- A configuration element consists of optional renderer
+elements,appender elements, categories and an optional root
+element. -->
+
+<!ELEMENT log4j:configuration (renderer*, appender*,(category|logger)*,root?,
+ categoryFactory?)>
+
+<!-- The "threshold" attribute takes a level value such that all -->
+<!-- logging statements with a level equal or below this value are -->
+<!-- disabled. -->
+
+<!-- Setting the "debug" enable the printing of internal log4j logging -->
+<!-- statements. -->
+
+<!-- By default, debug attribute is "null", meaning that we not do touch -->
+<!-- internal log4j logging settings. The "null" value for the threshold -->
+<!-- attribute can be misleading. The threshold field of a repository -->
+<!-- cannot be set to null. The "null" value for the threshold attribute -->
+<!-- simply means don't touch the threshold field, the threshold field -->
+<!-- keeps its old value. -->
+
+<!ATTLIST log4j:configuration
+ xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/"
+ threshold (all|debug|info|warn|error|fatal|off|null) "null"
+ debug (true|false|null) "null"
+>
+
+<!-- renderer elements allow the user to customize the conversion of -->
+<!-- message objects to String. -->
+
+<!ELEMENT renderer EMPTY>
+<!ATTLIST renderer
+ renderedClass CDATA #REQUIRED
+ renderingClass CDATA #REQUIRED
+>
+
+<!-- Appenders must have a name and a class. -->
+<!-- Appenders may contain an error handler, a layout, optional parameters -->
+<!-- and filters. They may also reference (or include) other appenders. -->
+<!ELEMENT appender (errorHandler?, param*, layout?, filter*, appender-ref*)>
+<!ATTLIST appender
+ name ID #REQUIRED
+ class CDATA #REQUIRED
+>
+
+<!ELEMENT layout (param*)>
+<!ATTLIST layout
+ class CDATA #REQUIRED
+>
+
+<!ELEMENT filter (param*)>
+<!ATTLIST filter
+ class CDATA #REQUIRED
+>
+
+<!-- ErrorHandlers can be of any class. They can admit any number of -->
+<!-- parameters. -->
+
+<!ELEMENT errorHandler (param*, root-ref?, logger-ref*, appender-ref?)>
+<!ATTLIST errorHandler
+ class CDATA #REQUIRED
+>
+
+<!ELEMENT root-ref EMPTY>
+
+<!ELEMENT logger-ref EMPTY>
+<!ATTLIST logger-ref
+ ref IDREF #REQUIRED
+>
+
+<!ELEMENT param EMPTY>
+<!ATTLIST param
+ name CDATA #REQUIRED
+ value CDATA #REQUIRED
+>
+
+
+<!-- The priority class is org.apache.log4j.Level by default -->
+<!ELEMENT priority (param*)>
+<!ATTLIST priority
+ class CDATA #IMPLIED
+ value CDATA #REQUIRED
+>
+
+<!-- The level class is org.apache.log4j.Level by default -->
+<!ELEMENT level (param*)>
+<!ATTLIST level
+ class CDATA #IMPLIED
+ value CDATA #REQUIRED
+>
+
+
+<!-- If no level element is specified, then the configurator MUST not -->
+<!-- touch the level of the named category. -->
+<!ELEMENT category (param*,(priority|level)?,appender-ref*)>
+<!ATTLIST category
+ class CDATA #IMPLIED
+ name CDATA #REQUIRED
+ additivity (true|false) "true"
+>
+
+<!-- If no level element is specified, then the configurator MUST not -->
+<!-- touch the level of the named logger. -->
+<!ELEMENT logger (level?,appender-ref*)>
+<!ATTLIST logger
+ name ID #REQUIRED
+ additivity (true|false) "true"
+>
+
+
+<!ELEMENT categoryFactory (param*)>
+<!ATTLIST categoryFactory
+ class CDATA #REQUIRED>
+
+<!ELEMENT appender-ref EMPTY>
+<!ATTLIST appender-ref
+ ref IDREF #REQUIRED
+>
+
+<!-- If no priority element is specified, then the configurator MUST not -->
+<!-- touch the priority of root. -->
+<!-- The root category always exists and cannot be subclassed. -->
+<!ELEMENT root (param*, (priority|level)?, appender-ref*)>
+
+
+<!-- ==================================================================== -->
+<!-- A logging event -->
+<!-- ==================================================================== -->
+<!ELEMENT log4j:eventSet (log4j:event*)>
+<!ATTLIST log4j:eventSet
+ xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/"
+ version (1.1|1.2) "1.2"
+ includesLocationInfo (true|false) "true"
+>
+
+
+
+<!ELEMENT log4j:event (log4j:message, log4j:NDC?, log4j:throwable?,
+ log4j:locationInfo?) >
+
+<!-- The timestamp format is application dependent. -->
+<!ATTLIST log4j:event
+ logger CDATA #REQUIRED
+ level CDATA #REQUIRED
+ thread CDATA #REQUIRED
+ timestamp CDATA #REQUIRED
+>
+
+<!ELEMENT log4j:message (#PCDATA)>
+<!ELEMENT log4j:NDC (#PCDATA)>
+
+<!ELEMENT log4j:throwable (#PCDATA)>
+
+<!ELEMENT log4j:locationInfo EMPTY>
+<!ATTLIST log4j:locationInfo
+ class CDATA #REQUIRED
+ method CDATA #REQUIRED
+ file CDATA #REQUIRED
+ line CDATA #REQUIRED
+>
diff --git a/plugins/org.eclipse.net4j.util/config/log4j.xml b/plugins/org.eclipse.net4j.util/config/log4j.xml
new file mode 100644
index 0000000000..8298e6844b
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/config/log4j.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "../../org.eclipse.net4j.util/config/log4j.dtd">
+<log4j:configuration debug="false" xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <appender name="LOGFACTOR" class="org.apache.log4j.lf5.LF5Appender">
+ <param name="MaxNumberOfRecords" value="1000"/>
+ </appender>
+
+ <appender name="GANYMEDE" class="org.apache.log4j.net.SocketAppender">
+ <param name="RemoteHost" value="localhost"/>
+ <param name="Port" value="4445"/>
+ <param name="LocationInfo" value="true"/>
+ </appender>
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%p] %c: %m%n"/>
+ </layout>
+ </appender>
+
+ <appender name="FILE" class="org.apache.log4j.FileAppender">
+ <param name="File" value="densityd.log"/>
+ <param name="Append" value="false"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%p] %c: %m%n"/>
+ </layout>
+ </appender>
+
+ <category name="org.eclipse.net4j.spring.impl.ContainerImpl">
+ <priority value="warn"/>
+ </category>
+
+ <category name="org.eclipse.net4j.util.fsm.StateMachine">
+ <priority value="warn"/>
+ </category>
+
+ <category name="org.eclipse.net4j.core.impl.ChannelImpl$ClientStateMachine">
+ <priority value="warn"/>
+ </category>
+
+ <category name="org.eclipse.net4j.core.impl.ChannelImpl$ServerStateMachine">
+ <priority value="warn"/>
+ </category>
+
+ <category name="org.springframework">
+ <priority value="warn"/>
+ </category>
+
+ <category name="org.springframework.jdbc">
+ <priority value="error"/>
+ </category>
+
+ <category name="density.bufferPool">
+ <priority value="warn"/>
+ </category>
+
+ <category name="density.connectionManager">
+ <priority value="debug"/>
+ </category>
+
+ <category name="density.executorPool">
+ <priority value="warn"/>
+ </category>
+
+ <category name="density.multiplexer">
+ <priority value="warn"/>
+ </category>
+
+ <root>
+ <priority value="debug"/>
+ <!--
+ <appender-ref ref="LOGFACTOR" />
+ <appender-ref ref="FILE"/>
+ -->
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</log4j:configuration>
diff --git a/plugins/org.eclipse.net4j.util/epl-v10.html b/plugins/org.eclipse.net4j.util/epl-v10.html
new file mode 100644
index 0000000000..d7b88e9416
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/epl-v10.html
@@ -0,0 +1,319 @@
+<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head>
+<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
+<meta name="ProgId" content="Word.Document">
+<meta name="Generator" content="Microsoft Word 9">
+<meta name="Originator" content="Microsoft Word 9">
+<link rel="File-List" href="http://www.eclipse.org/org/documents/Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml"><title>Eclipse Public License - Version 1.0</title><!--[if gte mso 9]><xml>
+ <o:DocumentProperties>
+ <o:Revision>2</o:Revision>
+ <o:TotalTime>3</o:TotalTime>
+ <o:Created>2004-03-05T23:03:00Z</o:Created>
+ <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
+ <o:Pages>4</o:Pages>
+ <o:Words>1626</o:Words>
+ <o:Characters>9270</o:Characters>
+ <o:Lines>77</o:Lines>
+ <o:Paragraphs>18</o:Paragraphs>
+ <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
+ <o:Version>9.4402</o:Version>
+ </o:DocumentProperties>
+</xml><![endif]--><!--[if gte mso 9]><xml>
+ <w:WordDocument>
+ <w:TrackRevisions/>
+ </w:WordDocument>
+</xml><![endif]-->
+
+
+<style>
+<!--
+ /* Font Definitions */
+@font-face
+ {font-family:Tahoma;
+ panose-1:2 11 6 4 3 5 4 4 2 4;
+ mso-font-charset:0;
+ mso-generic-font-family:swiss;
+ mso-font-pitch:variable;
+ mso-font-signature:553679495 -2147483648 8 0 66047 0;}
+ /* Style Definitions */
+p.MsoNormal, li.MsoNormal, div.MsoNormal
+ {mso-style-parent:"";
+ margin:0in;
+ margin-bottom:.0001pt;
+ mso-pagination:widow-orphan;
+ font-size:12.0pt;
+ font-family:"Times New Roman";
+ mso-fareast-font-family:"Times New Roman";}
+p
+ {margin-right:0in;
+ mso-margin-top-alt:auto;
+ mso-margin-bottom-alt:auto;
+ margin-left:0in;
+ mso-pagination:widow-orphan;
+ font-size:12.0pt;
+ font-family:"Times New Roman";
+ mso-fareast-font-family:"Times New Roman";}
+p.BalloonText, li.BalloonText, div.BalloonText
+ {mso-style-name:"Balloon Text";
+ margin:0in;
+ margin-bottom:.0001pt;
+ mso-pagination:widow-orphan;
+ font-size:8.0pt;
+ font-family:Tahoma;
+ mso-fareast-font-family:"Times New Roman";}
+@page Section1
+ {size:8.5in 11.0in;
+ margin:1.0in 1.25in 1.0in 1.25in;
+ mso-header-margin:.5in;
+ mso-footer-margin:.5in;
+ mso-paper-source:0;}
+div.Section1
+ {page:Section1;}
+-->
+</style></head>
+
+<body style="" lang="EN-US">
+
+<div class="Section1">
+
+<p style="text-align: center;" align="center"><b>Eclipse Public License - v 1.0</b>
+</p>
+
+<p><span style="font-size: 10pt;">THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
+THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE,
+REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
+OF THIS AGREEMENT.</span> </p>
+
+<p><b><span style="font-size: 10pt;">1. DEFINITIONS</span></b> </p>
+
+<p><span style="font-size: 10pt;">"Contribution" means:</span> </p>
+
+<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a)
+in the case of the initial Contributor, the initial code and documentation
+distributed under this Agreement, and<br clear="left">
+b) in the case of each subsequent Contributor:</span></p>
+
+<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">i)
+changes to the Program, and</span></p>
+
+<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">ii)
+additions to the Program;</span></p>
+
+<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">where
+such changes and/or additions to the Program originate from and are distributed
+by that particular Contributor. A Contribution 'originates' from a Contributor
+if it was added to the Program by such Contributor itself or anyone acting on
+such Contributor's behalf. Contributions do not include additions to the
+Program which: (i) are separate modules of software distributed in conjunction
+with the Program under their own license agreement, and (ii) are not derivative
+works of the Program. </span></p>
+
+<p><span style="font-size: 10pt;">"Contributor" means any person or
+entity that distributes the Program.</span> </p>
+
+<p><span style="font-size: 10pt;">"Licensed Patents " mean patent
+claims licensable by a Contributor which are necessarily infringed by the use
+or sale of its Contribution alone or when combined with the Program. </span></p>
+
+<p><span style="font-size: 10pt;">"Program" means the Contributions
+distributed in accordance with this Agreement.</span> </p>
+
+<p><span style="font-size: 10pt;">"Recipient" means anyone who
+receives the Program under this Agreement, including all Contributors.</span> </p>
+
+<p><b><span style="font-size: 10pt;">2. GRANT OF RIGHTS</span></b> </p>
+
+<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a)
+Subject to the terms of this Agreement, each Contributor hereby grants Recipient
+a non-exclusive, worldwide, royalty-free copyright license to<span style="color: red;"> </span>reproduce, prepare derivative works of, publicly
+display, publicly perform, distribute and sublicense the Contribution of such
+Contributor, if any, and such derivative works, in source code and object code
+form.</span></p>
+
+<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b)
+Subject to the terms of this Agreement, each Contributor hereby grants
+Recipient a non-exclusive, worldwide,<span style="color: green;"> </span>royalty-free
+patent license under Licensed Patents to make, use, sell, offer to sell, import
+and otherwise transfer the Contribution of such Contributor, if any, in source
+code and object code form. This patent license shall apply to the combination
+of the Contribution and the Program if, at the time the Contribution is added
+by the Contributor, such addition of the Contribution causes such combination
+to be covered by the Licensed Patents. The patent license shall not apply to
+any other combinations which include the Contribution. No hardware per se is
+licensed hereunder. </span></p>
+
+<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">c)
+Recipient understands that although each Contributor grants the licenses to its
+Contributions set forth herein, no assurances are provided by any Contributor
+that the Program does not infringe the patent or other intellectual property
+rights of any other entity. Each Contributor disclaims any liability to Recipient
+for claims brought by any other entity based on infringement of intellectual
+property rights or otherwise. As a condition to exercising the rights and
+licenses granted hereunder, each Recipient hereby assumes sole responsibility
+to secure any other intellectual property rights needed, if any. For example,
+if a third party patent license is required to allow Recipient to distribute
+the Program, it is Recipient's responsibility to acquire that license before
+distributing the Program.</span></p>
+
+<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">d)
+Each Contributor represents that to its knowledge it has sufficient copyright
+rights in its Contribution, if any, to grant the copyright license set forth in
+this Agreement. </span></p>
+
+<p><b><span style="font-size: 10pt;">3. REQUIREMENTS</span></b> </p>
+
+<p><span style="font-size: 10pt;">A Contributor may choose to distribute the
+Program in object code form under its own license agreement, provided that:</span>
+</p>
+
+<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a)
+it complies with the terms and conditions of this Agreement; and</span></p>
+
+<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b)
+its license agreement:</span></p>
+
+<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">i)
+effectively disclaims on behalf of all Contributors all warranties and
+conditions, express and implied, including warranties or conditions of title
+and non-infringement, and implied warranties or conditions of merchantability
+and fitness for a particular purpose; </span></p>
+
+<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">ii)
+effectively excludes on behalf of all Contributors all liability for damages,
+including direct, indirect, special, incidental and consequential damages, such
+as lost profits; </span></p>
+
+<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">iii)
+states that any provisions which differ from this Agreement are offered by that
+Contributor alone and not by any other party; and</span></p>
+
+<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">iv)
+states that source code for the Program is available from such Contributor, and
+informs licensees how to obtain it in a reasonable manner on or through a
+medium customarily used for software exchange.<span style="color: blue;"> </span></span></p>
+
+<p><span style="font-size: 10pt;">When the Program is made available in source
+code form:</span> </p>
+
+<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a)
+it must be made available under this Agreement; and </span></p>
+
+<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) a
+copy of this Agreement must be included with each copy of the Program. </span></p>
+
+<p><span style="font-size: 10pt;">Contributors may not remove or alter any
+copyright notices contained within the Program. </span></p>
+
+<p><span style="font-size: 10pt;">Each Contributor must identify itself as the
+originator of its Contribution, if any, in a manner that reasonably allows
+subsequent Recipients to identify the originator of the Contribution. </span></p>
+
+<p><b><span style="font-size: 10pt;">4. COMMERCIAL DISTRIBUTION</span></b> </p>
+
+<p><span style="font-size: 10pt;">Commercial distributors of software may
+accept certain responsibilities with respect to end users, business partners
+and the like. While this license is intended to facilitate the commercial use
+of the Program, the Contributor who includes the Program in a commercial
+product offering should do so in a manner which does not create potential
+liability for other Contributors. Therefore, if a Contributor includes the
+Program in a commercial product offering, such Contributor ("Commercial
+Contributor") hereby agrees to defend and indemnify every other
+Contributor ("Indemnified Contributor") against any losses, damages and
+costs (collectively "Losses") arising from claims, lawsuits and other
+legal actions brought by a third party against the Indemnified Contributor to
+the extent caused by the acts or omissions of such Commercial Contributor in
+connection with its distribution of the Program in a commercial product
+offering. The obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In order
+to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
+Contributor in writing of such claim, and b) allow the Commercial Contributor
+to control, and cooperate with the Commercial Contributor in, the defense and
+any related settlement negotiations. The Indemnified Contributor may participate
+in any such claim at its own expense.</span> </p>
+
+<p><span style="font-size: 10pt;">For example, a Contributor might include the
+Program in a commercial product offering, Product X. That Contributor is then a
+Commercial Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance claims and
+warranties are such Commercial Contributor's responsibility alone. Under this
+section, the Commercial Contributor would have to defend claims against the
+other Contributors related to those performance claims and warranties, and if a
+court requires any other Contributor to pay any damages as a result, the
+Commercial Contributor must pay those damages.</span> </p>
+
+<p><b><span style="font-size: 10pt;">5. NO WARRANTY</span></b> </p>
+
+<p><span style="font-size: 10pt;">EXCEPT AS EXPRESSLY SET FORTH IN THIS
+AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
+WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and distributing the
+Program and assumes all risks associated with its exercise of rights under this
+Agreement , including but not limited to the risks and costs of program errors,
+compliance with applicable laws, damage to or loss of data, programs or
+equipment, and unavailability or interruption of operations. </span></p>
+
+<p><b><span style="font-size: 10pt;">6. DISCLAIMER OF LIABILITY</span></b> </p>
+
+<p><span style="font-size: 10pt;">EXCEPT AS EXPRESSLY SET FORTH IN THIS
+AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
+THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
+
+<p><b><span style="font-size: 10pt;">7. GENERAL</span></b> </p>
+
+<p><span style="font-size: 10pt;">If any provision of this Agreement is invalid
+or unenforceable under applicable law, it shall not affect the validity or
+enforceability of the remainder of the terms of this Agreement, and without
+further action by the parties hereto, such provision shall be reformed to the
+minimum extent necessary to make such provision valid and enforceable.</span> </p>
+
+<p><span style="font-size: 10pt;">If Recipient institutes patent litigation
+against any entity (including a cross-claim or counterclaim in a lawsuit)
+alleging that the Program itself (excluding combinations of the Program with
+other software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of the date
+such litigation is filed. </span></p>
+
+<p><span style="font-size: 10pt;">All Recipient's rights under this Agreement
+shall terminate if it fails to comply with any of the material terms or
+conditions of this Agreement and does not cure such failure in a reasonable
+period of time after becoming aware of such noncompliance. If all Recipient's
+rights under this Agreement terminate, Recipient agrees to cease use and
+distribution of the Program as soon as reasonably practicable. However,
+Recipient's obligations under this Agreement and any licenses granted by
+Recipient relating to the Program shall continue and survive. </span></p>
+
+<p><span style="font-size: 10pt;">Everyone is permitted to copy and distribute
+copies of this Agreement, but in order to avoid inconsistency the Agreement is
+copyrighted and may only be modified in the following manner. The Agreement
+Steward reserves the right to publish new versions (including revisions) of
+this Agreement from time to time. No one other than the Agreement Steward has
+the right to modify this Agreement. The Eclipse Foundation is the initial
+Agreement Steward. The Eclipse Foundation may assign the responsibility to
+serve as the Agreement Steward to a suitable separate entity. Each new version
+of the Agreement will be given a distinguishing version number. The Program
+(including Contributions) may always be distributed subject to the version of
+the Agreement under which it was received. In addition, after a new version of
+the Agreement is published, Contributor may elect to distribute the Program
+(including its Contributions) under the new version. Except as expressly stated
+in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
+the intellectual property of any Contributor under this Agreement, whether
+expressly, by implication, estoppel or otherwise. All rights in the Program not
+expressly granted under this Agreement are reserved.</span> </p>
+
+<p><span style="font-size: 10pt;">This Agreement is governed by the laws of the
+State of New York and the intellectual property laws of the United States of
+America. No party to this Agreement will bring a legal action under this
+Agreement more than one year after the cause of action arose. Each party waives
+its rights to a jury trial in any resulting litigation.</span> </p>
+
+<p class="MsoNormal"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></p>
+
+</div>
+
+</body></html> \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/plugin.properties b/plugins/org.eclipse.net4j.util/plugin.properties
new file mode 100644
index 0000000000..8fb336abda
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/plugin.properties
@@ -0,0 +1,2 @@
+pluginName = Net4j Utilities
+providerName = Eclipse.org
diff --git a/plugins/org.eclipse.net4j.util/plugin.xml b/plugins/org.eclipse.net4j.util/plugin.xml
new file mode 100644
index 0000000000..635a28e0c6
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/plugin.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<plugin>
+
+
+</plugin>
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Argument.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Argument.java
new file mode 100644
index 0000000000..d251e296e6
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Argument.java
@@ -0,0 +1,75 @@
+package org.eclipse.net4j.util;
+
+
+/**
+ * <code>Assert</code> is useful for for embedding runtime sanity checks
+ * in code.
+ * The predicate methods all test a condition and throw some
+ * type of unchecked exception if the condition does not hold.
+ * <p>
+ * Assertion failure exceptions, like most runtime exceptions, are
+ * thrown when something is misbehaving. Assertion failures are invariably
+ * unspecified behavior; consequently, clients should never rely on
+ * these being thrown (and certainly should not being catching them
+ * specifically).
+ * </p>
+ */
+public final class Argument
+{
+ /* This class is not intended to be instantiated. */
+ private Argument()
+ {
+ // not allowed
+ }
+
+ /** Asserts that the given object is not <code>null</code>. If this
+ * is not the case, some kind of unchecked exception is thrown.
+ *
+ * @param object the value to test
+ * @exception IllegalArgumentException if the object is <code>null</code>
+ */
+ public static void isNotNull(Object object)
+ {
+ isNotNull(object, ""); //$NON-NLS-1$
+ }
+
+ /** Asserts that the given object is not <code>null</code>. If this
+ * is not the case, some kind of unchecked exception is thrown.
+ * The given message is included in that exception, to aid debugging.
+ *
+ * @param object the value to test
+ * @param message the message to include in the exception
+ * @exception IllegalArgumentException if the object is <code>null</code>
+ */
+ public static void isNotNull(Object object, String message)
+ {
+ if (object == null) throw new IllegalArgumentException("null argument:" + message); //$NON-NLS-1$
+ }
+
+ /** Asserts that the given boolean is <code>true</code>. If this
+ * is not the case, some kind of unchecked exception is thrown.
+ *
+ * @param expression the outcode of the check
+ * @return <code>true</code> if the check passes (does not return
+ * if the check fails)
+ */
+ public static boolean isTrue(boolean expression)
+ {
+ return isTrue(expression, ""); //$NON-NLS-1$
+ }
+
+ /** Asserts that the given boolean is <code>true</code>. If this
+ * is not the case, some kind of unchecked exception is thrown.
+ * The given message is included in that exception, to aid debugging.
+ *
+ * @param expression the outcode of the check
+ * @param message the message to include in the exception
+ * @return <code>true</code> if the check passes (does not return
+ * if the check fails)
+ */
+ public static boolean isTrue(boolean expression, String message)
+ {
+ if (!expression) throw new IllegalArgumentException("assertion failed: " + message); //$NON-NLS-1$
+ return expression;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Assert.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Assert.java
new file mode 100644
index 0000000000..b389e83463
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Assert.java
@@ -0,0 +1,96 @@
+package org.eclipse.net4j.util;
+
+
+/**
+ * <code>Assert</code> is useful for for embedding runtime sanity checks
+ * in code.
+ * The predicate methods all test a condition and throw some
+ * type of unchecked exception if the condition does not hold.
+ * <p>
+ * Assertion failure exceptions, like most runtime exceptions, are
+ * thrown when something is misbehaving. Assertion failures are invariably
+ * unspecified behavior; consequently, clients should never rely on
+ * these being thrown (and certainly should not being catching them
+ * specifically).
+ * </p>
+ */
+public final class Assert
+{
+ /* This class is not intended to be instantiated. */
+ private Assert()
+ {
+ // not allowed
+ }
+
+ /** Asserts that the given object is not <code>null</code>. If this
+ * is not the case, some kind of unchecked exception is thrown.
+ *
+ * @param object the value to test
+ * @exception IllegalArgumentException if the object is <code>null</code>
+ */
+ public static void isNotNull(Object object)
+ {
+ isNotNull(object, ""); //$NON-NLS-1$
+ }
+
+ /** Asserts that the given object is not <code>null</code>. If this
+ * is not the case, some kind of unchecked exception is thrown.
+ * The given message is included in that exception, to aid debugging.
+ *
+ * @param object the value to test
+ * @param message the message to include in the exception
+ * @exception IllegalArgumentException if the object is <code>null</code>
+ */
+ public static void isNotNull(Object object, String message)
+ {
+ if (object == null)
+ {
+ String txt = "null argument:" + message; //$NON-NLS-1$
+ System.out.println(txt);
+ throw new AssertionFailedError(txt);
+ }
+ }
+
+ /** Asserts that the given boolean is <code>true</code>. If this
+ * is not the case, some kind of unchecked exception is thrown.
+ *
+ * @param expression the outcode of the check
+ * @return <code>true</code> if the check passes (does not return
+ * if the check fails)
+ */
+ public static boolean isTrue(boolean expression)
+ {
+ return isTrue(expression, ""); //$NON-NLS-1$
+ }
+
+ /** Asserts that the given boolean is <code>true</code>. If this
+ * is not the case, some kind of unchecked exception is thrown.
+ * The given message is included in that exception, to aid debugging.
+ *
+ * @param expression the outcode of the check
+ * @param message the message to include in the exception
+ * @return <code>true</code> if the check passes (does not return
+ * if the check fails)
+ */
+ public static boolean isTrue(boolean expression, String message)
+ {
+ if (!expression)
+ {
+ String txt = "assertion failed: " + message; //$NON-NLS-1$
+ System.out.println(txt);
+ throw new AssertionFailedError(txt);
+ }
+
+ return expression;
+ }
+
+ public static boolean fail()
+ {
+ return fail(""); //$NON-NLS-1$
+ }
+
+ public static boolean fail(String message)
+ {
+ return isTrue(false, message);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/AssertionFailedError.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/AssertionFailedError.java
new file mode 100644
index 0000000000..e6ddc5af66
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/AssertionFailedError.java
@@ -0,0 +1,23 @@
+package org.eclipse.net4j.util;
+
+
+/**
+ * <code>AssertionFailedException</code> is a runtime exception thrown
+ * by some of the methods in <code>Assert</code>.
+ * <p>
+ * This class is not declared public to prevent some misuses; programs that catch
+ * or otherwise depend on assertion failures are susceptible to unexpected
+ * breakage when assertions in the code are added or removed.
+ * </p>
+ */
+class AssertionFailedError extends ImplementationError
+{
+ private static final long serialVersionUID = -1363257600902142582L;
+
+ /** Constructs a new exception with the given message.
+ */
+ public AssertionFailedError(String detail)
+ {
+ super(detail);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BeanException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BeanException.java
new file mode 100644
index 0000000000..7d05fb183f
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BeanException.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util;
+
+
+public class BeanException extends RuntimeException
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 3979274633562501681L;
+
+ /**
+ *
+ */
+ public BeanException()
+ {
+ super();
+ }
+
+ /**
+ * @param arg0
+ */
+ public BeanException(String arg0)
+ {
+ super(arg0);
+ }
+
+ /**
+ * @param arg0
+ */
+ public BeanException(Throwable arg0)
+ {
+ super(arg0);
+ }
+
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ public BeanException(String arg0, Throwable arg1)
+ {
+ super(arg0, arg1);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BeanHelper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BeanHelper.java
new file mode 100644
index 0000000000..8a75e38e94
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BeanHelper.java
@@ -0,0 +1,286 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util;
+
+
+import java.lang.reflect.Method;
+
+
+public class BeanHelper
+{
+ public static Class mostSpecificClass(Class[] classes)
+ {
+ int size = classes.length;
+
+ for (int i = 0; i < size; i++)
+ {
+ Class iClass = classes[i];
+
+ for (int k = i + 1; k < size; k++)
+ {
+ Class kClass = classes[k];
+
+ if (iClass.isAssignableFrom(kClass))
+ {
+ // iClass is super class of kClass
+ // iClass is less specific
+ classes[i] = classes[--size];
+ break;
+ }
+ else if (kClass.isAssignableFrom(iClass))
+ {
+ // kClass is super class of iClass
+ // kClass is less specific
+ classes[k] = classes[--size];
+ break;
+ }
+ }
+ }
+
+ if (size > 1)
+ {
+ throw new RuntimeException("Ambiguous ViewFacories");
+ }
+
+ if (size < 1)
+ {
+ throw new RuntimeException("No ViewFacories");
+ }
+
+ return classes[0];
+ }
+
+ public static void dispatchChild(Object object, String name, Object value)
+ {
+ Method adder = findAdder(object.getClass(), name);
+ if (adder == null) throw new BeanException("Child " + name + " not reognized");
+
+ try
+ {
+ adder.invoke(object, new Object[] { value});
+ }
+ catch (Throwable t)
+ {
+ throw new BeanException("Child " + name + " not accessible", t);
+ }
+ }
+
+ public static Object[] children(Object object, String name)
+ {
+ Method getter = findChildGetter(object.getClass(), name);
+ if (getter == null) throw new BeanException("Child " + name + " not reognized");
+
+ try
+ {
+ return (Object[]) getter.invoke(object, (Object[])null);
+ }
+ catch (Throwable t)
+ {
+ throw new BeanException("Child " + name + " not accessible", t);
+ }
+ }
+
+ public static void dispatchAttributeValue(Object object, String name, String value)
+ {
+ Method setter = findSetter(object.getClass(), name);
+ if (setter == null) throw new BeanException("Attribute " + name + " not reognized");
+
+ try
+ {
+ Class type = setter.getParameterTypes()[0];
+
+ if (type == Boolean.class)
+ {
+ Boolean bool = value == null ? null : Boolean.valueOf(value);
+ setter.invoke(object, new Object[] { bool});
+ }
+ else
+ {
+ // if (type == String)
+ setter.invoke(object, new Object[] { value});
+ }
+ }
+ catch (Throwable t)
+ {
+ throw new BeanException("Attribute " + name + " not accessible", t);
+ }
+ }
+
+ public static void dispatchAttributeValueBoolean(Object object, String name, Boolean value)
+ {
+ Method setter = findSetter(object.getClass(), name);
+ if (setter == null) throw new BeanException("Attribute " + name + " not reognized");
+ if (setter.getParameterTypes()[0] != Boolean.class)
+ throw new BeanException("Attribute " + name + " is not Boolean");
+
+ try
+ {
+ setter.invoke(object, new Object[] { value});
+ }
+ catch (Throwable t)
+ {
+ throw new BeanException("Attribute " + name + " not accessible", t);
+ }
+ }
+
+ public static String attributeValue(Object object, String name)
+ {
+ Method getter = findGetter(object.getClass(), name);
+ if (getter == null) throw new BeanException("Attribute " + name + " not reognized");
+
+ try
+ {
+ Object returnValue = getter.invoke(object, (Object[])null);
+ if (returnValue == null) return null;
+ if (returnValue instanceof String) return (String) returnValue;
+
+ //if (returnValue instanceof Boolean)
+ return ((Boolean) returnValue).toString();
+
+ }
+ catch (Throwable t)
+ {
+ throw new BeanException("Attribute " + name + " not accessible", t);
+ }
+ }
+
+ public static Boolean attributeValueBoolean(Object object, String name)
+ {
+ Method getter = findGetter(object.getClass(), name);
+ if (getter == null) throw new BeanException("Attribute " + name + " not reognized");
+ if (getter.getReturnType() != Boolean.class)
+ throw new BeanException("Attribute " + name + " is not Boolean");
+
+ try
+ {
+ return (Boolean) getter.invoke(object, (Object[])null);
+ }
+ catch (Throwable t)
+ {
+ throw new BeanException("Attribute " + name + " accessible", t);
+ }
+ }
+
+ public static Method findGetter(Class clazz, String name)
+ {
+ String accessor = "is" + capitalize(name);
+ Method method = findMethod(clazz, accessor);
+ if (validGetter(method)) return method;
+
+ accessor = "get" + capitalize(name);
+ method = findMethod(clazz, accessor);
+ if (validGetter(method)) return method;
+
+ return null;
+ }
+
+ public static Method findChildGetter(Class clazz, String name)
+ {
+ String accessor = "get" + capitalize(name) + "s";
+ Method method = findMethod(clazz, accessor);
+ if (validChildGetter(method)) return method;
+
+ return null;
+ }
+
+ public static Method findSetter(Class clazz, String name)
+ {
+ String accessor = "set" + capitalize(name);
+ Method method = findMethod(clazz, accessor);
+ return validSetter(method) ? method : null;
+ }
+
+ public static Method findAdder(Class clazz, String name)
+ {
+ String accessor = "add" + capitalize(name);
+ Method method = findMethod(clazz, accessor);
+ return validAdder(method) ? method : null;
+ }
+
+ public static Method findMethod(Class clazz, String name)
+ {
+ Method[] methods = clazz.getMethods();
+ for (int i = 0; i < methods.length; i++)
+ {
+ Method method = methods[i];
+ if (name.equals(method.getName())) return method;
+ }
+ return null;
+ }
+
+ private static boolean validGetter(Method method)
+ {
+ if (method == null) return false;
+
+ Class[] paramTypes = method.getParameterTypes();
+ if (paramTypes != null || paramTypes.length != 0) return false;
+
+ Class returnType = method.getReturnType();
+ if (returnType == null || !validAttributeType(returnType)) return false;
+
+ return true;
+ }
+
+ private static boolean validSetter(Method method)
+ {
+ if (method == null) return false;
+
+ Class[] paramTypes = method.getParameterTypes();
+ if (paramTypes == null || paramTypes.length != 1 || !validAttributeType(paramTypes[0]))
+ return false;
+
+ Class returnType = method.getReturnType();
+ if (returnType != null && returnType != void.class) return false;
+
+ return true;
+ }
+
+ private static boolean validAdder(Method method)
+ {
+ if (method == null) return false;
+
+ Class[] paramTypes = method.getParameterTypes();
+ if (paramTypes == null || paramTypes.length != 1) return false;
+
+ Class returnType = method.getReturnType();
+ if (returnType != null && returnType != void.class) return false;
+
+ return true;
+ }
+
+ private static boolean validChildGetter(Method method)
+ {
+ if (method == null) return false;
+
+ Class[] paramTypes = method.getParameterTypes();
+ if (paramTypes != null || paramTypes.length != 0) return false;
+
+ Class returnType = method.getReturnType();
+ if (returnType == null || !validChildType(returnType)) return false;
+
+ return true;
+ }
+
+ private static boolean validAttributeType(Class type)
+ {
+ return type == String.class || type == Boolean.class;
+ }
+
+ private static boolean validChildType(Class type)
+ {
+ return type.isArray();
+ }
+
+ private static String capitalize(String name)
+ {
+ return StringHelper.firstToUpper(name);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BitHelper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BitHelper.java
new file mode 100644
index 0000000000..df8975b676
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BitHelper.java
@@ -0,0 +1,26 @@
+package org.eclipse.net4j.util;
+
+
+public class BitHelper
+{
+ public static final int LOWEST_BIT = 0x0000001;
+
+ public static int getMask(int bits, int rightPad)
+ {
+ int mask = LOWEST_BIT;
+
+ // Create bit mask
+ for (int i = 0; i < bits - 1; i++)
+ {
+ mask <<= 1;
+ mask |= LOWEST_BIT;
+ }
+
+ return mask << rightPad;
+ }
+
+ public static int getMask(int bits)
+ {
+ return getMask(bits, 0);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/DateHelper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/DateHelper.java
new file mode 100644
index 0000000000..3780898c81
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/DateHelper.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util;
+
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+
+/**
+ * This is a timezone conversion utility class.
+ */
+public class DateHelper
+{
+
+ private static final String[] MONTHS = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
+ "Sep", "Oct", "Nov", "Dec"};
+
+ // as SimpleDateFormat is not thread-safe - we have to use ThreadLocal
+ private final static ThreadLocal AFTER_SIX = new ThreadLocal()
+ {
+
+ protected Object initialValue()
+ {
+ return new SimpleDateFormat(" yyyy");
+ }
+ };
+
+ private final static ThreadLocal BEFORE_SIX = new ThreadLocal()
+ {
+
+ protected Object initialValue()
+ {
+ return new SimpleDateFormat("HH:mm");
+ }
+ };
+
+ /**
+ * Get unix style date string.
+ */
+ public static String getUnixDate(Date date)
+ {
+ long dateTime = date.getTime();
+ if (dateTime < 0)
+ {
+ return "------------";
+ }
+
+ Calendar cal = new GregorianCalendar();
+ cal.setTime(date);
+ String firstPart = MONTHS[cal.get(Calendar.MONTH)] + ' ';
+
+ String dateStr = String.valueOf(cal.get(Calendar.DATE));
+ if (dateStr.length() == 1)
+ {
+ dateStr = ' ' + dateStr;
+ }
+ firstPart += dateStr + ' ';
+
+ long nowTime = System.currentTimeMillis();
+ if (Math.abs(nowTime - dateTime) > 183L * 24L * 60L * 60L * 1000L)
+ {
+ DateFormat fmt = (DateFormat) AFTER_SIX.get();
+ return firstPart + fmt.format(date);
+ }
+ else
+ {
+ DateFormat fmt = (DateFormat) BEFORE_SIX.get();
+ return firstPart + fmt.format(date);
+ }
+ }
+
+ /**
+ * Get the timezone specific string.
+ */
+ public static String getString(Date dt, DateFormat df, TimeZone to)
+ {
+ df.setTimeZone(to);
+ return df.format(dt);
+ }
+
+ /**
+ * Get the timezone specific calendar.
+ */
+ public static Calendar getCalendar(Date dt, TimeZone to)
+ {
+ Calendar cal = Calendar.getInstance(to);
+ cal.setTime(dt);
+ return cal;
+ }
+
+ /**
+ * Get date object.
+ */
+ public static Date getDate(String str, DateFormat df, TimeZone from)
+ throws java.text.ParseException
+ {
+ df.setTimeZone(from);
+ return df.parse(str);
+ }
+
+ /**
+ * Get date difference => d1 - d2.
+ */
+ public static String getDifference(Date d1, Date d2)
+ {
+ Calendar calendar = new GregorianCalendar();
+ calendar.setTime(d2);
+ int year2 = calendar.get(Calendar.YEAR);
+ int day2 = calendar.get(Calendar.DAY_OF_YEAR);
+ int hour2 = calendar.get(Calendar.HOUR_OF_DAY);
+ int min2 = calendar.get(Calendar.MINUTE);
+
+ calendar.setTime(d1);
+ int year1 = calendar.get(Calendar.YEAR);
+ int day1 = calendar.get(Calendar.DAY_OF_YEAR);
+ int hour1 = calendar.get(Calendar.HOUR_OF_DAY);
+ int min1 = calendar.get(Calendar.MINUTE);
+
+ int leftDays = (day1 - day2) + (year1 - year2) * 365;
+ int leftHours = hour1 - hour2;
+ int leftMins = min1 - min2;
+
+ if (leftMins < 0)
+ {
+ leftMins += 60;
+ --leftHours;
+ }
+ if (leftHours < 0)
+ {
+ leftHours += 24;
+ --leftDays;
+ }
+
+ String interval = "";
+ if (leftDays > 0)
+ {
+ interval = leftDays + " Days";
+ }
+ else if ((leftHours > 0) && (leftDays == 0))
+ {
+ interval = leftHours + " Hours";
+ }
+ else if ((leftMins > 0) && (leftHours == 0) && (leftDays == 0))
+ {
+ interval = leftMins + " Minutes";
+ }
+ else
+ {
+ interval = "";
+ }
+ return interval;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/DigestHelper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/DigestHelper.java
new file mode 100644
index 0000000000..f3ac9429be
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/DigestHelper.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util;
+
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+
+public class DigestHelper
+{
+
+ /**
+ * Encrypt byte array.
+ */
+ public static byte[] encrypt(byte[] source, String algorithm) throws NoSuchAlgorithmException
+ {
+ MessageDigest md = MessageDigest.getInstance(algorithm);
+ md.reset();
+ md.update(source);
+ return md.digest();
+ }
+
+ /**
+ * Encrypt string
+ */
+ public static String encrypt(String source, String algorithm) throws NoSuchAlgorithmException
+ {
+ byte[] resByteArray = encrypt(source.getBytes(), algorithm);
+ return StringHelper.toHexString(resByteArray);
+ }
+
+ /**
+ * Encrypt string using MD5 algorithm
+ */
+ public static String encryptMD5(String source)
+ {
+ if (source == null)
+ {
+ source = "";
+ }
+
+ String result = "";
+
+ try
+ {
+ result = encrypt(source, "MD5");
+ }
+ catch (NoSuchAlgorithmException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ return result;
+ }
+
+ /**
+ * Encrypt string using SHA algorithm
+ */
+ public static String encryptSHA(String source)
+ {
+ if (source == null)
+ {
+ source = "";
+ }
+
+ String result = "";
+
+ try
+ {
+ result = encrypt(source, "SHA");
+ }
+ catch (NoSuchAlgorithmException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ return result;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/IOHelper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/IOHelper.java
new file mode 100644
index 0000000000..87e292ed17
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/IOHelper.java
@@ -0,0 +1,683 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util;
+
+
+import java.util.Date;
+import java.util.Random;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import java.text.SimpleDateFormat;
+
+
+public class IOHelper
+{
+ public static String currentDirectory()
+ {
+ String path = new File(".").getAbsolutePath();
+ return path.substring(0, path.length() - 2);
+ }
+
+ /**
+ * Random number generator to make unique file name
+ */
+ private static final Random RANDOM_GEN = new Random(System.currentTimeMillis());
+
+ /**
+ * Get a <code>BufferedInputStream</code>.
+ */
+ public static BufferedInputStream getBufferedInputStream(InputStream in)
+ {
+ BufferedInputStream bin = null;
+ if (in instanceof java.io.BufferedInputStream)
+ {
+ bin = (BufferedInputStream) in;
+ }
+ else
+ {
+ bin = new BufferedInputStream(in);
+ }
+ return bin;
+ }
+
+ /**
+ * Get a <code>BufferedOutputStream</code>.
+ */
+ public static BufferedOutputStream getBufferedOutputStream(OutputStream out)
+ {
+ BufferedOutputStream bout = null;
+ if (out instanceof java.io.BufferedOutputStream)
+ {
+ bout = (BufferedOutputStream) out;
+ }
+ else
+ {
+ bout = new BufferedOutputStream(out);
+ }
+ return bout;
+ }
+
+ /**
+ * Get <code>BufferedReader</code>.
+ */
+ public static BufferedReader getBufferedReader(Reader rd)
+ {
+ if (rd instanceof java.io.BufferedReader)
+ {
+ return (BufferedReader) rd;
+ }
+ else
+ {
+ return new BufferedReader(rd);
+ }
+ }
+
+ /**
+ * Get <code>BufferedWriter</code>.
+ */
+ public static BufferedWriter getBufferedWriter(Writer wr)
+ {
+ BufferedWriter bw = null;
+ if (wr instanceof java.io.BufferedWriter)
+ {
+ bw = (BufferedWriter) wr;
+ }
+ else
+ {
+ bw = new BufferedWriter(wr);
+ }
+ return bw;
+ }
+
+ /**
+ * Get unique file object.
+ */
+ public static File getUniqueFile(File oldFile)
+ {
+ File newFile = oldFile;
+
+ while (true)
+ {
+ if (!newFile.exists())
+ {
+ break;
+ }
+
+ newFile = new File(oldFile.getAbsolutePath() + '.' + Math.abs(RANDOM_GEN.nextLong()));
+ }
+ return newFile;
+ }
+
+ /**
+ * No exception <code>InputStream</code> close method.
+ */
+ public static void close(InputStream is)
+ {
+ if (is != null)
+ {
+ try
+ {
+ is.close();
+ }
+ catch (Exception ignore)
+ {
+ ignore.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * No exception <code>OutputStream</code> close method.
+ */
+ public static void close(OutputStream os)
+ {
+ if (os != null)
+ {
+ try
+ {
+ os.close();
+ }
+ catch (Exception ignore)
+ {
+ ignore.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * No exception <code>java.io.Reader</code> close method.
+ */
+ public static void close(Reader rd)
+ {
+ if (rd != null)
+ {
+ try
+ {
+ rd.close();
+ }
+ catch (Exception ignore)
+ {
+ ignore.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * No exception <code>java.io.Writer</code> close method.
+ */
+ public static void close(Writer wr)
+ {
+ if (wr != null)
+ {
+ try
+ {
+ wr.close();
+ }
+ catch (Exception ignore)
+ {
+ ignore.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * Get exception stack trace.
+ */
+ public static String getStackTrace(Throwable ex)
+ {
+ String result = "";
+ try
+ {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ ex.printStackTrace(pw);
+ pw.close();
+ sw.close();
+ result = sw.toString();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ /**
+ * Copy chars from a <code>Reader</code> to a <code>Writer</code>.
+ *
+ * @param bufferSize
+ * Size of internal buffer to use.
+ */
+ public static void copy(Reader input, Writer output, int bufferSize) throws IOException
+ {
+ char buffer[] = new char[bufferSize];
+ int n = 0;
+
+ while ((n = input.read(buffer)) != -1)
+ {
+ output.write(buffer, 0, n);
+ }
+ }
+
+ public static void copy(InputStream input, OutputStream output, byte buffer[]) throws IOException
+ {
+ int n = 0;
+
+ while ((n = input.read(buffer)) != -1)
+ {
+ output.write(buffer, 0, n);
+ }
+ }
+
+ public static void copy(InputStream input, OutputStream output, int bufferSize)
+ throws IOException
+ {
+ copy(input, output, new byte[bufferSize]);
+ }
+
+ public static void copy(InputStream input, OutputStream output) throws IOException
+ {
+ copy(input, output, 4096);
+ }
+
+ public static void copy(File input, File output) throws IOException
+ {
+ FileInputStream fis = null;
+ FileOutputStream fos = null;
+
+ try
+ {
+ fis = new FileInputStream(input);
+ fos = new FileOutputStream(output);
+
+ copy(fis, fos);
+ }
+ finally
+ {
+ close(fis);
+ close(fos);
+ }
+ }
+
+ /**
+ * Read fully from reader
+ */
+ public static String readFully(Reader reader) throws IOException
+ {
+ StringWriter writer = new StringWriter();
+ copy(reader, writer, 1024);
+ return writer.toString();
+ }
+
+ /**
+ * Read fully from stream
+ */
+ public static String readFully(InputStream input) throws IOException
+ {
+ InputStreamReader reader = new InputStreamReader(input);
+ return readFully(reader);
+ }
+
+ /**
+ * Read fully from file
+ */
+ public static String readFully(File file) throws IOException
+ {
+ FileInputStream stream = null;
+
+ try
+ {
+ stream = new FileInputStream(file);
+ return readFully(stream);
+ }
+ finally
+ {
+ close(stream);
+ }
+ }
+
+ public static void log(String message)
+ {
+ log(message, null);
+ }
+
+ public static void log(String message, Throwable t)
+ {
+ PrintWriter writer = null;
+
+ try
+ {
+ writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream("log.txt", true)));
+ writer.println(new SimpleDateFormat().format(new Date()) + " " + message);
+
+ if (t != null)
+ {
+ t.printStackTrace(writer);
+ }
+ }
+ catch (Exception ignore)
+ {
+ }
+ finally
+ {
+ if (writer != null)
+ {
+ try
+ {
+ writer.close();
+ }
+ catch (Exception ignore)
+ {
+ }
+ }
+ }
+ }
+
+ public static File createTempFolder() throws IOException
+ {
+ return createTempFolder("tmp");
+ }
+
+ public static File createTempFolder(String prefix) throws IOException
+ {
+ return createTempFolder(prefix, "");
+ }
+
+ public static File createTempFolder(String prefix, String suffix) throws IOException
+ {
+ return createTempFolder(prefix, suffix, null);
+ }
+
+ public static File createTempFolder(String prefix, String suffix, File directory)
+ throws IOException
+ {
+ File tmp = File.createTempFile(prefix, suffix, directory);
+ String tmpPath = tmp.getAbsolutePath();
+ tmp.delete();
+ tmp = new File(tmpPath);
+ tmp.mkdirs();
+ return tmp;
+ }
+
+ public static void zip(File source, File target)
+ {
+ zip(source, target, false);
+ }
+
+ public static void zip(File source, File target, boolean excludeRoot)
+ {
+ ZipOutputStream zos = null;
+
+ try
+ {
+ File root = excludeRoot ? source : source.getParentFile();
+ int prefixLength = root.getAbsolutePath().length() + (excludeRoot ? 1 : 0);
+
+ zos = new ZipOutputStream(new FileOutputStream(target));
+ zipRecurse(source, prefixLength, zos);
+ zos.flush();
+ }
+ catch (IOException ex)
+ {
+ throw new UnderlyingIOException("Error while jaring " + source + " to " + target, ex);
+ }
+ finally
+ {
+ close(zos);
+ }
+ }
+
+ public static void unzip(String zipFilePath, String targetPath)
+ {
+ final int BUFFER = 4096;
+ byte data[] = new byte[BUFFER];
+ int count;
+
+ BufferedOutputStream dest = null;
+ ZipInputStream zis = null;
+
+ try
+ {
+ new File(targetPath).mkdirs();
+
+ FileInputStream fis = new FileInputStream(zipFilePath);
+ zis = new ZipInputStream(new BufferedInputStream(fis));
+ ZipEntry entry;
+
+ while ((entry = zis.getNextEntry()) != null)
+ {
+ File path = new File(targetPath, entry.getName());
+ if (entry.isDirectory())
+ {
+ path.mkdirs();
+ }
+ else
+ {
+ path.getParentFile().mkdirs();
+ FileOutputStream fos = new FileOutputStream(path);
+ dest = new BufferedOutputStream(fos, BUFFER);
+
+ while ((count = zis.read(data, 0, BUFFER)) != -1)
+ {
+ dest.write(data, 0, count);
+ }
+
+ dest.flush();
+ dest.close();
+ dest = null;
+ }
+ }
+ }
+ catch (IOException ex)
+ {
+ throw new UnderlyingIOException("Error while unzipping " + zipFilePath + " to " + targetPath,
+ ex);
+ }
+ finally
+ {
+ IOHelper.close(dest);
+ IOHelper.close(zis);
+ }
+ }
+
+ public static void jar(File source, File target)
+ {
+ jar(source, target, false);
+ }
+
+ public static void jar(File source, File target, boolean excludeRoot)
+ {
+ FileOutputStream fos = null;
+ JarOutputStream jos = null;
+
+ try
+ {
+ Manifest manifest = null;
+ File metainfFolder = new File(source, "META-INF");
+ File manifestFile = metainfFolder.exists() ? new File(metainfFolder, "MANIFEST.MF") : null;
+
+ if (manifestFile == null)
+ {
+ manifest = new Manifest();
+ }
+ else
+ {
+ FileInputStream fis = null;
+
+ try
+ {
+ fis = new FileInputStream(manifestFile);
+ manifest = new Manifest(fis);
+ }
+ catch (IOException ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ close(fis);
+ }
+ }
+
+ File root = excludeRoot ? source : source.getParentFile();
+ int prefixLength = root.getAbsolutePath().length() + 1;
+
+ fos = new FileOutputStream(target);
+ jos = new JarOutputStream(fos, manifest);
+ jarRecurse(source, prefixLength, jos);
+ jos.flush();
+ }
+ catch (IOException ex)
+ {
+ throw new UnderlyingIOException("Error while jaring " + source + " to " + target, ex);
+ }
+ finally
+ {
+ close(jos);
+ close(fos);
+ }
+ }
+
+ /**
+ *
+ * @param file
+ * @param impliedPrefix
+ * @param jos
+ * @throws IOException
+ */
+
+ public static long diskUsage(File file)
+ {
+ if (file.isFile())
+ {
+ return file.length();
+ }
+ else if (file.isDirectory())
+ {
+ long usage = 0;
+ File[] children = file.listFiles();
+
+ for (int i = 0; i < children.length; i++)
+ {
+ File child = children[i];
+ usage += diskUsage(child);
+ }
+
+ return usage;
+ }
+
+ return 0;
+ }
+
+ public static int deleteFile(File file)
+ {
+ if (file == null)
+ {
+ return 0;
+ }
+
+ int deleted = 0;
+
+ if (file.isDirectory())
+ {
+ File[] children = file.listFiles();
+ for (int i = 0; i < children.length; i++)
+ {
+ File child = children[i];
+ deleted += deleteFile(child);
+ }
+ }
+
+ return deleted + (file.delete() ? 1 : 0);
+ }
+
+ private static void zipRecurse(File file, int prefixLength, ZipOutputStream zos)
+ throws IOException
+ {
+ ZipEntry entry = null;
+
+ try
+ {
+ String name = file.getAbsolutePath() + (file.isDirectory() ? "/" : "");
+ name = name.substring(prefixLength);
+
+ if (name.length() > 0)
+ {
+ entry = new ZipEntry(name);
+ zos.putNextEntry(entry);
+
+ if (file.isFile())
+ {
+ FileInputStream fis = null;
+
+ try
+ {
+ fis = new FileInputStream(file);
+ copy(fis, zos, 4096);
+ }
+ finally
+ {
+ close(fis);
+ }
+ }
+ }
+ }
+ finally
+ {
+ if (entry != null)
+ {
+ zos.closeEntry();
+ }
+ }
+
+ if (file.isDirectory())
+ {
+ File[] children = file.listFiles();
+ for (int i = 0; i < children.length; i++)
+ {
+ File child = children[i];
+ zipRecurse(child, prefixLength, zos);
+ }
+ }
+ }
+
+ private static void jarRecurse(File file, int prefixLength, JarOutputStream jos)
+ throws IOException
+ {
+ JarEntry entry = null;
+
+ try
+ {
+ String name = file.getAbsolutePath() + (file.isDirectory() ? "/" : "");
+ name = name.substring(prefixLength);
+
+ if (name.length() > 0)
+ {
+ if (file.isFile() && !name.replace('\\', '/').equals("META-INF/MANIFEST.MF"))
+ {
+ entry = new JarEntry(name);
+ jos.putNextEntry(entry);
+
+ FileInputStream fis = null;
+
+ try
+ {
+ fis = new FileInputStream(file);
+ copy(fis, jos, 4096);
+ }
+ finally
+ {
+ close(fis);
+ }
+ }
+ }
+ }
+ finally
+ {
+ if (entry != null)
+ {
+ jos.closeEntry();
+ }
+ }
+
+ if (file.isDirectory())
+ {
+ File[] children = file.listFiles();
+ for (int i = 0; i < children.length; i++)
+ {
+ File child = children[i];
+ jarRecurse(child, prefixLength, jos);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ImplementationError.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ImplementationError.java
new file mode 100644
index 0000000000..65a3fed675
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ImplementationError.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util;
+
+
+public class ImplementationError extends Net4jException
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 3256718498427318836L;
+
+ public ImplementationError()
+ {
+ super();
+ }
+
+ public ImplementationError(String arg0)
+ {
+ super(arg0);
+ }
+
+ public ImplementationError(Throwable arg0)
+ {
+ super(arg0);
+ }
+
+ public ImplementationError(String arg0, Throwable arg1)
+ {
+ super(arg0, arg1);
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/MathHelper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/MathHelper.java
new file mode 100644
index 0000000000..2ac28c550a
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/MathHelper.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util;
+
+
+public class MathHelper
+{
+
+ public static boolean isPrime(int number)
+ {
+ if (number % 2 == 0)
+ {
+ return false;
+ }
+ else
+ {
+ int max = (int) Math.floor(Math.sqrt(number));
+ for (int i = 3; i <= max; i += 2)
+ {
+ if (number % i == 0)
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public static int getPrime(int min)
+ {
+ while (!isPrime(min))
+ {
+ ++min;
+ }
+
+ return min;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Net4jException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Net4jException.java
new file mode 100644
index 0000000000..2df853cd6f
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Net4jException.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util;
+
+
+public class Net4jException extends RuntimeException
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 3978703987010976050L;
+
+ /**
+ *
+ */
+ public Net4jException()
+ {
+ super();
+ }
+
+ /**
+ * @param message
+ */
+ public Net4jException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * @param cause
+ */
+ public Net4jException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public Net4jException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Net4jUtilPlugin.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Net4jUtilPlugin.java
new file mode 100644
index 0000000000..8c542faa96
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Net4jUtilPlugin.java
@@ -0,0 +1,63 @@
+package org.eclipse.net4j.util;
+
+
+import org.eclipse.net4j.util.eclipse.AbstractPlugin;
+
+import org.eclipse.core.runtime.FileLocator;
+
+import org.apache.log4j.xml.DOMConfigurator;
+
+import org.osgi.framework.BundleContext;
+
+import java.net.URL;
+
+
+public class Net4jUtilPlugin extends AbstractPlugin
+{
+ //The shared instance.
+ private static Net4jUtilPlugin plugin;
+
+ /**
+ * The constructor.
+ */
+ public Net4jUtilPlugin()
+ {
+ if (plugin == null) plugin = this;
+ }
+
+ public void start(BundleContext context) throws Exception
+ {
+ super.start(context);
+ initializeLogger();
+ }
+
+ protected void doStop() throws Exception
+ {
+ plugin = null;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static Net4jUtilPlugin getDefault()
+ {
+ return plugin;
+ }
+
+ private void initializeLogger()
+ {
+ // IOHelper.log("Initializing Log4j...");
+
+ try
+ {
+ URL pluginURL = getBundle().getEntry("/config/log4j.xml");
+ URL absoluteURL = FileLocator.toFileURL(pluginURL);
+
+ DOMConfigurator.configure(absoluteURL);
+ }
+ catch (Exception ex)
+ {
+ IOHelper.log("Warning: Initialization of Log4j failed", ex);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Pair.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Pair.java
new file mode 100644
index 0000000000..a65d6db4bf
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Pair.java
@@ -0,0 +1,55 @@
+package org.eclipse.net4j.util;
+
+
+public final class Pair<T1, T2>
+{
+ private final T1 first;
+
+ private final T2 second;
+
+ public Pair(T1 first, T2 second)
+ {
+ this.first = first;
+ this.second = second;
+ }
+
+ public T1 getFirst()
+ {
+ return first;
+ }
+
+ public T2 getSecond()
+ {
+ return second;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (!(o instanceof Pair)) return false;
+ Pair that = (Pair) o;
+
+ Object f1 = getFirst();
+ Object f2 = that.getFirst();
+ if (f1 == f2 || (f1 != null && f1.equals(f2)))
+ {
+ Object s1 = getSecond();
+ Object s2 = that.getSecond();
+ if (s1 == s2 || (s1 != null && s1.equals(s2))) return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return (first == null ? 0 : first.hashCode()) ^ (second == null ? 0 : second.hashCode());
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Pair[" + first + ", " + second + "]";
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/StringHelper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/StringHelper.java
new file mode 100644
index 0000000000..b0dde7ef67
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/StringHelper.java
@@ -0,0 +1,578 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import java.nio.ByteBuffer;
+
+
+public class StringHelper
+{
+
+ public static final char HEX_DIGITS[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a',
+ 'b', 'c', 'd', 'e', 'f',};
+
+ public static final String UTF8_CHARS = " "
+ + " !\"#$%&'()*+,-./0123456789:;<=>?" + "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
+ + "`abcdefghijklmnopqrstuvwxyz{|}~";
+
+ public static final char SEPARATOR = '\n';
+
+ /**
+ * This method is used to insert HTML block dynamically
+ *
+ * @param source
+ * the HTML code to be processes
+ * @param bReplaceNl
+ * if true '\n' will be replaced by <br>
+ * @param bReplaceTag
+ * if true ' <' will be replaced by &lt; and '>' will be replaced by &gt;
+ * @param bReplaceQuote
+ * if true '\"' will be replaced by &quot;
+ */
+ public static String formatHtml(String source, boolean bReplaceNl, boolean bReplaceTag,
+ boolean bReplaceQuote)
+ {
+
+ StringBuffer sb = new StringBuffer();
+ int len = source.length();
+ for (int i = 0; i < len; i++)
+ {
+ char c = source.charAt(i);
+ switch (c)
+ {
+ case '\"':
+ if (bReplaceQuote)
+ sb.append("&quot;");
+ else
+ sb.append(c);
+ break;
+
+ case '<':
+ if (bReplaceTag)
+ sb.append("&lt;");
+ else
+ sb.append(c);
+ break;
+
+ case '>':
+ if (bReplaceTag)
+ sb.append("&gt;");
+ else
+ sb.append(c);
+ break;
+
+ case '\n':
+ if (bReplaceNl)
+ {
+ if (bReplaceTag)
+ sb.append("&lt;br&gt;");
+ else
+ sb.append("<br>");
+ }
+ else
+ {
+ sb.append(c);
+ }
+ break;
+
+ case '\r':
+ break;
+
+ case '&':
+ sb.append("&amp;");
+ break;
+
+ default:
+ sb.append(c);
+ break;
+ }
+ }
+ return sb.toString();
+ }
+
+ public static String getLastToken(String str, char separator)
+ {
+ int pos = str.lastIndexOf(separator);
+ if (pos != -1)
+ {
+ str = str.substring(pos + 1);
+ }
+ return str;
+ }
+
+ public static String getSimpleClassName(Class aClass)
+ {
+ return getSimpleClassName(aClass.getName());
+ }
+
+ public static String getSimpleClassName(String qualifiedClassName)
+ {
+ return getLastToken(qualifiedClassName, '.');
+ }
+
+ /**
+ * Pad string object
+ */
+ public static String pad(String src, char padChar, boolean rightPad, int totalLength)
+ {
+
+ int srcLength = src.length();
+ if (srcLength >= totalLength)
+ {
+ return src;
+ }
+
+ int padLength = totalLength - srcLength;
+ StringBuffer sb = new StringBuffer(padLength);
+ for (int i = 0; i < padLength; ++i)
+ {
+ sb.append(padChar);
+ }
+
+ if (rightPad)
+ {
+ return src + sb.toString();
+ }
+ else
+ {
+ return sb.toString() + src;
+ }
+ }
+
+ public static String removePrefix(String str, String prefix)
+ {
+ if (str.startsWith(prefix))
+ {
+ return str.substring(prefix.length());
+ }
+ return str;
+ }
+
+ public static String removeSuffix(String str, String suffix)
+ {
+ if (str.endsWith(suffix))
+ {
+ return str.substring(0, str.length() - suffix.length());
+ }
+ return str;
+ }
+
+ /**
+ * Replace string
+ */
+ public static String replaceString(String source, Map args)
+ {
+ int startIndex = 0;
+ int openIndex = source.indexOf('{', startIndex);
+ if (openIndex == -1)
+ {
+ return source;
+ }
+
+ int closeIndex = source.indexOf('}', startIndex);
+ if ((closeIndex == -1) || (openIndex > closeIndex))
+ {
+ return source;
+ }
+
+ StringBuffer sb = new StringBuffer();
+ sb.append(source.substring(startIndex, openIndex));
+ while (true)
+ {
+ String key = source.substring(openIndex + 1, closeIndex);
+ Object val = args.get(key);
+ if (val != null)
+ {
+ sb.append(val);
+ }
+
+ startIndex = closeIndex + 1;
+ openIndex = source.indexOf('{', startIndex);
+ if (openIndex == -1)
+ {
+ sb.append(source.substring(startIndex));
+ break;
+ }
+
+ closeIndex = source.indexOf('}', startIndex);
+ if ((closeIndex == -1) || (openIndex > closeIndex))
+ {
+ sb.append(source.substring(startIndex));
+ break;
+ }
+ sb.append(source.substring(startIndex, openIndex));
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Replace string
+ */
+ public static String replaceString(String source, Object[] args)
+ {
+ int startIndex = 0;
+ int openIndex = source.indexOf('{', startIndex);
+ if (openIndex == -1)
+ {
+ return source;
+ }
+
+ int closeIndex = source.indexOf('}', startIndex);
+ if ((closeIndex == -1) || (openIndex > closeIndex))
+ {
+ return source;
+ }
+
+ StringBuffer sb = new StringBuffer();
+ sb.append(source.substring(startIndex, openIndex));
+ while (true)
+ {
+ String intStr = source.substring(openIndex + 1, closeIndex);
+ int index = Integer.parseInt(intStr);
+ sb.append(args[index]);
+
+ startIndex = closeIndex + 1;
+ openIndex = source.indexOf('{', startIndex);
+ if (openIndex == -1)
+ {
+ sb.append(source.substring(startIndex));
+ break;
+ }
+
+ closeIndex = source.indexOf('}', startIndex);
+ if ((closeIndex == -1) || (openIndex > closeIndex))
+ {
+ sb.append(source.substring(startIndex));
+ break;
+ }
+ sb.append(source.substring(startIndex, openIndex));
+ }
+ return sb.toString();
+ }
+
+ /**
+ * This is a string replacement method.
+ */
+ public static String replaceString(String source, String oldStr, String newStr)
+ {
+ StringBuffer sb = new StringBuffer(source.length());
+ int sind = 0;
+ int cind = 0;
+ while ((cind = source.indexOf(oldStr, sind)) != -1)
+ {
+ sb.append(source.substring(sind, cind));
+ sb.append(newStr);
+ sind = cind + oldStr.length();
+ }
+ sb.append(source.substring(sind));
+ return sb.toString();
+ }
+
+ public static String replaceWildcards(String source, String param, Object[] args)
+ {
+ String tmp = source;
+ for (int i = 0; i < args.length; i++)
+ {
+ int pos = tmp.indexOf(param);
+ if (pos == -1)
+ throw new IllegalArgumentException("source '" + source + "' must contain at least "
+ + args.length + " params '" + param + "'");
+
+ String arg = args[i] == null ? "null" : args[i].toString();
+ tmp = tmp.substring(0, pos) + arg + tmp.substring(pos + 1);
+ }
+ return tmp;
+ }
+
+ /**
+ * Get byte array from hex string
+ */
+ public static byte[] toByteArray(String hexString)
+ {
+ int arrLength = hexString.length() >> 1;
+ byte buff[] = new byte[arrLength];
+ for (int i = 0; i < arrLength; i++)
+ {
+ int index = i << 1;
+ String digit = hexString.substring(index, index + 2);
+ buff[i] = (byte) Integer.parseInt(digit, 16);
+ }
+ return buff;
+ }
+
+ /**
+ * Append hex string from byte to StringBuffer
+ */
+ public static void appendHexString(StringBuffer buffer, byte data)
+ {
+ int positive = data < 0 ? ~data : data;
+ buffer.append(HEX_DIGITS[positive >> 4]);
+ buffer.append(HEX_DIGITS[positive & 0xf]);
+ }
+
+ /**
+ * Get hex string from byte
+ */
+ public static String toHexString(byte data)
+ {
+ StringBuffer buffer = new StringBuffer();
+ appendHexString(buffer, data);
+ return buffer.toString();
+ }
+
+ /**
+ * Get hex string from byte array
+ */
+ public static String toHexString(byte[] data)
+ {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < data.length; i++)
+ {
+ appendHexString(buffer, data[i]);
+ buffer.append(' ');
+ }
+
+ return buffer.toString();
+ }
+
+ public static String toHexString(ByteBuffer buffer)
+ {
+ StringBuffer line = new StringBuffer();
+
+ while (buffer.hasRemaining())
+ {
+ byte dec = buffer.get();
+ StringHelper.appendHexString(line, dec);
+ line.append(' ');
+ }
+
+ return line.toString();
+ }
+
+ /**
+ * Append hex string from byte to StringBuffer
+ */
+ public static void appendUTF8String(StringBuffer buffer, byte data, boolean flat)
+ {
+ if (32 <= data && data < 127)
+ {
+ char c = UTF8_CHARS.charAt(data);
+ buffer.append(c);
+ }
+ else
+ {
+ if (!flat)
+ {
+ buffer.append(".");
+ }
+ }
+ }
+
+ /**
+ * Get hex string from byte
+ */
+ public static String toUTF8String(byte data, boolean flat)
+ {
+ StringBuffer buffer = new StringBuffer();
+ appendUTF8String(buffer, data, flat);
+ return buffer.toString();
+ }
+
+ /**
+ * Get hex string from byte array
+ */
+ public static String toUTF8String(byte[] data, boolean flat)
+ {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < data.length; i++)
+ {
+ appendUTF8String(buffer, data[i], flat);
+ }
+
+ return buffer.toString();
+ }
+
+ public static String toUTF8String(ByteBuffer buffer, boolean flat)
+ {
+ StringBuffer line = new StringBuffer();
+
+ while (buffer.hasRemaining())
+ {
+ byte dec = buffer.get();
+ StringHelper.appendUTF8String(line, dec, flat);
+ }
+
+ return line.toString();
+ }
+
+ public static boolean parseBoolean(String str) throws NumberFormatException
+ {
+ if (str.equals("true")) return true;
+ if (str.equals("false")) return false;
+ throw new NumberFormatException("'" + str + "' is neither 'true' nor 'false'");
+ }
+
+ public static String implode(Collection collection, String separator)
+ {
+ if (collection == null) return null;
+ if (collection.size() == 0) return "";
+
+ Iterator iter = collection.iterator();
+ StringBuffer result = new StringBuffer(iter.next().toString());
+
+ while (iter.hasNext())
+ {
+ if (separator != null) result.append(separator);
+ result.append(iter.next().toString());
+ }
+
+ return result.toString();
+ }
+
+ public static String implode(Object[] array, String separator)
+ {
+ if (array == null) return null;
+ if (array.length == 0) return "";
+
+ StringBuffer result = new StringBuffer(array[0].toString());
+
+ for (int i = 1; i < array.length; i++)
+ {
+ if (separator != null) result.append(separator);
+ result.append(array[i].toString());
+ }
+
+ return result.toString();
+ }
+
+ public static int getChoice(String str, String[] choices)
+ {
+ if (choices == null) throw new IllegalArgumentException("choices should be non-null");
+
+ for (int i = 0; i < choices.length; i++)
+ {
+ if ((str == null && choices[i] == null) || str.equals(choices[i]))
+ {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ public static List parseName(String name, char separator)
+ {
+ List result = new ArrayList();
+ StringBuffer currentWord = new StringBuffer();
+
+ int length = name.length();
+ boolean lastIsLower = false;
+
+ for (int index = 0; index < length; index++)
+ {
+ char curChar = name.charAt(index);
+ if (Character.isUpperCase(curChar) || (!lastIsLower && Character.isDigit(curChar))
+ || curChar == separator)
+ {
+ if (lastIsLower || curChar == separator)
+ {
+ result.add(currentWord.toString());
+ currentWord = new StringBuffer();
+ }
+ lastIsLower = false;
+ }
+ else
+ {
+ if (!lastIsLower)
+ {
+ int currentWordLength = currentWord.length();
+ if (currentWordLength > 1)
+ {
+ char lastChar = currentWord.charAt(--currentWordLength);
+ currentWord.setLength(currentWordLength);
+ result.add(currentWord.toString());
+ currentWord = new StringBuffer();
+ currentWord.append(lastChar);
+ }
+ }
+ lastIsLower = true;
+ }
+ if (curChar != separator)
+ {
+ currentWord.append(curChar);
+ }
+ }
+
+ result.add(currentWord.toString());
+ return result;
+ }
+
+ /**
+ * @param text
+ */
+ public static String firstToLower(String text)
+ {
+ if (text == null || text.length() == 0) return text;
+ if (Character.isUpperCase(text.charAt(0)))
+ {
+ return text.substring(0, 1).toLowerCase() + text.substring(1);
+ }
+ return text;
+ }
+
+ /**
+ * @param text
+ */
+ public static String firstToUpper(String text)
+ {
+ if (text == null || text.length() == 0) return text;
+ if (Character.isLowerCase(text.charAt(0)))
+ {
+ return text.substring(0, 1).toUpperCase() + text.substring(1);
+ }
+ return text;
+ }
+
+ public static int toInt(String intValue, int defaultValue)
+ {
+ try
+ {
+ return Integer.valueOf(intValue).intValue();
+ }
+ catch (Exception e)
+ {
+ return defaultValue;
+ }
+ }
+
+ public static boolean equals(Object obj1, Object obj2)
+ {
+ if (obj1 == null) return obj2 == null;
+ return obj1.equals(obj2);
+ }
+
+ public static String formatNull(String str, String nullReplacement)
+ {
+ return str == null ? nullReplacement : str;
+ }
+
+ public static String toNonNull(String str)
+ {
+ return formatNull(str, "");
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ThreadInterruptedException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ThreadInterruptedException.java
new file mode 100644
index 0000000000..61339cc1ce
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ThreadInterruptedException.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util;
+
+
+public class ThreadInterruptedException extends Net4jException
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 3256443603340244792L;
+
+ /**
+ *
+ */
+ public ThreadInterruptedException()
+ {
+ super();
+ }
+
+ /**
+ * @param message
+ */
+ public ThreadInterruptedException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * @param cause
+ */
+ public ThreadInterruptedException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public ThreadInterruptedException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/TimeOutException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/TimeOutException.java
new file mode 100644
index 0000000000..a41c7afa00
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/TimeOutException.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util;
+
+
+public class TimeOutException extends Net4jException
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 3977295508371158066L;
+
+ /**
+ *
+ */
+ public TimeOutException()
+ {
+ super();
+ }
+
+ /**
+ * @param message
+ */
+ public TimeOutException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * @param cause
+ */
+ public TimeOutException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public TimeOutException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/UnderlyingIOException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/UnderlyingIOException.java
new file mode 100644
index 0000000000..a7ea89597c
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/UnderlyingIOException.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util;
+
+
+public class UnderlyingIOException extends Net4jException
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 3833179220800386871L;
+
+ /**
+ *
+ */
+ public UnderlyingIOException()
+ {
+ super();
+ }
+
+ /**
+ * @param message
+ */
+ public UnderlyingIOException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * @param cause
+ */
+ public UnderlyingIOException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public UnderlyingIOException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/AbstractPlugin.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/AbstractPlugin.java
new file mode 100644
index 0000000000..91dbbdc51b
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/AbstractPlugin.java
@@ -0,0 +1,253 @@
+package org.eclipse.net4j.util.eclipse;
+
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+
+import org.apache.log4j.Logger;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import java.io.IOException;
+
+import java.net.URL;
+
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public abstract class AbstractPlugin extends Plugin implements ClassLoaderFactory
+{
+ /**
+ * Logger for this class
+ */
+ private final Logger logger = Logger.getLogger(getClass());
+
+ private String pluginId;
+
+ private ResourceBundle resourceBundle;
+
+ private BundleContext bundleContext;
+
+ /**
+ * The constructor.
+ */
+ protected AbstractPlugin()
+ {
+ }
+
+ public String getPluginId()
+ {
+ return pluginId;
+ }
+
+ public ClassLoader getClassLoader()
+ {
+ return getClass().getClassLoader();
+ }
+
+ public Logger getLogger()
+ {
+ return logger;
+ }
+
+ /**
+ * This method is called upon plug-in activation
+ */
+ public void start(BundleContext context) throws Exception
+ {
+ super.start(context);
+ bundleContext = context;
+ pluginId = context.getBundle().getSymbolicName();
+
+ try
+ {
+ if (resourceBundle == null)
+ {
+ try
+ {
+ resourceBundle = ResourceBundle.getBundle(pluginId);
+ }
+ catch (MissingResourceException x)
+ {
+ resourceBundle = null;
+ }
+ }
+
+ if (logger.isDebugEnabled()) logger.debug("ENTER STARTUP");
+ doStart();
+ }
+ catch (Throwable t)
+ {
+ logger.error("Startup error", t);
+ }
+ finally
+ {
+ if (logger.isDebugEnabled()) logger.debug("EXIT STARTUP");
+ }
+ }
+
+ /**
+ * This method is called upon plug-in deactivation
+ */
+ public void stop(BundleContext context) throws Exception
+ {
+ try
+ {
+ if (logger.isDebugEnabled()) logger.debug("ENTER SHUTDOWN");
+ doStop();
+ }
+ catch (Throwable t)
+ {
+ logger.error("Shutdown error", t);
+ }
+ finally
+ {
+ if (logger.isDebugEnabled()) logger.debug("EXIT SHUTDOWN");
+ }
+
+ super.stop(context);
+ resourceBundle = null;
+ }
+
+ /**
+ *
+ */
+ protected void doStart() throws Exception
+ {
+ }
+
+ /**
+ *
+ */
+ protected void doStop() throws Exception
+ {
+ }
+
+ /**
+ * Returns the string from the plugin's resource bundle,
+ * or 'key' if not found.
+ */
+ public String getResourceString(String key)
+ {
+ ResourceBundle bundle = getResourceBundle();
+
+ try
+ {
+ return (bundle != null) ? bundle.getString(key) : key;
+ }
+ catch (MissingResourceException e)
+ {
+ return key;
+ }
+ }
+
+ /**
+ * Returns the plugin's resource bundle,
+ */
+ public ResourceBundle getResourceBundle()
+ {
+ return resourceBundle;
+ }
+
+ /**
+ * @return Returns the bundleContext.
+ */
+ public BundleContext getBundleContext()
+ {
+ return bundleContext;
+ }
+
+ public String getBundleLocation() throws IOException
+ {
+ Bundle bundle = bundleContext.getBundle();
+ return getBundleLocation(bundle);
+ }
+
+ /**
+ * Progress monitor helpers
+ */
+ public static void checkCanceled(IProgressMonitor monitor)
+ {
+ if (monitor.isCanceled()) cancelOperation();
+ }
+
+ public static void cancelOperation()
+ {
+ throw new OperationCanceledException();
+ }
+
+ public static IProgressMonitor monitorFor(IProgressMonitor monitor)
+ {
+ if (monitor == null) return new NullProgressMonitor();
+ return monitor;
+ }
+
+ public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks)
+ {
+ if (monitor == null) return new NullProgressMonitor();
+ if (monitor instanceof NullProgressMonitor) return monitor;
+ return new SubProgressMonitor(monitor, ticks);
+ }
+
+ public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks, int style)
+ {
+ if (monitor == null) return new NullProgressMonitor();
+ if (monitor instanceof NullProgressMonitor) return monitor;
+ return new SubProgressMonitor(monitor, ticks, style);
+ }
+
+ public static String getBundleLocation(Bundle bundle) throws IOException
+ {
+ URL url = bundle.getEntry("/");
+ return FileLocator.toFileURL(url).getFile();
+ }
+
+ public void debug(String message)
+ {
+ logger.debug(message);
+ getLog().log(new Status(IStatus.INFO, pluginId, IStatus.OK, message, null));
+ }
+
+ public void warn(String message)
+ {
+ warn(message, null);
+ }
+
+ public void error(String message)
+ {
+ error(message, null);
+ }
+
+ public void warn(Throwable t)
+ {
+ warn(t.getMessage(), t);
+ }
+
+ public void error(Throwable t)
+ {
+ error(t.getMessage(), t);
+ }
+
+ public void warn(String message, Throwable t)
+ {
+ logger.warn(message, t);
+ getLog().log(new Status(IStatus.WARNING, pluginId, IStatus.OK, message, t));
+ }
+
+ public void error(String message, Throwable t)
+ {
+ logger.error(message, t);
+ getLog().log(new Status(IStatus.ERROR, pluginId, IStatus.OK, message, t));
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ClassLoaderFactory.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ClassLoaderFactory.java
new file mode 100644
index 0000000000..35978c3fb8
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ClassLoaderFactory.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util.eclipse;
+
+
+public interface ClassLoaderFactory
+{
+ public ClassLoader getClassLoader();
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/Element.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/Element.java
new file mode 100644
index 0000000000..51d2e0d28b
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/Element.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util.eclipse;
+
+
+import org.eclipse.net4j.util.BeanHelper;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+
+
+public class Element extends BeanHelper
+{
+ protected IConfigurationElement configurationElement;
+
+ public Element()
+ {
+ }
+
+ public void internalSetConfigurationElement(IConfigurationElement configurationElement)
+ {
+ this.configurationElement = configurationElement;
+ }
+
+ public void validate(ExtensionParser parser)
+ {
+ }
+
+ public IConfigurationElement configurationElement()
+ {
+ return configurationElement;
+ }
+
+ public IExtension declaringExtension()
+ {
+ return configurationElement.getDeclaringExtension();
+ }
+
+ public String name()
+ {
+ return configurationElement.getName();
+ }
+
+ public void dispatchChild(String name, Object value)
+ {
+ dispatchChild(this, name, value);
+ }
+
+ public void dispatchAttributeValue(String name, String value)
+ {
+ dispatchAttributeValue(this, name, value);
+ }
+
+ protected String executableExtensionPropertyName()
+ {
+ return "className";
+ }
+
+
+ public interface Factory
+ {
+ public Element createElementData();
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ElementRegistry.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ElementRegistry.java
new file mode 100644
index 0000000000..33255a609c
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ElementRegistry.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util.eclipse;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class ElementRegistry extends HashMap
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 3762810506670847288L;
+
+ public ElementRegistry()
+ {
+ super();
+ }
+
+ public ElementRegistry(int initialCapacity)
+ {
+ super(initialCapacity);
+ }
+
+ public ElementRegistry(int initialCapacity, float loadFactor)
+ {
+ super(initialCapacity, loadFactor);
+ }
+
+ public ElementRegistry(Map m)
+ {
+ super(m);
+ }
+
+ public Object put(Item value)
+ {
+ Object key = value.registryKey();
+ return super.put(key, value);
+ }
+
+
+ public interface Item
+ {
+ public Object registryKey();
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExamplePlugin.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExamplePlugin.java
new file mode 100644
index 0000000000..be57ddbeb4
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExamplePlugin.java
@@ -0,0 +1,36 @@
+package org.eclipse.net4j.util.eclipse;
+
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class ExamplePlugin extends AbstractPlugin
+{
+ //The shared instance.
+ private static ExamplePlugin plugin;
+
+ /**
+ * The constructor.
+ */
+ public ExamplePlugin()
+ {
+ if (plugin == null) plugin = this;
+ }
+
+ protected void doStart() throws Exception
+ {
+ }
+
+ public void doStop() throws Exception
+ {
+ plugin = null;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static ExamplePlugin getDefault()
+ {
+ return plugin;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExecutableElement.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExecutableElement.java
new file mode 100644
index 0000000000..04e4c64684
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExecutableElement.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util.eclipse;
+
+
+import org.eclipse.core.runtime.CoreException;
+
+
+public class ExecutableElement extends Element
+{
+ protected String className;
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public void setClassName(String className)
+ {
+ this.className = className;
+ }
+
+ public Object createExecutableExtension() throws CoreException
+ {
+ String propertyName = executableExtensionPropertyName();
+ return configurationElement.createExecutableExtension(propertyName);
+ }
+
+ public Object createExecutableExtension(String propertyName) throws CoreException
+ {
+ return configurationElement.createExecutableExtension(propertyName);
+ }
+
+ public String toString()
+ {
+ return "Executable(" + className + ")";
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExtensionConfigException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExtensionConfigException.java
new file mode 100644
index 0000000000..84aafea998
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExtensionConfigException.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util.eclipse;
+
+
+public class ExtensionConfigException extends RuntimeException
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 3979274633562501681L;
+
+ /**
+ *
+ */
+ public ExtensionConfigException()
+ {
+ super();
+ }
+
+ /**
+ * @param arg0
+ */
+ public ExtensionConfigException(String arg0)
+ {
+ super(arg0);
+ }
+
+ /**
+ * @param arg0
+ */
+ public ExtensionConfigException(Throwable arg0)
+ {
+ super(arg0);
+ }
+
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ public ExtensionConfigException(String arg0, Throwable arg1)
+ {
+ super(arg0, arg1);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExtensionParser.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExtensionParser.java
new file mode 100644
index 0000000000..d849193178
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExtensionParser.java
@@ -0,0 +1,182 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util.eclipse;
+
+
+import org.eclipse.net4j.util.ImplementationError;
+import org.eclipse.net4j.util.StringHelper;
+import org.eclipse.net4j.util.eclipse.Element.Factory;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+
+import org.apache.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+public class ExtensionParser
+{
+ protected Map elementDataFactoryRegistry = new HashMap();
+
+ protected List contextStack = new ArrayList();
+
+ private static final Logger logger = Logger.getLogger(ExtensionParser.class.getName());
+
+ public void parse(String extPointId)
+ {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint point = registry.getExtensionPoint(extPointId);
+
+ if (point == null)
+ {
+ String msg = "Extension point '" + extPointId + "' does not exist.";
+ logger.error(msg);
+ return;
+ }
+
+ parse(point);
+ }
+
+ public void parse(IExtensionPoint point)
+ {
+ IExtension[] extensions = point.getExtensions();
+ for (int i = 0; extensions != null && i < extensions.length; i++)
+ {
+ try
+ {
+ parse(extensions[i]);
+ }
+ catch (Throwable t)
+ {
+ String msg = "Error in plugin " + extensions[i].getNamespaceIdentifier()
+ + " while reading extension to " + point.getUniqueIdentifier();
+ logger.error(msg, t);
+ }
+ }
+ }
+
+ public Element[] parse(IExtension extension)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("Parsing plugin " + extension.getNamespaceIdentifier() + " (extension-point = "
+ + extension.getExtensionPointUniqueIdentifier() + ")");
+
+ IConfigurationElement[] elems = extension.getConfigurationElements();
+ return parse(elems);
+ }
+
+ public Element[] parse(IConfigurationElement[] elems)
+ {
+ Element[] result = new Element[elems.length];
+
+ for (int i = 0; i < elems.length; i++)
+ {
+ IConfigurationElement elem = elems[i];
+ result[i] = parse(elem);
+ }
+
+ if (logger.isDebugEnabled())
+ logger.debug("All extension data: " + StringHelper.implode(result, ", "));
+
+ return result;
+ }
+
+ public Element parse(IConfigurationElement elem)
+ {
+ pushContext(elem.getName());
+ String context = getContextString();
+
+ Element.Factory factory = findFactory(context);
+ if (factory == null)
+ throw new ExtensionConfigException("No element factory for context " + context);
+
+ Element elementData = factory.createElementData();
+ if (elementData == null)
+ throw new ExtensionConfigException("No element created for context " + context);
+ elementData.internalSetConfigurationElement(elem);
+
+ String[] attributeNames = elem.getAttributeNames();
+ for (int i = 0; i < attributeNames.length; i++)
+ {
+ String attributeName = attributeNames[i];
+ String attributeValue = elem.getAttribute(attributeName);
+
+ if (logger.isDebugEnabled())
+ logger.debug("Dispatching " + context + "." + attributeName + " = " + attributeValue);
+
+ elementData.dispatchAttributeValue(attributeName, attributeValue);
+ }
+
+ // Recurse
+ for (int i = 0; i < elem.getChildren().length; i++)
+ {
+ IConfigurationElement child = elem.getChildren()[i];
+ Element childData = parse(child);
+ elementData.dispatchChild(child.getName(), childData);
+ }
+
+ popContext();
+ validate(elementData);
+ return elementData;
+ }
+
+ public void addFactory(String contextPattern, Factory factory)
+ {
+ Pattern pattern = Pattern.compile(contextPattern);
+ elementDataFactoryRegistry.put(pattern, factory);
+ }
+
+ public Factory findFactory(String context)
+ {
+ for (Iterator it = elementDataFactoryRegistry.entrySet().iterator(); it.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+ Pattern pattern = (Pattern) entry.getKey();
+ Matcher matcher = pattern.matcher(context);
+ if (matcher.matches())
+ {
+ return (Factory) entry.getValue();
+ }
+ }
+ return null;
+ }
+
+ protected void pushContext(String elementName)
+ {
+ contextStack.add(elementName);
+ }
+
+ protected String popContext()
+ {
+ if (contextStack.isEmpty()) throw new ImplementationError("contextStack is empty");
+ return (String) contextStack.remove(contextStack.size() - 1);
+ }
+
+ protected String getContextString()
+ {
+ return StringHelper.implode(contextStack, "/");
+ }
+
+ protected void validate(Element elementData)
+ {
+ elementData.validate(this);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ListExtensionParser.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ListExtensionParser.java
new file mode 100644
index 0000000000..9ac17cda7a
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ListExtensionParser.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util.eclipse;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class ListExtensionParser extends ExtensionParser
+{
+ protected List list;
+
+ public ListExtensionParser()
+ {
+ }
+
+ public ListExtensionParser(List list)
+ {
+ this.list = list;
+ }
+
+ public List getList()
+ {
+ if (list == null)
+ {
+ list = new ArrayList();
+ }
+
+ return list;
+ }
+
+ public void setList(List list)
+ {
+ this.list = list;
+ }
+
+ protected void validate(Element elementData)
+ {
+ super.validate(elementData);
+ if (contextStack.isEmpty())
+ {
+ getList().add(elementData);
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/RegistryExtensionParser.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/RegistryExtensionParser.java
new file mode 100644
index 0000000000..710f96b51c
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/RegistryExtensionParser.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util.eclipse;
+
+
+public class RegistryExtensionParser extends ExtensionParser
+{
+ protected ElementRegistry registry;
+
+ public RegistryExtensionParser()
+ {
+ }
+
+ public RegistryExtensionParser(ElementRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ public ElementRegistry getRegistry()
+ {
+ if (registry == null)
+ {
+ registry = new ElementRegistry();
+ }
+
+ return registry;
+ }
+
+ public void setRegistry(ElementRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ protected void validate(Element elementData)
+ {
+ super.validate(elementData);
+
+ if (elementData instanceof ElementRegistry.Item)
+ {
+ getRegistry().put((ElementRegistry.Item) elementData);
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ResourcesHelper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ResourcesHelper.java
new file mode 100644
index 0000000000..33eeb165bc
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ResourcesHelper.java
@@ -0,0 +1,157 @@
+package org.eclipse.net4j.util.eclipse;
+
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+
+public class ResourcesHelper
+{
+ public static void writeFile(IFile file, String[] content, IProgressMonitor monitor)
+ throws CoreException
+ {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < content.length; i++)
+ {
+ String line = content[i];
+ buffer.append(line);
+ buffer.append("\n");
+ }
+
+ writeFile(file, buffer.toString(), monitor);
+ }
+
+ public static void writeFile(IFile file, String content, IProgressMonitor monitor)
+ throws CoreException
+ {
+ InputStream stream = new ByteArrayInputStream(content.getBytes());
+ writeFile(file, stream, monitor);
+ }
+
+ public static void writeFile(IFile file, InputStream content, IProgressMonitor monitor)
+ throws CoreException
+ {
+ if (file.exists())
+ {
+ file.setContents(content, false, true, monitor);
+ }
+ else
+ {
+ if (file.getParent() instanceof IFolder)
+ {
+ mkdirs((IFolder) file.getParent(), monitor);
+ }
+
+ file.create(content, true, monitor);
+ }
+ }
+
+ public static void mkdirs(IFolder folder, IProgressMonitor monitor) throws CoreException
+ {
+ if (folder != null && !folder.exists())
+ {
+ IContainer parent = folder.getParent();
+ if (parent != null && parent instanceof IFolder)
+ {
+ mkdirs((IFolder) parent, monitor);
+ }
+
+ folder.create(true, true, monitor);
+ }
+ }
+
+ public static String readFileIntoString(IFile file) throws CoreException, IOException
+ {
+ return readFileIntoString(file, null);
+ }
+
+ public static String readFileIntoString(IFile file, String linePrefix) throws CoreException,
+ IOException
+ {
+ BufferedReader br = new BufferedReader(new InputStreamReader(file.getContents()));
+ StringBuffer buffer = new StringBuffer();
+ String line;
+
+ while ((line = br.readLine()) != null)
+ {
+ if (linePrefix != null)
+ {
+ buffer.append(linePrefix);
+ }
+
+ buffer.append(line);
+ buffer.append("\n");
+ }
+
+ return buffer.toString();
+ }
+
+ public static String[] readFileIntoStringArray(IFile file) throws IOException, CoreException
+ {
+ return readFileIntoStringArray(file.getContents());
+ }
+
+ public static String[] readFileIntoStringArray(InputStream stream) throws IOException
+ {
+ BufferedReader br = new BufferedReader(new InputStreamReader(stream));
+ List result = new ArrayList();
+ String line;
+
+ while ((line = br.readLine()) != null)
+ {
+ result.add(line);
+ }
+
+ return (String[]) result.toArray(new String[result.size()]);
+ }
+
+ public static IProject ensureProject(String name) throws CoreException
+ {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+
+ if (!project.exists())
+ {
+ project.create(new NullProgressMonitor());
+ }
+
+ if (!project.isOpen())
+ {
+ project.open(new NullProgressMonitor());
+ }
+
+ return project;
+ }
+
+ public static IFolder ensureFolder(IContainer container, String path) throws CoreException
+ {
+ if (container == null)
+ {
+ container = ResourcesPlugin.getWorkspace().getRoot();
+ }
+
+ IFolder folder = container.getFolder(new Path(path));
+
+ if (!folder.exists())
+ {
+ folder.create(true, true, new NullProgressMonitor());
+ }
+
+ return folder;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/IStateMachine.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/IStateMachine.java
new file mode 100644
index 0000000000..9c5f2ff1e4
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/IStateMachine.java
@@ -0,0 +1,31 @@
+package org.eclipse.net4j.util.fsm;
+
+
+public interface IStateMachine<SUBJECT>
+{
+ public int getStateCount();
+
+ public int getEventCount();
+
+ public String getStateName(int state);
+
+ public String getEventName(int event);
+
+ public ITransition<SUBJECT> getIdentityTransition();
+
+ public void process(SUBJECT subject, int event, Object data) throws Exception;
+
+ public void handle(int state, int event, ITransition<SUBJECT> transition);
+
+ public void handle(int state, int event, int newState);
+
+ public void ignore(int state, int event);
+
+ public void cancel(int state, int event);
+
+
+ public interface ITransition<SUBJECT>
+ {
+ public void process(SUBJECT subject, int event, Object data) throws Exception;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/StateMachine.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/StateMachine.java
new file mode 100644
index 0000000000..2f5e991122
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/StateMachine.java
@@ -0,0 +1,149 @@
+package org.eclipse.net4j.util.fsm;
+
+
+import org.apache.log4j.Logger;
+
+
+public abstract class StateMachine<SUBJECT> implements IStateMachine<SUBJECT>
+{
+ private static final Logger logger = Logger.getLogger(StateMachine.class.getName());
+
+ private String[] stateNames;
+
+ private String[] eventNames;
+
+ private ITransition<SUBJECT>[][] matrix;
+
+ public StateMachine(String[] stateNames, String[] eventNames,
+ ITransition<SUBJECT> defaultTransition)
+ {
+ this.stateNames = stateNames;
+ this.eventNames = eventNames;
+
+ matrix = new ITransition[stateNames.length][eventNames.length];
+
+ if (defaultTransition != null)
+ {
+ for (int state = 0; state < stateNames.length; state++)
+ {
+ for (int event = 0; event < eventNames.length; event++)
+ {
+ handle(state, event, defaultTransition);
+ }
+ }
+ }
+ }
+
+ public StateMachine(String[] stateNames, String[] eventNames)
+ {
+ this(stateNames, eventNames, null);
+ }
+
+ public int getStateCount()
+ {
+ return stateNames.length;
+ }
+
+ public int getEventCount()
+ {
+ return eventNames.length;
+ }
+
+ public String getStateName(int state)
+ {
+ return stateNames[state];
+ }
+
+ public String getEventName(int event)
+ {
+ return eventNames[event];
+ }
+
+ public ITransition<SUBJECT> getIdentityTransition()
+ {
+ return new ITransition<SUBJECT>()
+ {
+ public void process(SUBJECT subject, int event, Object data) throws Exception
+ {
+ if (getLogger().isDebugEnabled())
+ {
+ int state = getState(subject);
+ getLogger().debug("Ignoring " + makeLabel(subject, state, event));
+ }
+ }
+ };
+ }
+
+ public void handle(int state, int event, ITransition<SUBJECT> transition)
+ {
+ matrix[state][event] = transition;
+ }
+
+ public void handle(int state, int event, final int newState)
+ {
+ handle(state, event, new ITransition<SUBJECT>()
+ {
+ public void process(SUBJECT subject, int event, Object data) throws Exception
+ {
+ setState(subject, newState);
+ }
+ });
+ }
+
+ public void ignore(int state, int event)
+ {
+ handle(state, event, getIdentityTransition());
+ }
+
+ public void cancel(int state, int event)
+ {
+ handle(state, event, null);
+ }
+
+ public void process(SUBJECT subject, int event, Object data) throws Exception
+ {
+ int state = getState(subject);
+ ITransition<SUBJECT> transition = matrix[state][event];
+
+ if (transition == null)
+ {
+ if (getLogger().isDebugEnabled())
+ {
+ getLogger().warn("Ignoring " + makeLabel(subject, state, event));
+ }
+
+ return;
+ }
+
+ if (getLogger().isDebugEnabled())
+ {
+ getLogger().debug("Processing " + makeLabel(subject, state, event));
+ }
+
+ transition.process(subject, event, data);
+
+ if (getLogger().isDebugEnabled())
+ {
+ int newState = getState(subject);
+ getLogger()
+ .debug(
+ "Finished " + makeLabel(subject, state, event) + ", newState="
+ + getStateName(newState));
+ }
+ }
+
+ protected Logger getLogger()
+ {
+ return logger;
+ }
+
+ protected String makeLabel(SUBJECT subject, int state, int event)
+ {
+ return "event " + eventNames[event] + " in state " + stateNames[state] + " for subject "
+ + subject;
+ }
+
+ protected abstract int getState(SUBJECT subject);
+
+ protected abstract void setState(SUBJECT subject, int state);
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/thread/DeadlockDetector.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/thread/DeadlockDetector.java
new file mode 100644
index 0000000000..4de5b55b89
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/thread/DeadlockDetector.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.net4j.util.thread;
+
+
+import org.eclipse.net4j.util.ImplementationError;
+import org.eclipse.net4j.util.ThreadInterruptedException;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+
+public final class DeadlockDetector
+{
+ public static boolean DETECTION = false;
+
+ public static final boolean COMPLETE_TRACE = true;
+
+ protected static final HashMap locks = new HashMap();
+
+ public static void preLock()
+ {
+ if (DETECTION)
+ {
+ Object old = locks.put(Thread.currentThread(), identifySource());
+ if (old != null) throw new ImplementationError("Don't nest deadlock detection!");
+ }
+ }
+
+ public static void postLock()
+ {
+ if (DETECTION) locks.remove(Thread.currentThread());
+ }
+
+ public static void sleep(long millis) throws ThreadInterruptedException
+ {
+ preLock();
+
+ try
+ {
+ Thread.sleep(millis);
+ }
+ catch (InterruptedException ex)
+ {
+ throw new ThreadInterruptedException(ex);
+ }
+ finally
+ {
+ postLock();
+ }
+ }
+
+ public static void wait(Object object) throws ThreadInterruptedException
+ {
+ preLock();
+
+ try
+ {
+ object.wait();
+ }
+ catch (InterruptedException ex)
+ {
+ throw new ThreadInterruptedException(ex);
+ }
+ finally
+ {
+ postLock();
+ }
+ }
+
+ public static void dump()
+ {
+ System.out.println();
+ System.out.println("Deadlock Detection Dump");
+ System.out.println("=====================================================================");
+
+ Map.Entry[] array = (Map.Entry[]) locks.entrySet().toArray(new Map.Entry[locks.size()]);
+ for (int i = 0; i < array.length; i++)
+ {
+ Entry entry = array[i];
+ Thread key = (Thread) entry.getKey();
+ String val = (String) entry.getValue();
+ System.out.println("Lock in " + key + "\n" + val);
+ }
+
+ System.out.println("=====================================================================");
+ System.out.println();
+ // locks.clear();
+ }
+
+ public static String identifySource()
+ {
+ class SourceIdentificationException extends Exception
+ {
+ private static final long serialVersionUID = 1L;
+ }
+
+ try
+ {
+ throw new SourceIdentificationException();
+ }
+ catch (SourceIdentificationException ex)
+ {
+ String ignore = DeadlockDetector.class.getName();
+ StackTraceElement[] frames = ex.getStackTrace();
+
+ for (int i = 0; i < frames.length; i++)
+ {
+ if (!frames[i].getClassName().equals(ignore))
+ {
+ if (!COMPLETE_TRACE) return frames[i].toString();
+
+ StringBuffer result = new StringBuffer();
+ for (int j = i; j < frames.length; j++)
+ {
+ result.append("\tat " + frames[j].toString() + "\n");
+ }
+ return result.toString();
+ }
+ }
+
+ throw new ImplementationError("identifySource() must not be called from inside the class "
+ + ignore);
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/thread/Worker.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/thread/Worker.java
new file mode 100644
index 0000000000..3bfce93de1
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/thread/Worker.java
@@ -0,0 +1,336 @@
+package org.eclipse.net4j.util.thread;
+
+
+import org.eclipse.net4j.util.ImplementationError;
+
+import org.apache.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+
+public abstract class Worker extends Thread
+{
+ public static final long TERMINATE = -1;
+
+ public static final long NO_PAUSE = 0;
+
+ /**
+ * Logger for this class
+ */
+ private static final Logger logger = Logger.getLogger(Worker.class);
+
+ private List progressListeners;
+
+ private List shutdownListeners;
+
+ private int progress;
+
+ private boolean running;
+
+ private Object waitMonitor;
+
+ /**
+ *
+ */
+ public Worker()
+ {
+ super();
+ }
+
+ /**
+ * @param target
+ */
+ public Worker(Runnable target)
+ {
+ super(target);
+ }
+
+ /**
+ * @param name
+ */
+ public Worker(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * @param group
+ * @param target
+ */
+ public Worker(ThreadGroup group, Runnable target)
+ {
+ super(group, target);
+ }
+
+ /**
+ * @param target
+ * @param name
+ */
+ public Worker(Runnable target, String name)
+ {
+ super(target, name);
+ }
+
+ /**
+ * @param group
+ * @param name
+ */
+ public Worker(ThreadGroup group, String name)
+ {
+ super(group, name);
+ }
+
+ /**
+ * @param group
+ * @param target
+ * @param name
+ */
+ public Worker(ThreadGroup group, Runnable target, String name)
+ {
+ super(group, target, name);
+ }
+
+ /**
+ * @param group
+ * @param target
+ * @param name
+ * @param stackSize
+ */
+ public Worker(ThreadGroup group, Runnable target, String name, long stackSize)
+ {
+ super(group, target, name, stackSize);
+ }
+
+ public String getLabel()
+ {
+ String name = getName();
+ return name == null ? toString() : name;
+ }
+
+ /**
+ * @return Returns the running.
+ */
+ public boolean isRunning()
+ {
+ return running;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Runnable#run()
+ */
+ public final void run()
+ {
+ notifyProgress();
+
+ try
+ {
+ while (running && !isInterrupted())
+ {
+ if (progress == Integer.MAX_VALUE)
+ {
+ progress = 0;
+ }
+ else
+ {
+ ++progress;
+ }
+
+ long pause = doWorkStep(progress);
+ notifyProgress();
+
+ if (pause == TERMINATE)
+ {
+ break;
+ }
+
+ if (pause > 0)
+ {
+ try
+ {
+ Thread.sleep(pause);
+ }
+ catch (InterruptedException ex)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("Interrupted while pausing worker " + getLabel());
+ break;
+ }
+ }
+ }
+ }
+ catch (Throwable t)
+ {
+ try
+ {
+ logger.error("Error in worker " + getLabel(), t);
+ }
+ catch (Exception ignore)
+ {
+ // Can happen due to already unloaded plugins (logging)!
+ }
+ }
+
+ notifyShutdown();
+ }
+
+ protected void doWait(Object object) throws InterruptedException
+ {
+ synchronized (this)
+ {
+ waitMonitor = object;
+ }
+
+ DeadlockDetector.wait(waitMonitor);
+
+ synchronized (this)
+ {
+ waitMonitor = null;
+ }
+
+ if (!running)
+ {
+ throw new InterruptedException();
+ }
+ }
+
+ /**
+ *
+ * @param progress
+ * @return The duration to sleep after this step in milliseconds.
+ */
+ protected abstract long doWorkStep(int progress);
+
+ /* (non-Javadoc)
+ * @see java.lang.Thread#start()
+ */
+ public final void start()
+ {
+ throw new ImplementationError("use startup()");
+ }
+
+ public void startup()
+ {
+ running = true;
+ super.start();
+ }
+
+ public void shutdown()
+ {
+ shutdown(0);
+ }
+
+ public void shutdown(long timeoutMillis)
+ {
+ if (logger.isDebugEnabled()) logger.debug("Shutting down worker " + getLabel());
+ running = false;
+
+ synchronized (this)
+ {
+ if (waitMonitor != null)
+ {
+ synchronized (waitMonitor)
+ {
+ waitMonitor.notifyAll();
+ }
+ }
+ }
+
+ try
+ {
+ join(timeoutMillis);
+ }
+ catch (InterruptedException ex)
+ {
+ if (logger.isDebugEnabled()) logger.debug(ex);
+ }
+
+ if (running)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("Shutdown timeout expired. Interrupting worker " + getLabel());
+
+ interrupt();
+
+ try
+ {
+ join();
+ }
+ catch (InterruptedException ex)
+ {
+ if (logger.isDebugEnabled()) logger.debug(ex);
+ }
+ }
+ }
+
+ public void addProgressListener(ProgressListener listener)
+ {
+ if (progressListeners == null)
+ {
+ progressListeners = new ArrayList();
+ }
+ progressListeners.add(listener);
+ }
+
+ public void removeProgressListener(ProgressListener listener)
+ {
+ if (progressListeners != null)
+ {
+ progressListeners.remove(listener);
+ }
+ }
+
+ public void addShutdownListener(ShutdownListener listener)
+ {
+ if (shutdownListeners == null)
+ {
+ shutdownListeners = new ArrayList();
+ }
+ shutdownListeners.add(listener);
+ }
+
+ public void removeShutdownListener(ShutdownListener listener)
+ {
+ if (shutdownListeners != null)
+ {
+ shutdownListeners.remove(listener);
+ }
+ }
+
+ protected void notifyProgress()
+ {
+ if (progressListeners != null)
+ {
+ for (Iterator it = progressListeners.iterator(); it.hasNext();)
+ {
+ ProgressListener listener = (ProgressListener) it.next();
+ listener.notifyProgress(this, progress);
+ }
+ }
+ }
+
+ protected void notifyShutdown()
+ {
+ if (shutdownListeners != null)
+ {
+ for (Iterator it = shutdownListeners.iterator(); it.hasNext();)
+ {
+ ShutdownListener listener = (ShutdownListener) it.next();
+ listener.notifyShutdown(this);
+ }
+ }
+ }
+
+
+ public interface ProgressListener
+ {
+ public void notifyProgress(Worker worker, int progress);
+ }
+
+
+ public interface ShutdownListener
+ {
+ public void notifyShutdown(Worker worker);
+ }
+} \ No newline at end of file

Back to the top