Graduation of the bundle from the equinox.incubator
diff --git a/bundles/org.eclipse.equinox.io/.classpath b/bundles/org.eclipse.equinox.io/.classpath
new file mode 100644
index 0000000..755d49b
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/OSGi%Minimum-1.0"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.eclipse.equinox.io/.cvsignore b/bundles/org.eclipse.equinox.io/.cvsignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/bundles/org.eclipse.equinox.io/.project b/bundles/org.eclipse.equinox.io/.project
new file mode 100644
index 0000000..8c9bd86
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.equinox.io</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/bundles/org.eclipse.equinox.io/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.io/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..d304116
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,331 @@
+#Thu Aug 16 11:00:59 EDT 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.builder.cleanOutputFolder=clean
+org.eclipse.jdt.core.builder.duplicateResourceTask=warning
+org.eclipse.jdt.core.builder.invalidClasspath=abort
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
+org.eclipse.jdt.core.circularClasspath=error
+org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
+org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.maxProblemPerUnit=1000
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=error
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=error
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.3
+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=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_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=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=false
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=false
+org.eclipse.jdt.core.formatter.comment.format_line_comments=false
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=false
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
+org.eclipse.jdt.core.formatter.comment.line_length=80
+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=do not 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=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not 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=do not 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=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=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_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_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=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=800
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false
+org.eclipse.jdt.core.formatter.tabulation.char=tab
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.incompatibleJDKLevel=ignore
+org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/bundles/org.eclipse.equinox.io/.settings/org.eclipse.jdt.ui.prefs b/bundles/org.eclipse.equinox.io/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..023a27a
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,57 @@
+#Tue Aug 21 11:19:11 CDT 2007
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=_core
+formatter_settings_version=11
+org.eclipse.jdt.ui.ignorelowercasenames=true
+org.eclipse.jdt.ui.importorder=;
+org.eclipse.jdt.ui.ondemandthreshold=3
+org.eclipse.jdt.ui.staticondemandthreshold=99
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=true
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_variable_declarations_final=true
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=false
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_trailing_whitespaces=false
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/bundles/org.eclipse.equinox.io/.settings/org.eclipse.pde.core.prefs b/bundles/org.eclipse.equinox.io/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 0000000..c37bbc4
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,3 @@
+#Thu Mar 29 10:30:40 EEST 2007
+eclipse.preferences.version=1
+pluginProject.extensions=false
diff --git a/bundles/org.eclipse.equinox.io/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.io/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..4a908f8
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/META-INF/MANIFEST.MF
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: IO Connector Service
+Bundle-SymbolicName: org.eclipse.equinox.io
+Bundle-Version: 0.1.0.qualifier
+Bundle-Vendor: Eclipse
+Bundle-Activator: org.eclipse.equinox.internal.io.impl.Activator
+Bundle-Description: This bundle contains service for creating connections.
+Import-Package:
+ javax.microedition.io,
+ org.eclipse.equinox.internal.util.hash;version="1.0.0",
+ org.eclipse.equinox.internal.util.pool;version="1.0.0",
+ org.eclipse.equinox.internal.util.ref;version="1.0.0",
+ org.osgi.framework;version="1.0",
+ org.osgi.service.io;version="1.0",
+ org.osgi.service.log;version="1.0.0",
+ org.osgi.util.tracker;version="1.2"
+Export-Package:
+ javax.microedition.io,
+ org.eclipse.equinox.internal.io; x-internal:=true,
+ org.eclipse.equinox.internal.io.impl; x-internal:=true,
+ org.eclipse.equinox.internal.io.util; x-internal:=true
+Bundle-RequiredExecutionEnvironment: OSGi/Minimum-1.0,
+ CDC-1.0/Foundation-1.0,
+ J2SE-1.2,
+ J2SE-1.3,
+ J2SE-1.4,
+ J2SE-1.5,
+ JavaSE-1.6,
+ CDC-1.1/Foundation-1.1
+Provided-Services: class=org.osgi.service.io.ConnectorService
diff --git a/bundles/org.eclipse.equinox.io/OSGI-INF/permissions.perm b/bundles/org.eclipse.equinox.io/OSGI-INF/permissions.perm
new file mode 100644
index 0000000..6cedcdd
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/OSGI-INF/permissions.perm
@@ -0,0 +1,18 @@
+(org.osgi.framework.PackagePermission "javax.microedition.io" "import")
+(org.osgi.framework.PackagePermission "org.osgi.service.io" "import")
+(org.osgi.framework.PackagePermission "org.osgi.service.log" "import")
+(org.osgi.framework.PackagePermission "org.osgi.util.tracker" "import")
+(org.osgi.framework.PackagePermission "org.osgi.framework" "import")
+(org.osgi.framework.PackagePermission "org.eclipse.equinox.internal.util.hash" "import")
+(org.osgi.framework.PackagePermission "org.eclipse.equinox.internal.util.pool" "import")
+(org.osgi.framework.PackagePermission "org.eclipse.equinox.internal.util.ref" "import")
+(org.osgi.framework.PackagePermission "org.eclipse.equinox.internal.io" "export")
+(org.osgi.framework.PackagePermission "org.eclipse.equinox.internal.io.impl" "export")
+(org.osgi.framework.PackagePermission "org.eclipse.equinox.internal.io.util" "export")
+(org.osgi.framework.PackagePermission "javax.microedition.io" "export")
+(org.osgi.framework.BundlePermission "*" "provide")
+(org.osgi.framework.BundlePermission "*" "host")
+(org.osgi.framework.ServicePermission "org.osgi.service.io.ConnectionFactory" "get")
+(org.osgi.framework.ServicePermission "org.osgi.service.io.ConnectorService" "register")
+(java.util.PropertyPermission "*" "read")
+(java.net.SocketPermission "*" "listen")
diff --git a/bundles/org.eclipse.equinox.io/about.html b/bundles/org.eclipse.equinox.io/about.html
new file mode 100644
index 0000000..40e147d
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>January 15, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/bundles/org.eclipse.equinox.io/build.properties b/bundles/org.eclipse.equinox.io/build.properties
new file mode 100644
index 0000000..9cbab3c
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ about.html
+src.includes = about.html
diff --git a/bundles/org.eclipse.equinox.io/src/javax/microedition/io/Connection.java b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/Connection.java
new file mode 100644
index 0000000..1d5fffd
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/Connection.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package javax.microedition.io;
+
+public abstract interface Connection {
+
+ public abstract void close() throws java.io.IOException;
+
+}
diff --git a/bundles/org.eclipse.equinox.io/src/javax/microedition/io/ConnectionNotFoundException.java b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/ConnectionNotFoundException.java
new file mode 100644
index 0000000..68a9016
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/ConnectionNotFoundException.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package javax.microedition.io;
+
+public class ConnectionNotFoundException extends java.io.IOException {
+
+ private static final long serialVersionUID = 1L;
+
+ public ConnectionNotFoundException() {
+ }
+
+ public ConnectionNotFoundException(java.lang.String var0) {
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.io/src/javax/microedition/io/Connector.java b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/Connector.java
new file mode 100644
index 0000000..dceb48e
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/Connector.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package javax.microedition.io;
+
+public class Connector {
+
+ private Connector() {
+ }
+
+ public static javax.microedition.io.Connection open(java.lang.String var0) throws java.io.IOException {
+ return null;
+ }
+
+ public static javax.microedition.io.Connection open(java.lang.String var0, int var1) throws java.io.IOException {
+ return null;
+ }
+
+ public static javax.microedition.io.Connection open(java.lang.String var0, int var1, boolean var2) throws java.io.IOException {
+ return null;
+ }
+
+ public static java.io.DataInputStream openDataInputStream(java.lang.String var0) throws java.io.IOException {
+ return null;
+ }
+
+ public static java.io.DataOutputStream openDataOutputStream(java.lang.String var0) throws java.io.IOException {
+ return null;
+ }
+
+ public static java.io.InputStream openInputStream(java.lang.String var0) throws java.io.IOException {
+ return null;
+ }
+
+ public static java.io.OutputStream openOutputStream(java.lang.String var0) throws java.io.IOException {
+ return null;
+ }
+
+ public final static int READ = 1;
+
+ public final static int WRITE = 2;
+
+ public final static int READ_WRITE = 3;
+
+}
diff --git a/bundles/org.eclipse.equinox.io/src/javax/microedition/io/ContentConnection.java b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/ContentConnection.java
new file mode 100644
index 0000000..8064b2f
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/ContentConnection.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package javax.microedition.io;
+
+public abstract interface ContentConnection extends javax.microedition.io.StreamConnection {
+
+ public abstract java.lang.String getEncoding();
+
+ public abstract long getLength();
+
+ public abstract java.lang.String getType();
+
+}
diff --git a/bundles/org.eclipse.equinox.io/src/javax/microedition/io/Datagram.java b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/Datagram.java
new file mode 100644
index 0000000..b59b5bf
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/Datagram.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package javax.microedition.io;
+
+public abstract interface Datagram extends java.io.DataInput, java.io.DataOutput {
+
+ public abstract java.lang.String getAddress();
+
+ public abstract byte[] getData();
+
+ public abstract int getLength();
+
+ public abstract int getOffset();
+
+ public abstract void reset();
+
+ public abstract void setAddress(javax.microedition.io.Datagram var0);
+
+ public abstract void setAddress(java.lang.String var0) throws java.io.IOException;
+
+ public abstract void setData(byte[] var0, int var1, int var2);
+
+ public abstract void setLength(int var0);
+
+}
diff --git a/bundles/org.eclipse.equinox.io/src/javax/microedition/io/DatagramConnection.java b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/DatagramConnection.java
new file mode 100644
index 0000000..b97d452
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/DatagramConnection.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package javax.microedition.io;
+
+public abstract interface DatagramConnection extends javax.microedition.io.Connection {
+
+ public abstract int getMaximumLength() throws java.io.IOException;
+
+ public abstract int getNominalLength() throws java.io.IOException;
+
+ public abstract javax.microedition.io.Datagram newDatagram(byte[] var0, int var1) throws java.io.IOException;
+
+ public abstract javax.microedition.io.Datagram newDatagram(byte[] var0, int var1, java.lang.String var2) throws java.io.IOException;
+
+ public abstract javax.microedition.io.Datagram newDatagram(int var0) throws java.io.IOException;
+
+ public abstract javax.microedition.io.Datagram newDatagram(int var0, java.lang.String var1) throws java.io.IOException;
+
+ public abstract void receive(javax.microedition.io.Datagram var0) throws java.io.IOException;
+
+ public abstract void send(javax.microedition.io.Datagram var0) throws java.io.IOException;
+
+}
diff --git a/bundles/org.eclipse.equinox.io/src/javax/microedition/io/HttpConnection.java b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/HttpConnection.java
new file mode 100644
index 0000000..6a3bb45
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/HttpConnection.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package javax.microedition.io;
+
+public abstract interface HttpConnection extends javax.microedition.io.ContentConnection {
+
+ public abstract long getDate() throws java.io.IOException;
+
+ public abstract long getExpiration() throws java.io.IOException;
+
+ public abstract java.lang.String getFile();
+
+ public abstract java.lang.String getHeaderField(int var0) throws java.io.IOException;
+
+ public abstract java.lang.String getHeaderField(java.lang.String var0) throws java.io.IOException;
+
+ public abstract long getHeaderFieldDate(java.lang.String var0, long var1) throws java.io.IOException;
+
+ public abstract int getHeaderFieldInt(java.lang.String var0, int var1) throws java.io.IOException;
+
+ public abstract java.lang.String getHeaderFieldKey(int var0) throws java.io.IOException;
+
+ public abstract java.lang.String getHost();
+
+ public abstract long getLastModified() throws java.io.IOException;
+
+ public abstract int getPort();
+
+ public abstract java.lang.String getProtocol();
+
+ public abstract java.lang.String getQuery();
+
+ public abstract java.lang.String getRef();
+
+ public abstract java.lang.String getRequestMethod();
+
+ public abstract java.lang.String getRequestProperty(java.lang.String var0);
+
+ public abstract int getResponseCode() throws java.io.IOException;
+
+ public abstract java.lang.String getResponseMessage() throws java.io.IOException;
+
+ public abstract java.lang.String getURL();
+
+ public abstract void setRequestMethod(java.lang.String var0) throws java.io.IOException;
+
+ public abstract void setRequestProperty(java.lang.String var0, java.lang.String var1) throws java.io.IOException;
+
+ public final static java.lang.String GET = "GET";
+
+ public final static java.lang.String HEAD = "HEAD";
+
+ public final static java.lang.String POST = "POST";
+
+ public final static int HTTP_ACCEPTED = 202;
+
+ public final static int HTTP_BAD_GATEWAY = 502;
+
+ public final static int HTTP_BAD_METHOD = 405;
+
+ public final static int HTTP_BAD_REQUEST = 400;
+
+ public final static int HTTP_CLIENT_TIMEOUT = 408;
+
+ public final static int HTTP_CONFLICT = 409;
+
+ public final static int HTTP_CREATED = 201;
+
+ public final static int HTTP_ENTITY_TOO_LARGE = 413;
+
+ public final static int HTTP_EXPECT_FAILED = 417;
+
+ public final static int HTTP_FORBIDDEN = 403;
+
+ public final static int HTTP_GATEWAY_TIMEOUT = 504;
+
+ public final static int HTTP_GONE = 410;
+
+ public final static int HTTP_INTERNAL_ERROR = 500;
+
+ public final static int HTTP_LENGTH_REQUIRED = 411;
+
+ public final static int HTTP_MOVED_PERM = 301;
+
+ public final static int HTTP_MOVED_TEMP = 302;
+
+ public final static int HTTP_MULT_CHOICE = 300;
+
+ public final static int HTTP_NO_CONTENT = 204;
+
+ public final static int HTTP_NOT_ACCEPTABLE = 406;
+
+ public final static int HTTP_NOT_AUTHORITATIVE = 203;
+
+ public final static int HTTP_NOT_FOUND = 404;
+
+ public final static int HTTP_NOT_IMPLEMENTED = 501;
+
+ public final static int HTTP_NOT_MODIFIED = 304;
+
+ public final static int HTTP_OK = 200;
+
+ public final static int HTTP_PARTIAL = 206;
+
+ public final static int HTTP_PAYMENT_REQUIRED = 402;
+
+ public final static int HTTP_PRECON_FAILED = 412;
+
+ public final static int HTTP_PROXY_AUTH = 407;
+
+ public final static int HTTP_REQ_TOO_LONG = 414;
+
+ public final static int HTTP_RESET = 205;
+
+ public final static int HTTP_SEE_OTHER = 303;
+
+ public final static int HTTP_TEMP_REDIRECT = 307;
+
+ public final static int HTTP_UNAUTHORIZED = 401;
+
+ public final static int HTTP_UNAVAILABLE = 503;
+
+ public final static int HTTP_UNSUPPORTED_RANGE = 416;
+
+ public final static int HTTP_UNSUPPORTED_TYPE = 415;
+
+ public final static int HTTP_USE_PROXY = 305;
+
+ public final static int HTTP_VERSION = 505;
+
+}
diff --git a/bundles/org.eclipse.equinox.io/src/javax/microedition/io/InputConnection.java b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/InputConnection.java
new file mode 100644
index 0000000..c738f18
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/InputConnection.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package javax.microedition.io;
+
+public abstract interface InputConnection extends javax.microedition.io.Connection {
+
+ public abstract java.io.DataInputStream openDataInputStream() throws java.io.IOException;
+
+ public abstract java.io.InputStream openInputStream() throws java.io.IOException;
+
+}
diff --git a/bundles/org.eclipse.equinox.io/src/javax/microedition/io/OutputConnection.java b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/OutputConnection.java
new file mode 100644
index 0000000..e03cbea
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/OutputConnection.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package javax.microedition.io;
+
+public abstract interface OutputConnection extends javax.microedition.io.Connection {
+
+ public abstract java.io.DataOutputStream openDataOutputStream() throws java.io.IOException;
+
+ public abstract java.io.OutputStream openOutputStream() throws java.io.IOException;
+
+}
diff --git a/bundles/org.eclipse.equinox.io/src/javax/microedition/io/StreamConnection.java b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/StreamConnection.java
new file mode 100644
index 0000000..aecb893
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/StreamConnection.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package javax.microedition.io;
+
+public abstract interface StreamConnection extends javax.microedition.io.InputConnection, javax.microedition.io.OutputConnection {
+
+}
diff --git a/bundles/org.eclipse.equinox.io/src/javax/microedition/io/StreamConnectionNotifier.java b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/StreamConnectionNotifier.java
new file mode 100644
index 0000000..9b718bf
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/StreamConnectionNotifier.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package javax.microedition.io;
+
+public abstract interface StreamConnectionNotifier extends javax.microedition.io.Connection {
+
+ public abstract javax.microedition.io.StreamConnection acceptAndOpen() throws java.io.IOException;
+
+}
diff --git a/bundles/org.eclipse.equinox.io/src/javax/microedition/io/package.html b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/package.html
new file mode 100644
index 0000000..84f3c6f
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/javax/microedition/io/package.html
@@ -0,0 +1,9 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html">
+</head>
+<body bgcolor="#FFFFFF">
+The classes for the generic connections.
+</body>
+</html>
diff --git a/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/ConnectionListener.java b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/ConnectionListener.java
new file mode 100644
index 0000000..c698fe2
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/ConnectionListener.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.io;
+
+import java.util.EventListener;
+import javax.microedition.io.Connection;
+
+/**
+ * Interface for a listener that will receive notification when the connection
+ * is created and when is closed.
+ * <p>
+ * Listener is notified for creation of the connection only when the connector
+ * service creates connection that implements only this and the Connection
+ * interface, when the needed IOProvider is not available at the moment of
+ * creation. When the provider becomes available then all registered listeners
+ * will receive event
+ * <p>
+ * <code>CONNECTION_CREATED</code> and the created connection. Event
+ * <code>CONNECTION_CLOSED</code> must be send from every connection that
+ * implements this interface when it is closing.
+ *
+ * @author Pavlin Dobrev
+ * @version 1.0
+ */
+
+public interface ConnectionListener extends EventListener {
+ /**
+ * Constant for event type created
+ */
+ public static final int CONNECTION_CREATED = 0;
+ /**
+ * Constant for event type closed
+ */
+ public static final int CONNECTION_CLOSED = 1;
+
+ /**
+ * Receives notification that a connection has been created or closed.
+ */
+ public void notify(String uri, int eventType, Connection conn);
+
+}
diff --git a/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/ConnectionNotifier.java b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/ConnectionNotifier.java
new file mode 100644
index 0000000..86029c6
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/ConnectionNotifier.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.io;
+
+/**
+ * Provides methods for registering listeners for receiving events from a
+ * connection (that implements this interface).
+ *
+ * @author Pavlin Dobrev
+ * @version 1.0
+ */
+
+public interface ConnectionNotifier {
+ /**
+ * Adds the given listener to the set of listeners that will be notified
+ * when the connection is created or closed.
+ */
+ public void addConnectionListener(ConnectionListener l);
+
+ /**
+ * Removes the given listener from the set of listeners that will be
+ * notified when the connection is created or closed.
+ */
+ public void removeConnectionListener(ConnectionListener l);
+}
diff --git a/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/RandomAccessConnection.java b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/RandomAccessConnection.java
new file mode 100644
index 0000000..c550e5e
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/RandomAccessConnection.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.io;
+
+import java.io.*;
+import javax.microedition.io.InputConnection;
+import javax.microedition.io.OutputConnection;
+
+/**
+ * @author Pavlin Dobrev
+ * @version 1.0
+ */
+
+public interface RandomAccessConnection extends InputConnection, OutputConnection, DataInput, DataOutput {
+
+ public long length() throws IOException;
+
+ public long getFilePointer() throws IOException;
+
+ public boolean isSelected();
+
+ public int read() throws IOException;
+
+ public int read(byte[] buff, int off, int len) throws IOException;
+
+ public void seek(long len) throws IOException;
+
+ public void write(int b) throws IOException;
+
+ public void write(byte[] buff, int off, int len) throws IOException;
+
+ public void flush() throws IOException;
+}
diff --git a/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/impl/Activator.java b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/impl/Activator.java
new file mode 100644
index 0000000..f159f87
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/impl/Activator.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.io.impl;
+
+import org.eclipse.equinox.internal.util.ref.Log;
+import org.osgi.framework.*;
+
+/**
+ * @author Pavlin Dobrev
+ * @version 1.0
+ */
+
+public class Activator implements BundleActivator {
+
+ public static BundleContext bc = null;
+ private ConnectorServiceImpl connector;
+ private Log log;
+
+ public void start(BundleContext bc) throws BundleException {
+ Activator.bc = bc;
+ log = new Log(bc, false);
+ log.setDebug(getBoolean("equinox.connector.debug"));
+ log.setPrintOnConsole(getBoolean("equinox.connector.console"));
+ if (log.getDebug()) {
+ log.setMaps(TracerConfigConnector.getMap(), null);
+ }
+ connector = new ConnectorServiceImpl(bc, log);
+ }
+
+ public void stop(BundleContext bc) {
+ if (connector != null) {
+ connector.close();
+ connector = null;
+ log.close();
+ }
+ bc = null;
+ }
+
+ public static boolean getBoolean(String property) {
+ String prop = (bc != null) ? bc.getProperty(property) : System.getProperty(property);
+ return ((prop != null) && prop.equalsIgnoreCase("true"));
+ }
+
+ public static int getInteger(String property, int defaultValue) {
+ String prop = (bc != null) ? bc.getProperty(property) : System.getProperty(property);
+ if (prop != null) {
+ try {
+ return Integer.decode(prop).intValue();
+ } catch (NumberFormatException e) {
+ //do nothing
+ }
+ }
+ return defaultValue;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/impl/ConnectionFactoryListener.java b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/impl/ConnectionFactoryListener.java
new file mode 100644
index 0000000..bdce47f
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/impl/ConnectionFactoryListener.java
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.io.impl;
+
+import java.io.IOException;
+import java.util.*;
+import javax.microedition.io.Connection;
+import org.eclipse.equinox.internal.io.impl.PrivilegedRunner.PrivilegedDispatcher;
+import org.osgi.framework.*;
+import org.osgi.service.io.ConnectionFactory;
+
+/**
+ * @author Pavlin Dobrev
+ * @version 1.0
+ */
+
+public class ConnectionFactoryListener implements ServiceListener, PrivilegedDispatcher {
+ private static Hashtable urlToConN = new Hashtable(5);
+ private BundleContext bc;
+
+ public ConnectionFactoryListener(BundleContext bc) {
+ this.bc = bc;
+
+ try {
+ bc.addServiceListener(this, '(' + Constants.OBJECTCLASS + '=' + ConnectionFactory.class.getName() + ')');
+ } catch (InvalidSyntaxException ex) {
+ // Ignored - syntax is right!
+ }
+ }
+
+ public void close() {
+ bc.removeServiceListener(this);
+
+ if (!urlToConN.isEmpty()) {
+ Vector copyV = new Vector(urlToConN.size());
+
+ for (Enumeration en = urlToConN.elements(); en.hasMoreElements();) {
+ copyV.addElement(en.nextElement());
+ }
+
+ for (Enumeration en = copyV.elements(); en.hasMoreElements();) {
+ ConnectionNotifierImpl cn = (ConnectionNotifierImpl) en.nextElement();
+ try {
+ cn.close();
+ } catch (IOException ex) {
+ }
+ }
+ }
+ }
+
+ static void removeConnectionNotifier(String url) {
+ urlToConN.remove(url);
+ }
+
+ static int count = 0;
+
+ static Connection getConnectionNotifier(String scheme, String url, int mode, boolean timeouts, String filter, int count) throws IOException {
+ ConnectionNotifierImpl ret = null;
+ synchronized (urlToConN) {
+ if (urlToConN.containsKey(url)) {
+ return (Connection) urlToConN.get(url);
+ }
+
+ ret = new ConnectionNotifierImpl(scheme, url, mode, timeouts, filter);
+ urlToConN.put(url, ret);
+ if (count == ConnectionFactoryListener.count)
+ return ret;
+ }
+
+ Connection c = ConnectorServiceImpl.getConnection(filter, url, mode, timeouts, false);
+ if (c != null) {
+ if (ret.hasListeners())
+ ret.notifyCreated(c);
+ else
+ ret.close();
+ }
+ return c;
+ }
+
+ public void serviceChanged(ServiceEvent event) {
+ if (event.getType() == ServiceEvent.REGISTERED && !urlToConN.isEmpty()) {
+ ServiceReference ref = event.getServiceReference();
+ ConnectionFactory factory = (ConnectionFactory) bc.getService(ref);
+ String[] schemes = (String[]) ref.getProperty(ConnectionFactory.IO_SCHEME);
+
+ Vector toNotify = new Vector(urlToConN.size());
+ synchronized (urlToConN) {
+ for (Enumeration en = urlToConN.elements(); en.hasMoreElements();) {
+ ConnectionNotifierImpl cn = (ConnectionNotifierImpl) en.nextElement();
+ if (match(schemes, cn.scheme))
+ toNotify.addElement(cn);
+ }
+ }
+ for (int i = 0; i < toNotify.size(); i++) {
+ ConnectionNotifierImpl cn = (ConnectionNotifierImpl) toNotify.elementAt(i);
+ try {
+ if (cn.context != null) {
+ PrivilegedRunner.doPrivileged(cn.context, this, 0, cn, factory, null, null);
+ return;
+ }
+ Connection connection = factory.createConnection(cn.url, cn.mode, cn.timeouts);
+ if (cn.hasListeners())
+ cn.notifyCreated(connection);
+ else
+ cn.close();
+ } catch (Throwable ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ bc.ungetService(ref);
+ }
+ }
+
+ static boolean match(String[] schemes, String scheme) {
+ if (schemes != null && scheme != null) {
+ for (int i = 0; i < schemes.length; i++) {
+ if (scheme.equals(schemes[i])) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.equinox.internal.io.impl.PrivilegedRunner.PrivilegedDispatcher#dispatchPrivileged(int,
+ * java.lang.Object, java.lang.Object, java.lang.Object,
+ * java.lang.Object)
+ */
+ public Object dispatchPrivileged(int type, Object arg1, Object arg2, Object arg3, Object arg4) throws Exception {
+ ConnectionNotifierImpl cn = (ConnectionNotifierImpl) arg1;
+ ConnectionFactory factory = (ConnectionFactory) arg2;
+ Connection connection = factory.createConnection(cn.url, cn.mode, cn.timeouts);
+ if (cn.hasListeners()) {
+ cn.notifyCreated(connection);
+ } else {
+ cn.close();
+ }
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/impl/ConnectionNotifierImpl.java b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/impl/ConnectionNotifierImpl.java
new file mode 100644
index 0000000..c5fbf4a
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/impl/ConnectionNotifierImpl.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.io.impl;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Vector;
+import javax.microedition.io.Connection;
+import org.eclipse.equinox.internal.io.ConnectionListener;
+import org.eclipse.equinox.internal.io.ConnectionNotifier;
+
+/**
+ * @author Pavlin Dobrev
+ * @version 1.0
+ */
+
+class ConnectionNotifierImpl implements ConnectionNotifier, Connection {
+ private Vector list;
+ String scheme;
+ int mode;
+ boolean timeouts;
+ String url;
+ String filter;
+
+ boolean notified = false;
+ Object context;
+
+ ConnectionNotifierImpl(String scheme, String url, int mode, boolean timeouts, String filter) {
+ list = new Vector(3, 5);
+ this.scheme = scheme;
+ this.url = url;
+ this.mode = mode;
+ this.timeouts = timeouts;
+ this.filter = filter;
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ context = System.getSecurityManager().getSecurityContext();
+ }
+
+ public void addConnectionListener(ConnectionListener l) {
+ long timeStart = 0;
+ if (ConnectorServiceImpl.hasDebug) {
+ ConnectorServiceImpl.debug(16050, l.getClass().getName(), null);
+ timeStart = System.currentTimeMillis();
+ }
+ try {
+ synchronized (list) {
+ if (!notified) {
+ if (!list.contains(l))
+ list.addElement(l);
+ return;
+ }
+ }
+ Connection c = ConnectorServiceImpl.getConnection(filter, url, mode, timeouts, false);
+ if (c != null)
+ l.notify(url, ConnectionListener.CONNECTION_CREATED, c);
+ } catch (Exception exc) {
+ } finally {
+ if (ConnectorServiceImpl.hasDebug) {
+ ConnectorServiceImpl.debug(16051, String.valueOf(System.currentTimeMillis() - timeStart), null);
+ }
+ }
+ }
+
+ public void removeConnectionListener(ConnectionListener l) {
+ if (ConnectorServiceImpl.hasDebug) {
+ ConnectorServiceImpl.debug(16052, l.getClass().getName(), null);
+ }
+ list.removeElement(l);
+ }
+
+ boolean hasListeners() {
+ return !list.isEmpty();
+ }
+
+ void notifyCreated(Connection conn) {
+ notify(ConnectionListener.CONNECTION_CREATED, conn);
+ }
+
+ private void notify(int eventType, Connection conn) {
+ if (eventType != ConnectionListener.CONNECTION_CREATED && eventType != ConnectionListener.CONNECTION_CLOSED) {
+ return;
+ }
+
+ synchronized (list) {
+ if (notified)
+ return;
+ notified = true;
+ }
+ ConnectionFactoryListener.removeConnectionNotifier(url);
+ for (Enumeration en = list.elements(); en.hasMoreElements();) {
+ ConnectionListener l = (ConnectionListener) en.nextElement();
+ l.notify(url, eventType, conn);
+ }
+ }
+
+ public void close() throws IOException {
+ if (ConnectorServiceImpl.hasDebug) {
+ ConnectorServiceImpl.debug(16053, url, null);
+ }
+ synchronized (list) {
+ if (notified)
+ return;
+ notified = true;
+ }
+ ConnectionFactoryListener.removeConnectionNotifier(url);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/impl/ConnectorServiceImpl.java b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/impl/ConnectorServiceImpl.java
new file mode 100644
index 0000000..e9217f9
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/impl/ConnectorServiceImpl.java
@@ -0,0 +1,401 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.io.impl;
+
+import java.io.*;
+import javax.microedition.io.*;
+import org.eclipse.equinox.internal.util.ref.Log;
+import org.osgi.framework.*;
+import org.osgi.service.io.ConnectionFactory;
+import org.osgi.service.io.ConnectorService;
+
+/**
+ * ConnectorService implementation.
+ *
+ * @author Pavlin Dobrev
+ * @version 1.0
+ */
+
+public class ConnectorServiceImpl implements ConnectorService {
+ static BundleContext bc;
+ ServiceRegistration reg;
+ ConnectionFactoryListener listener;
+
+ static boolean enableNotification = Activator.getBoolean("eclipse.io.enable.notification");
+ public static boolean hasDebug;
+ private static Log log;
+
+ public ConnectorServiceImpl(BundleContext bc, Log log) {
+ ConnectorServiceImpl.log = log;
+ ConnectorServiceImpl.hasDebug = log.getDebug();
+ init(bc);
+ }
+
+ public static void debug(int id, String message, Throwable t) {
+ log.debug(0x1200, id, message, t, false);
+ }
+
+ public ConnectorServiceImpl(BundleContext bc) {
+ init(bc);
+ }
+
+ private void init(BundleContext bc) {
+ ConnectorServiceImpl.bc = bc;
+
+ if (enableNotification) {
+ listener = new ConnectionFactoryListener(bc);
+ }
+
+ reg = bc.registerService(ConnectorService.class.getName(), this, null);
+ }
+
+ public void close() {
+ reg.unregister();
+
+ if (listener != null) {
+ listener.close();
+ }
+ }
+
+ public Connection open(String uri) throws IOException {
+ return open(uri, READ_WRITE);
+ }
+
+ public Connection open(String uri, int mode) throws IOException {
+ return open(uri, mode, false);
+ }
+
+ static char[] chars = {'~', '='};
+
+ public Connection open(String uri, int mode, boolean timeouts) throws IOException {
+ long timeStart = 0;
+ if (hasDebug) {
+ debug(16001, uri + ", " + (mode == READ_WRITE ? "READ_WRITE" : (mode == READ) ? "READ" : "WRITE"), null);
+ timeStart = System.currentTimeMillis();
+ }
+ try {
+ if (uri == null) {
+ throw new IllegalArgumentException("URL cannot be NULL!");
+ }
+
+ int sPos = uri.indexOf(":");
+
+ if (sPos < 1) { // scheme must be at least with 1 symbol
+ throw new IllegalArgumentException("Does not have scheme");
+ }
+
+ String scheme = uri.substring(0, sPos);
+ StringBuffer filter = new StringBuffer(scheme.length() + 13);
+ filter.append('(');
+ filter.append(ConnectionFactory.IO_SCHEME);
+ filter.append(chars);
+ filter.append(scheme);
+ filter.append(')');
+
+ int count = 0;
+ if (listener != null)
+ count = ConnectionFactoryListener.count;
+ Connection c = getConnection(filter.toString(), uri, mode, timeouts, true);
+
+ if (c == null && listener != null)
+ c = ConnectionFactoryListener.getConnectionNotifier(scheme, uri, mode, timeouts, filter.toString(), count);
+ if (c == null)
+ throw new ConnectionNotFoundException("Failed to create connection " + uri);
+ return c;
+ } finally {
+ if (hasDebug) {
+ debug(16002, String.valueOf(System.currentTimeMillis() - timeStart), null);
+ }
+ }
+ }
+
+ static protected Connection getConnection(String filter, String uri, int mode, boolean timeouts, boolean connector) throws IOException {
+ ServiceReference[] cfRefs = null;
+ Connection ret = null;
+ try {
+ cfRefs = bc.getServiceReferences(ConnectionFactory.class.getName(), filter);
+ } catch (InvalidSyntaxException ex) {
+ }
+
+ if (cfRefs != null) {
+ sort(cfRefs, 0, cfRefs.length);
+ }
+
+ IOException ioExc = null;
+ boolean not_found = false;
+ if (cfRefs != null)
+ for (int i = 0; i < cfRefs.length; i++) {
+ ConnectionFactory prov = (ConnectionFactory) bc.getService(cfRefs[i]);
+ if (prov != null)
+ try {
+ not_found = true;
+ ret = prov.createConnection(uri, mode, timeouts);
+ } catch (IOException e) {
+ if (hasDebug) {
+ debug(16003, prov.getClass().getName(), e);
+ }
+ if (ioExc == null)
+ ioExc = e;
+ } finally {
+ if (ret == null)
+ bc.ungetService(cfRefs[i]);
+ else {
+ if (hasDebug) {
+ debug(16004, prov.getClass().getName(), null);
+ }
+ return ret;
+ }
+ }
+ }
+
+ if (connector)
+ try {
+ ret = Connector.open(uri, mode, timeouts);
+ } catch (ConnectionNotFoundException ignore) { // returns null ->
+ // ConnectionNotifier
+ // is created
+ debug(16014, null, ignore);
+ } finally {
+ if (ret == null) {
+ if (ioExc != null)
+ throw ioExc;
+ if (not_found)
+ throw new ConnectionNotFoundException("Failed to create connection " + uri);
+
+ } else {
+ if (hasDebug) {
+ debug(16005, null, null);
+ }
+ }
+ }
+ return ret;
+ }
+
+ private static void sort(ServiceReference[] array, int start, int end) {
+ int middle = (start + end) / 2;
+ if (start + 1 < middle)
+ sort(array, start, middle);
+ if (middle + 1 < end)
+ sort(array, middle, end);
+ if (start + 1 >= end)
+ return; // this case can only happen when this method is called by
+ // the user
+
+ if (getRanking(array[middle - 1]) == getRanking(array[middle])) {
+ if (getServiceID(array[middle - 1]) < getServiceID(array[middle])) {
+ return;
+ }
+ } else if (getRanking(array[middle - 1]) >= getRanking(array[middle])) {
+ return;
+ }
+
+ if (start + 2 == end) {
+ ServiceReference temp = array[start];
+ array[start] = array[middle];
+ array[middle] = temp;
+ return;
+ }
+ int i1 = start, i2 = middle, i3 = 0;
+ Object[] merge = new Object[end - start];
+ while (i1 < middle && i2 < end) {
+ if (getRanking(array[i1]) == getRanking(array[i2])) {
+ merge[i3++] = getServiceID(array[i1]) < getServiceID(array[i2]) ? array[i1++] : array[i2++];
+ } else {
+ merge[i3++] = getRanking(array[i1]) >= getRanking(array[i2]) ? array[i1++] : array[i2++];
+ }
+ }
+ if (i1 < middle)
+ System.arraycopy(array, i1, merge, i3, middle - i1);
+ System.arraycopy(merge, 0, array, start, i2 - start);
+ }
+
+ private static int getRanking(ServiceReference ref) {
+ Object rank = ref.getProperty(Constants.SERVICE_RANKING);
+
+ if (rank == null || !(rank instanceof Integer)) {
+ return 0;
+ }
+
+ return ((Integer) rank).intValue();
+ }
+
+ private static long getServiceID(ServiceReference ref) {
+ Object sid = ref.getProperty(Constants.SERVICE_ID);
+
+ if (sid == null || !(sid instanceof Long)) {
+ return 0;
+ }
+
+ return ((Long) sid).intValue();
+ }
+
+ /**
+ * Create and open an <tt>DataInputStream</tt> object for the specified
+ * name.
+ *
+ * @param name
+ * the URI for the connection.
+ * @throws IOException
+ * if and I/O error occurs
+ * @throws ConnectionNotFoundException
+ * if the <tt>Connection</tt> object can not be made or if no
+ * handler for the requested scheme can be found.
+ * @throws IllegalArgumentException
+ * if the given uri is invalid
+ * @return A <tt>DataInputStream</tt> to the given URI
+ */
+ public DataInputStream openDataInputStream(String name) throws IOException {
+ long timeBegin = 0;
+ if (hasDebug) {
+ debug(16006, name, null);
+ timeBegin = System.currentTimeMillis();
+ }
+ try {
+ Connection conn = open(name, READ);
+
+ if (!(conn instanceof InputConnection)) {
+ try {
+ conn.close();
+ } catch (IOException e) {
+ }
+ throw new IOException("Connection does not implement InputConnection:" + conn.getClass());
+ }
+
+ return ((InputConnection) conn).openDataInputStream();
+ } finally {
+ if (hasDebug) {
+ debug(16007, String.valueOf(System.currentTimeMillis() - timeBegin), null);
+ }
+ }
+ }
+
+ /**
+ * Create and open an <tt>DataOutputStream</tt> object for the specified
+ * name.
+ *
+ * @param name
+ * the URI for the connection.
+ * @throws IOException
+ * if and I/O error occurs
+ * @throws ConnectionNotFoundException
+ * if the <tt>Connection</tt> object can not be made or if no
+ * handler for the requested scheme can be found.
+ * @throws IllegalArgumentException
+ * if the given uri is invalid
+ * @return A <tt>DataOutputStream</tt> to the given URI
+ */
+ public DataOutputStream openDataOutputStream(String name) throws IOException {
+ long timeBegin = 0;
+ if (hasDebug) {
+ debug(16008, name, null);
+ }
+ try {
+ Connection conn = open(name, WRITE);
+
+ if (!(conn instanceof OutputConnection)) {
+ try {
+ conn.close();
+ } catch (IOException e) {
+ }
+
+ throw new IOException("Connection does not implement OutputConnection:" + conn.getClass());
+ }
+
+ return ((OutputConnection) conn).openDataOutputStream();
+ } finally {
+ if (hasDebug) {
+ debug(16009, String.valueOf(System.currentTimeMillis() - timeBegin), null);
+ }
+ }
+ }
+
+ /**
+ * Create and open an <tt>InputStream</tt> object for the specified name.
+ *
+ *
+ * @param name
+ * the URI for the connection.
+ * @throws IOException
+ * if and I/O error occurs
+ * @throws ConnectionNotFoundException
+ * if the <tt>Connection</tt> object can not be made or if no
+ * handler for the requested scheme can be found.
+ * @throws IllegalArgumentException
+ * if the given uri is invalid
+ * @return A <tt>InputStream</tt> to the given URI
+ */
+ public InputStream openInputStream(String name) throws IOException {
+ long timeBegin = 0;
+ if (hasDebug) {
+ debug(16010, name, null);
+ timeBegin = System.currentTimeMillis();
+ }
+ try {
+ Connection conn = open(name, READ);
+
+ if (!(conn instanceof InputConnection)) {
+ try {
+ conn.close();
+ } catch (IOException e) {
+ }
+
+ throw new IOException("Connection does not implement InputConnection:" + conn.getClass());
+ }
+
+ return ((InputConnection) conn).openInputStream();
+ } finally {
+ if (hasDebug) {
+ debug(16011, String.valueOf(System.currentTimeMillis() - timeBegin), null);
+ }
+ }
+ }
+
+ /**
+ * Create and open an <tt>OutputStream</tt> object for the specified name.
+ *
+ * @param name
+ * the URI for the connection.
+ * @throws IOException
+ * if and I/O error occurs
+ * @throws ConnectionNotFoundException
+ * if the <tt>Connection</tt> object can not be made or if no
+ * handler for the requested scheme can be found.
+ * @throws IllegalArgumentException
+ * if the given uri is invalid
+ * @return A <tt>OutputStream</tt> to the given URI
+ */
+ public OutputStream openOutputStream(String name) throws IOException {
+ long timeBegin = 0;
+ if (hasDebug) {
+ debug(16012, name, null);
+ timeBegin = System.currentTimeMillis();
+ }
+ try {
+ Connection conn = open(name, WRITE);
+
+ if (!(conn instanceof OutputConnection)) {
+ try {
+ conn.close();
+ } catch (IOException e) {
+ }
+
+ throw new IOException("Connection does not implement OutputConnection:" + conn.getClass());
+ }
+
+ return ((OutputConnection) conn).openOutputStream();
+ } finally {
+ if (hasDebug) {
+ debug(16013, String.valueOf(System.currentTimeMillis() - timeBegin), null);
+ }
+ }
+ }
+}
diff --git a/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/impl/PrivilegedRunner.java b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/impl/PrivilegedRunner.java
new file mode 100644
index 0000000..485724e
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/impl/PrivilegedRunner.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.io.impl;
+
+import java.security.*;
+import org.eclipse.equinox.internal.util.pool.ObjectCreator;
+import org.eclipse.equinox.internal.util.pool.ObjectPool;
+
+/**
+ * @author Pavlin Dobrev
+ * @version 1.0
+ */
+
+public final class PrivilegedRunner implements ObjectCreator {
+
+ private static ObjectPool POOL;
+
+ static {
+ try {
+ POOL = new ObjectPool(new PrivilegedRunner(), 5, 10);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /* prevent instantiations */
+ private PrivilegedRunner() {
+ }
+
+ /**
+ * Same as the longer doPrivileged method, but fills in the first parameter
+ * only. All other parameters are set to <code>null</code>.
+ *
+ * @param dispatcher
+ * the dispatcher which should be called
+ * @param type
+ * the type of the action - used in the dispatcher
+ * @param arg1
+ * a parameter received by the dispatcher
+ * @see #doPrivileged(PrivilegedDispatcher, int, Object, Object, Object,
+ * Object)
+ * @return the object returned from the execution
+ * @throws Exception
+ * if the dispatcher fails
+ */
+ public static final Object doPrivileged(PrivilegedDispatcher dispatcher, int type, Object arg1) throws Exception {
+ return doPrivileged(null, dispatcher, type, arg1, null, null, null);
+ }
+
+ /**
+ * Performs a privileged action. The method calls the dispatcher inside the
+ * privileged call passing it the same parameters that were passed to this
+ * method.
+ *
+ * @param dispatcher
+ * the dispatcher which should be called
+ * @param type
+ * the type of the action - used in the dispatcher
+ * @param arg1
+ * a parameter received by the dispatcher
+ * @param arg2
+ * a parameter received by the dispatcher
+ * @param arg3
+ * a parameter received by the dispatcher
+ * @param arg4
+ * a parameter received by the dispatcher
+ * @return the object returned from the execution
+ * @throws Exception
+ * if the dispatcher fails
+ */
+ public static final Object doPrivileged(PrivilegedDispatcher dispatcher, int type, Object arg1, Object arg2, Object arg3, Object arg4) throws Exception {
+ return doPrivileged(null, dispatcher, type, arg1, arg2, arg3, arg4);
+ }
+
+ /**
+ * Performs a privileged action. The method calls the dispatcher inside the
+ * privileged call passing it the same parameters that were passed to this
+ * method.
+ *
+ * @param context
+ * the access context
+ * @param dispatcher
+ * the dispatcher which should be called
+ * @param type
+ * the type of the action - used in the dispatcher
+ * @param arg1
+ * a parameter received by the dispatcher
+ * @param arg2
+ * a parameter received by the dispatcher
+ * @param arg3
+ * a parameter received by the dispatcher
+ * @param arg4
+ * a parameter received by the dispatcher
+ * @return the object returned from the execution
+ * @throws Exception
+ * if the dispatcher fails
+ */
+ public static final Object doPrivileged(Object context, PrivilegedDispatcher dispatcher, int type, Object arg1, Object arg2, Object arg3, Object arg4) throws Exception {
+ /* init runner */
+ PA runner = (PA) POOL.getObject();
+ runner.dispatcher = dispatcher;
+ runner.type = type;
+ runner.arg1 = arg1;
+ runner.arg2 = arg2;
+ runner.arg3 = arg3;
+ runner.arg4 = arg4;
+
+ try {
+ if (System.getSecurityManager() != null) {
+ /*
+ * if security manager is set - then privileged execution is
+ * started
+ */
+ return (context != null)
+ //
+ ? AccessController.doPrivileged(runner, (AccessControlContext) context)
+ : AccessController.doPrivileged(runner);
+ }
+ /* if no security manager is set - simply run the action */
+ return runner.run();
+ } catch (PrivilegedActionException e) {
+ throw e.getException();
+ } finally {
+ runner.recycle();
+ POOL.releaseObject(runner);
+ }
+ }
+
+ /**
+ * @see org.eclipse.equinox.internal.util.pool.ObjectCreator#getInstance()
+ */
+ public Object getInstance() throws Exception {
+ return new PA();
+ }
+
+ /**
+ * This dispatcher is the handler that is called within the privileged call.
+ * It should dispatch and perform the requested actions depending on the
+ * action type and using the given job parameters.
+ *
+ * @author Valentin Valchev
+ * @version $Revision: 1.3 $
+ */
+ public static interface PrivilegedDispatcher {
+
+ /**
+ * @param type
+ * the type of the action
+ * @param arg1
+ * parameter 1 - depends on the action type
+ * @param arg2
+ * parameter 2 - depends on the action type
+ * @param arg3
+ * parameter 3 - depends on the action type
+ * @param arg4
+ * parameter 4 - depends on the action type
+ * @return an object which should be returned from the
+ * PrivilegedAction.run() method
+ * @throws Exception
+ * on error
+ */
+ Object dispatchPrivileged(int type, Object arg1, Object arg2, Object arg3, Object arg4) throws Exception;
+ }
+
+ static class PA implements PrivilegedExceptionAction {
+
+ int type;
+ Object arg1, arg2, arg3, arg4;
+ PrivilegedDispatcher dispatcher;
+
+ void recycle() {
+ dispatcher = null;
+ type = -1;
+ arg1 = arg2 = arg3 = arg4 = null;
+ }
+
+ /**
+ * @see java.security.PrivilegedExceptionAction#run()
+ */
+ public Object run() throws Exception {
+ return dispatcher.dispatchPrivileged(type, arg1, arg2, arg3, arg4);
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/impl/TracerConfigConnector.java b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/impl/TracerConfigConnector.java
new file mode 100644
index 0000000..caa5445
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/impl/TracerConfigConnector.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.io.impl;
+
+import org.eclipse.equinox.internal.util.hash.HashIntObjNS;
+
+/**
+ * @author Lubomir Mitev
+ * @author Pavlin Dobrev
+ * @version 1.0
+ */
+public class TracerConfigConnector {
+
+ public static HashIntObjNS getMap() {
+ /*
+ * increase size if you add more dumps in the table - at this moment the
+ * entries in table are 159
+ */
+ HashIntObjNS map = new HashIntObjNS(28);// (int)(28 * 0.7) = 19, 18
+ constructMap(map);
+ return map;
+ }
+
+ public static void constructMap(HashIntObjNS map) {
+ map.put(-0x1200, "Connector Service");
+ map.put(16001, "[BEGIN - open connection] The values of the URI and the access mode are");
+ map.put(16002, "[END - open connection] took");
+ map.put(16003, "IOException when connection is created from ConnectionFactory");
+ map.put(16004, "Connection is created from ConnectionFactory");
+ map.put(16005, "Connection is created from javax.microedition.io.Connector");
+ map.put(16006, "[BEGIN - open DataInputStream] The URI is");
+ map.put(16007, "[END - open DataInputStream] took");
+ map.put(16008, "[BEGIN - open DataOutputStream] The URI is");
+ map.put(16009, "[END - open DataOutputStream] took");
+ map.put(16010, "[BEGIN - open InputStream] The URI is");
+ map.put(16011, "[END - open InputStream] took");
+ map.put(16012, "[BEGIN - open OutputStream] The URI is");
+ map.put(16013, "[END - open OutputStream] took");
+ map.put(16014, "ConnectionNotFoundException thrown from system javax.microedition.io.Connector");
+ map.put(16050, "[BEGIN - add ConnectionListener] The ConnectionListener is");
+ map.put(16051, "[END - add ConnectionListener] took");
+ map.put(16052, "Remove ConnectionListener");
+ map.put(16053, "Close connection. The URI is");
+ }
+}
diff --git a/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/package.html b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/package.html
new file mode 100644
index 0000000..32d3d84
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/package.html
@@ -0,0 +1,10 @@
+<!-- $Header: /cvsroot/eclipse/equinox-incubator/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/package.html,v 1.1 2007/11/30 13:45:13 pdobrev Exp $ -->
+<BODY>
+<P>The OSGi IO Provider Specification Version 1.0.
+<p>Bundles wishing to use this package must list the package
+in the <TT>Import-Package</TT> header of the bundle's manifest.
+For example:
+<pre>
+Import-Package: org.osgi.service.io; specification-version=1.0
+</pre>
+</BODY>
diff --git a/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/util/AbstractConnectionNotifier.java b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/util/AbstractConnectionNotifier.java
new file mode 100644
index 0000000..5cf2968
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/util/AbstractConnectionNotifier.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.io.util;
+
+import java.util.*;
+import javax.microedition.io.Connection;
+import org.eclipse.equinox.internal.io.ConnectionListener;
+import org.eclipse.equinox.internal.io.ConnectionNotifier;
+
+/**
+ * @author Pavlin Dobrev
+ * @version 1.0
+ */
+
+public abstract class AbstractConnectionNotifier extends Dictionary implements ConnectionNotifier {
+ private Vector list;
+ private Hashtable info;
+
+ // the local address to which the connection is bound
+
+ public final static String LOCAL_ADDRESS = "local_address";
+
+ // the local port to which the connection is bound.
+
+ public final static String LOCAL_PORT = "local_port";
+
+ // the remote address to which the connection is connected.
+
+ public final static String ADDRESS = "address";
+
+ // the remote port to which the connection is connected.
+
+ public final static String PORT = "port";
+
+ // the encoder used
+
+ public final static String ENCODER = "enc";
+
+ public static final String SO_TIMEOUT = "timeout";
+
+ protected AbstractConnectionNotifier() {
+ list = new Vector(2, 3);
+ info = new Hashtable(30);
+ }
+
+ // ConnectionNotifier methods
+ public void addConnectionListener(ConnectionListener l) {
+ if (!list.contains(l)) {
+ list.addElement(l);
+ }
+ }
+
+ public void removeConnectionListener(ConnectionListener l) {
+ list.removeElement(l);
+ }
+
+ // returns the url of connection
+ protected abstract String getURL();
+
+ // the connection to which this ConnectionLife is bound to
+ protected abstract Connection getConnection();
+
+ protected void notifyClosed() {
+ for (Enumeration en = list.elements(); en.hasMoreElements();) {
+ ConnectionListener l = (ConnectionListener) en.nextElement();
+ l.notify(getURL(), ConnectionListener.CONNECTION_CLOSED, getConnection());
+ }
+ }
+
+ protected void setInfo(String key, Object value) {
+ if (key != null && value != null) {
+ info.put(key, value);
+ }
+ }
+
+ public int size() {
+ return info.size();
+ }
+
+ public boolean isEmpty() {
+ return info.isEmpty();
+ }
+
+ public Enumeration keys() {
+ return info.keys();
+ }
+
+ public Enumeration elements() {
+ return info.elements();
+ }
+
+ public Object get(Object key) {
+ return info.get(key);
+ }
+
+ public Object remove(Object key) {
+ return info.remove(key);
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/util/AbstractDatagram.java b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/util/AbstractDatagram.java
new file mode 100644
index 0000000..4f81da4
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/util/AbstractDatagram.java
@@ -0,0 +1,434 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.io.util;
+
+import java.io.*;
+import javax.microedition.io.Datagram;
+
+/**
+ * @author Pavlin Dobrev
+ * @version 1.0
+ */
+
+public abstract class AbstractDatagram implements Datagram {
+ protected byte[] data;
+ private int pos;
+ private int count;
+
+ public AbstractDatagram(int size) {
+ this(new byte[size]);
+ }
+
+ public AbstractDatagram(byte[] data) {
+ this.data = data;
+ pos = 0;
+ count = data.length;
+ }
+
+ public AbstractDatagram(byte[] data, int start, int length) {
+ if (start > data.length || (start + length) > data.length) {
+ throw new IllegalArgumentException("Start possition or length is greater than data length");
+ }
+
+ this.data = data;
+ pos = start;
+ count = length;
+ }
+
+ public synchronized byte[] getData() {
+ return data;
+ }
+
+ public int getLength() {
+ return count;
+ }
+
+ public int getOffset() {
+ return pos;
+ }
+
+ public void setLength(int len) {
+ if (len < 0 || len > data.length) {
+ throw new IllegalArgumentException("Given length is negative or greater than buffer size");
+ }
+
+ count = len;
+ }
+
+ public synchronized void setData(byte[] buffer, int offset, int len) {
+ if (offset > buffer.length || (offset + len) > buffer.length) {
+ throw new IllegalArgumentException();
+ }
+
+ data = buffer;
+ pos = offset;
+ count = len;
+ }
+
+ public void reset() {
+ pos = 0;
+ count = 0;
+ }
+
+ public int read() {
+ return (pos < count) ? (data[pos++] & 0xff) : -1;
+ }
+
+ public void readFully(byte b[]) throws IOException {
+ readFully(b, 0, b.length);
+ }
+
+ public void readFully(byte b[], int off, int len) throws IOException {
+ if (len < 0) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ int n = 0;
+
+ while (n < len) {
+ int ch = read();
+
+ if (ch < 0) {
+ throw new EOFException();
+ }
+
+ b[off + (n++)] = (byte) ch;
+ }
+ }
+
+ public int skipBytes(int n) throws IOException {
+ if (pos + n > count) {
+ n = count - pos;
+ }
+
+ if (n < 0) {
+ return 0;
+ }
+
+ pos += n;
+ return n;
+ }
+
+ public boolean readBoolean() throws IOException {
+ int ch = read();
+
+ if (ch < 0) {
+ throw new EOFException();
+ }
+
+ return (ch != 0);
+ }
+
+ public byte readByte() throws IOException {
+ int ch = read();
+
+ if (ch < 0) {
+ throw new EOFException();
+ }
+
+ return (byte) (ch);
+ }
+
+ public int readUnsignedByte() throws IOException {
+ int ch = read();
+
+ if (ch < 0) {
+ throw new EOFException();
+ }
+
+ return ch;
+ }
+
+ public short readShort() throws IOException {
+ int ch1 = read();
+ int ch2 = read();
+
+ if ((ch1 | ch2) < 0) {
+ throw new EOFException();
+ }
+
+ return (short) ((ch1 << 8) + (ch2 << 0));
+ }
+
+ public int readUnsignedShort() throws IOException {
+ int ch1 = read();
+ int ch2 = read();
+
+ if ((ch1 | ch2) < 0) {
+ throw new EOFException();
+ }
+
+ return (ch1 << 8) + (ch2 << 0);
+ }
+
+ public char readChar() throws IOException {
+ int ch1 = read();
+ int ch2 = read();
+
+ if ((ch1 | ch2) < 0) {
+ throw new EOFException();
+ }
+
+ return (char) ((ch1 << 8) + (ch2 << 0));
+ }
+
+ public int readInt() throws IOException {
+ int ch1 = read();
+ int ch2 = read();
+ int ch3 = read();
+ int ch4 = read();
+
+ if ((ch1 | ch2 | ch3 | ch4) < 0) {
+ throw new EOFException();
+ }
+
+ return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
+ }
+
+ public long readLong() throws IOException {
+ return ((long) (readInt()) << 32) + (readInt() & 0xFFFFFFFFL);
+ }
+
+ public float readFloat() throws IOException {
+ return Float.intBitsToFloat(readInt());
+ }
+
+ public double readDouble() throws IOException {
+ return Double.longBitsToDouble(readLong());
+ }
+
+ public String readLine() throws IOException {
+ throw new RuntimeException("Function not supported");
+ }
+
+ public String readUTF() throws IOException {
+ return readUTF(this);
+ }
+
+ public final static String readUTF(DataInput in) throws IOException {
+ int utflen = in.readUnsignedShort();
+ StringBuffer str = new StringBuffer(utflen);
+ byte bytearr[] = new byte[utflen];
+ int c, char2, char3;
+ int count = 0;
+
+ in.readFully(bytearr, 0, utflen);
+
+ while (count < utflen) {
+ c = bytearr[count] & 0xff;
+
+ switch (c >> 4) {
+ case 0 :
+ case 1 :
+ case 2 :
+ case 3 :
+ case 4 :
+ case 5 :
+ case 6 :
+ case 7 :
+ /* 0xxxxxxx */
+ count++;
+ str.append((char) c);
+ break;
+
+ case 12 :
+ case 13 :
+ /* 110x xxxx 10xx xxxx */
+ count += 2;
+
+ if (count > utflen) {
+ throw new UTFDataFormatException();
+ }
+
+ char2 = bytearr[count - 1];
+
+ if ((char2 & 0xC0) != 0x80) {
+ throw new UTFDataFormatException();
+ }
+
+ str.append((char) (((c & 0x1F) << 6) | (char2 & 0x3F)));
+ break;
+
+ case 14 :
+ /* 1110 xxxx 10xx xxxx 10xx xxxx */
+ count += 3;
+
+ if (count > utflen) {
+ throw new UTFDataFormatException();
+ }
+
+ char2 = bytearr[count - 2];
+ char3 = bytearr[count - 1];
+
+ if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) {
+ throw new UTFDataFormatException();
+ }
+
+ str.append((char) (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0)));
+ break;
+
+ default :
+ /* 10xx xxxx, 1111 xxxx */
+ throw new UTFDataFormatException();
+ }
+ }
+
+ // The number of chars produced may be less than utflen
+ return str.toString();
+ }
+
+ // --------------------------------------------------------
+ public void write(int b) throws IOException {
+
+ if (pos < data.length) {
+ data[pos++] = (byte) b;
+ } else {
+ byte buf[] = new byte[data.length + 1];
+ System.arraycopy(data, 0, buf, 0, count);
+ data = buf;
+ data[pos++] = (byte) b;
+ count++;
+ }
+ }
+
+ public void write(byte b[]) throws IOException {
+ write(b, 0, b.length);
+ }
+
+ public void write(byte b[], int off, int len) throws IOException {
+ if (b == null) {
+ throw new NullPointerException();
+ } else if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) {
+ throw new IndexOutOfBoundsException();
+ } else if (len == 0) {
+ return;
+ }
+
+ for (int i = 0; i < len; i++) {
+ write(b[off + i]);
+ }
+ }
+
+ public void writeBoolean(boolean v) throws IOException {
+ write(v ? 1 : 0);
+ }
+
+ public void writeByte(int v) throws IOException {
+ write(v);
+ }
+
+ public void writeShort(int v) throws IOException {
+ write((v >>> 8) & 0xFF);
+ write((v >>> 0) & 0xFF);
+ }
+
+ public void writeChar(int v) throws IOException {
+ write((v >>> 8) & 0xFF);
+ write((v >>> 0) & 0xFF);
+ }
+
+ public void writeInt(int v) throws IOException {
+ write((v >>> 24) & 0xFF);
+ write((v >>> 16) & 0xFF);
+ write((v >>> 8) & 0xFF);
+ write((v >>> 0) & 0xFF);
+ }
+
+ public void writeLong(long v) throws IOException {
+ write((int) (v >>> 56) & 0xFF);
+ write((int) (v >>> 48) & 0xFF);
+ write((int) (v >>> 40) & 0xFF);
+ write((int) (v >>> 32) & 0xFF);
+ write((int) (v >>> 24) & 0xFF);
+ write((int) (v >>> 16) & 0xFF);
+ write((int) (v >>> 8) & 0xFF);
+ write((int) (v >>> 0) & 0xFF);
+ }
+
+ public void writeFloat(float v) throws IOException {
+ writeInt(Float.floatToIntBits(v));
+ }
+
+ public void writeDouble(double v) throws IOException {
+ writeLong(Double.doubleToLongBits(v));
+ }
+
+ public void writeBytes(String s) throws IOException {
+ int len = s.length();
+
+ for (int i = 0; i < len; i++) {
+ write((byte) s.charAt(i));
+ }
+ }
+
+ public void writeChars(String s) throws IOException {
+ int len = s.length();
+
+ for (int i = 0; i < len; i++) {
+ int v = s.charAt(i);
+ write((v >>> 8) & 0xFF);
+ write((v >>> 0) & 0xFF);
+ }
+ }
+
+ public void writeUTF(String str) throws IOException {
+ writeUTF(str, this);
+ }
+
+ static int writeUTF(String str, DataOutput out) throws IOException {
+ int strlen = str.length();
+ int utflen = 0;
+ char[] charr = new char[strlen];
+ int c, count = 0;
+
+ str.getChars(0, strlen, charr, 0);
+
+ for (int i = 0; i < strlen; i++) {
+ c = charr[i];
+
+ if ((c >= 0x0001) && (c <= 0x007F)) {
+ utflen++;
+ } else if (c > 0x07FF) {
+ utflen += 3;
+ } else {
+ utflen += 2;
+ }
+ }
+
+ if (utflen > 65535) {
+ throw new UTFDataFormatException();
+ }
+
+ byte[] bytearr = new byte[utflen + 2];
+ bytearr[count++] = (byte) ((utflen >>> 8) & 0xFF);
+ bytearr[count++] = (byte) ((utflen >>> 0) & 0xFF);
+
+ for (int i = 0; i < strlen; i++) {
+ c = charr[i];
+
+ if ((c >= 0x0001) && (c <= 0x007F)) {
+ bytearr[count++] = (byte) c;
+ } else if (c > 0x07FF) {
+ bytearr[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F));
+ bytearr[count++] = (byte) (0x80 | ((c >> 6) & 0x3F));
+ bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
+ } else {
+ bytearr[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F));
+ bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
+ }
+ }
+
+ out.write(bytearr);
+ return utflen + 2;
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/util/URI.java b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/util/URI.java
new file mode 100644
index 0000000..3cfdfd7
--- /dev/null
+++ b/bundles/org.eclipse.equinox.io/src/org/eclipse/equinox/internal/io/util/URI.java
@@ -0,0 +1,347 @@
+/*******************************************************************************
+ * Copyright (c) 1997-2007 by ProSyst Software GmbH
+ * http://www.prosyst.com
+ * 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:
+ * ProSyst Software GmbH - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.io.util;
+
+import java.util.Hashtable;
+import java.util.Enumeration;
+
+/**
+ * @author Pavlin Dobrev
+ * @version 1.0
+ */
+
+public class URI {
+
+ /*
+ * <scheme>://<net_loc>/<path>;<params>?<query>#<fragment>
+ */
+ private String scheme;
+ private String schemeSpec;
+ private String auth;
+ private String userInfo;
+ private String host;
+ private String port;
+ private String path;
+ private String query;
+ private String fragment;
+ private boolean isOpaque;
+
+ private Hashtable params;
+
+ public URI(String uri) {
+ if (uri == null) {
+ throw new IllegalArgumentException("URL cannot be NULL!");
+ }
+
+ byte[] buf = uri.getBytes();
+ int sPos = indexOf(buf, ':', 0);
+
+ scheme = trim(buf, 0, sPos);
+
+ sPos++;
+
+ int ePos = indexOf(buf, '#', sPos);
+
+ if (ePos != -1) {
+ fragment = trim(buf, ePos + 1, buf.length);
+ } else {
+ ePos = buf.length;
+ }
+
+ schemeSpec = trim(buf, sPos, ePos);
+
+ int pos = indexOf(buf, '?', sPos, ePos);
+
+ if (pos != -1) {
+ query = trim(buf, pos + 1, ePos);
+ ePos = pos;
+ }
+
+ pos = indexOf(buf, ';', sPos, ePos);
+
+ if (pos != -1) {
+ parseParams(buf, pos + 1, ePos);
+ ePos = pos;
+ }
+
+ isOpaque = true;
+
+ if (buf[sPos] == '/' && buf[sPos + 1] == '/') {
+ sPos += 2;
+ isOpaque = false;
+ }
+
+ pos = indexOf(buf, '/', sPos, ePos);
+
+ if (pos != -1) {
+ path = trim(buf, pos, ePos);
+ ePos = pos;
+ }
+
+ auth = trim(buf, sPos, ePos);
+
+ if (!isOpaque) {
+ pos = indexOf(buf, '@', sPos);
+
+ if (pos != -1) {
+ userInfo = trim(buf, sPos, pos);
+ sPos = pos + 1;
+ }
+
+ pos = indexOf(buf, ']', sPos);
+ if (pos != -1) {
+ host = trim(buf, sPos, pos + 1);
+ sPos = pos + 1;
+ }
+
+ pos = indexOf(buf, ':', sPos);
+
+ if (pos != -1) {
+ port = trim(buf, pos + 1, ePos);
+ ePos = pos;
+ }
+ if (host == null) {
+ host = trim(buf, sPos, ePos);
+ }
+ }
+ }
+
+ public String getScheme() {
+ return scheme;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public String getPort() {
+ return port;
+ }
+
+ public int getPortNumber() {
+ return port == null ? -1 : Integer.parseInt(port);
+ }
+
+ public String getFragment() {
+ return fragment;
+ }
+
+ public String getQuery() {
+ return query;
+ }
+
+ public String getUserInfo() {
+ return userInfo;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public String getSchemeSpecificPart() {
+ return schemeSpec;
+ }
+
+ public String getAuthority() {
+ return auth;
+ }
+
+ public boolean isOpaque() {
+ return isOpaque;
+ }
+
+ public String get(String param) {
+ return params == null ? null : (String) params.get(param);
+ }
+
+ public String getParams() {
+ if (params == null || params.isEmpty()) {
+ return null;
+ }
+
+ StringBuffer sb = new StringBuffer();
+
+ for (Enumeration en = params.keys(); en.hasMoreElements();) {
+ String key = (String) en.nextElement();
+ sb.append(";");
+ sb.append(key);
+ sb.append("=");
+ sb.append(((String) params.get(key)));
+ }
+
+ if (sb.length() == 0) {
+ return null;
+ }
+
+ return sb.toString();
+ }
+
+ public static String getHost(String uri) {
+ if (uri == null) {
+ throw new IllegalArgumentException("URL cannot be NULL!");
+ }
+
+ int pos = uri.indexOf("://");
+
+ if (pos == -1) {
+ throw new IllegalArgumentException("Does not have scheme");
+ }
+
+ int sPos = pos + 3;
+
+ pos = uri.indexOf('@', sPos);
+ if (pos != -1) {
+ sPos = pos + 1;
+ }
+
+ int ePos = endOfHostPort(uri, sPos);
+
+ pos = uri.indexOf(']', sPos);
+ if (pos != -1) {
+ return uri.substring(sPos, pos + 1);
+ }
+
+ pos = uri.indexOf(':', sPos);
+
+ if (sPos != -1 && pos < ePos) {
+ return uri.substring(sPos, pos);
+ }
+
+ return uri.substring(sPos, ePos);
+ }
+
+ public static int getPort(String uri) {
+ if (uri == null) {
+ throw new IllegalArgumentException("URL cannot be NULL!");
+ }
+
+ int pos = uri.indexOf("://");
+
+ if (pos == -1) {
+ throw new IllegalArgumentException("Does not have scheme");
+ }
+
+ int sPos = pos + 3;
+
+ pos = uri.indexOf('@', sPos);
+ if (pos != -1) {
+ sPos = pos + 1;
+ }
+
+ pos = uri.indexOf(']', sPos);
+ if (pos != -1) {
+ sPos = pos + 1;
+ }
+
+ sPos = uri.indexOf(":", sPos);
+
+ if (sPos == -1) {
+ // return -1;
+ throw new IllegalArgumentException("Port is missing " + uri);
+ }
+
+ sPos++;
+
+ int ePos = endOfHostPort(uri, sPos);
+
+ return Integer.parseInt(uri.substring(sPos, ePos));
+ }
+
+ static int endOfHostPort(String str, int spos) {
+ int pos = str.indexOf("/", spos);
+ int tmp = str.indexOf(";", spos);
+
+ if (tmp != -1 && tmp < pos || pos == -1) {
+ pos = tmp;
+ }
+
+ if (pos != -1) {
+ return pos;
+ }
+
+ return str.length();
+ }
+
+ static int indexOf(byte[] ba, char b, int startPos) {
+ return indexOf(ba, b, startPos, ba.length);
+ }
+
+ static int indexOf(byte[] ba, char b, int sPos, int ePos) {
+ if (sPos > ba.length || sPos < 0 || ePos > ba.length || ePos < 0 || sPos >= ePos) {
+ return -1;// throw new IllegalArgumentException();
+ }
+
+ for (int i = sPos; i < ePos; i++) {
+ if (ba[i] == b) {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ static String trim(byte[] buf, int s, int e) {
+ if (s >= e) {
+ return null;
+ }
+
+ while (s < buf.length && s < e && buf[s] == ' ') {
+ s++;
+ }
+
+ while (e >= 0 && e > s && buf[e - 1] == ' ') {
+ e--;
+ }
+
+ if (s == e) {
+ return null;
+ }
+
+ return new String(buf, s, e - s);
+ }
+
+ private void parseParams(byte[] buf, int sPos, int ePos) {
+ int pos;
+
+ while (sPos < ePos && (pos = indexOf(buf, ';', sPos)) != -1) {
+ parseParam(buf, sPos, pos);
+ sPos = pos + 1;
+ }
+
+ if (sPos < ePos) {
+ parseParam(buf, sPos, ePos);
+ }
+ }
+
+ private void parseParam(byte[] buf, int sPos, int ePos) {
+ int rpos = indexOf(buf, '=', sPos, ePos);
+
+ if (rpos != -1) {
+ String key = trim(buf, sPos, rpos);
+
+ if (key == null) {
+ return;
+ }
+
+ String str = trim(buf, rpos + 1, ePos);
+
+ if (str != null) {
+ if (params == null) {
+ params = new Hashtable();
+ }
+
+ params.put(key, str);
+ }
+ }
+ }
+
+}