diff options
66 files changed, 3 insertions, 8593 deletions
diff --git a/bundles/org.eclipse.core.resources.compatibility/.classpath b/bundles/org.eclipse.core.resources.compatibility/.classpath deleted file mode 100644 index ce7393340..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?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/J2SE-1.4"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/bundles/org.eclipse.core.resources.compatibility/.cvsignore b/bundles/org.eclipse.core.resources.compatibility/.cvsignore deleted file mode 100644 index ba077a403..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/bundles/org.eclipse.core.resources.compatibility/.project b/bundles/org.eclipse.core.resources.compatibility/.project deleted file mode 100644 index 018265cd7..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/.project +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.core.resources.compatibility</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> - <buildCommand> - <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature> - </natures> -</projectDescription> diff --git a/bundles/org.eclipse.core.resources.compatibility/.settings/org.eclipse.core.resources.prefs b/bundles/org.eclipse.core.resources.compatibility/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 529f58b45..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Tue Feb 01 12:03:35 EST 2005 -eclipse.preferences.version=1 -encoding/<project>=ISO-8859-1 diff --git a/bundles/org.eclipse.core.resources.compatibility/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.core.resources.compatibility/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 5def5a17c..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,350 +0,0 @@ -#Fri Feb 20 11:54:29 CET 2009 -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.comparingIdentical=warning -org.eclipse.jdt.core.compiler.problem.deadCode=error -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.fallthroughCase=ignore -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled -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=error -org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=disabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled -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.missingHashCodeMethod=error -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.missingJavadocTagDescription=return_tag -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.missingSynchronizedOnInheritedMethod=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=error -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore -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.unusedDeclaredThrownException=warning -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled -org.eclipse.jdt.core.compiler.problem.unusedImport=error -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=error -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -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.unusedWarningToken=warning -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=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.format_block_comments=false -org.eclipse.jdt.core.formatter.comment.format_comments=false -org.eclipse.jdt.core.formatter.comment.format_header=false -org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_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.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.incompatibleJDKLevel=ignore -org.eclipse.jdt.core.incompleteClasspath=error diff --git a/bundles/org.eclipse.core.resources.compatibility/.settings/org.eclipse.jdt.ui.prefs b/bundles/org.eclipse.core.resources.compatibility/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 5061c817f..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Fri Feb 23 16:59:24 EST 2007 -eclipse.preferences.version=1 -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 -org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return Returns the ${bare_field_name}.\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} The ${bare_field_name} to set.\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*******************************************************************************\r\n * Copyright (c) ${year} IBM Corporation and others.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n *\r\n * Contributors\:\r\n * IBM Corporation - initial API and implementation\r\n ******************************************************************************/\r\n</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @since 3.2\r\n *\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="false" context\="newtype_context" deleted\="false" description\="New classes and interfaces" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">/*******************************************************************************\r\n * Copyright (c) ${year} IBM Corporation and others.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * Contributors\:\r\n * IBM Corporation - initial API and implementation\r\n *******************************************************************************/\r\n${filecomment}\r\n${package_declaration}\r\n\r\n/**\r\n * \r\n */\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">fail("4.99", ${exception_var});</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates> diff --git a/bundles/org.eclipse.core.resources.compatibility/META-INF/MANIFEST.MF b/bundles/org.eclipse.core.resources.compatibility/META-INF/MANIFEST.MF deleted file mode 100644 index 7a2d601a3..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/META-INF/MANIFEST.MF +++ /dev/null @@ -1,14 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: %compatibilityFragmentName -Bundle-SymbolicName: org.eclipse.core.resources.compatibility -Bundle-Version: 3.4.0.qualifier -Bundle-Vendor: %providerName -Fragment-Host: - org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)" -Bundle-Localization: plugin -Export-Package: org.eclipse.core.internal.indexing;x-internal:=true, - org.eclipse.core.internal.localstore;x-internal:=true, - org.eclipse.core.internal.properties;x-internal:=true, - org.eclipse.core.internal.resources;x-internal:=true -Bundle-RequiredExecutionEnvironment: J2SE-1.4 diff --git a/bundles/org.eclipse.core.resources.compatibility/about.html b/bundles/org.eclipse.core.resources.compatibility/about.html deleted file mode 100644 index 460233046..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/about.html +++ /dev/null @@ -1,28 +0,0 @@ -<!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>June 2, 2006</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>
\ No newline at end of file diff --git a/bundles/org.eclipse.core.resources.compatibility/build.properties b/bundles/org.eclipse.core.resources.compatibility/build.properties deleted file mode 100644 index b53bdaca8..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/build.properties +++ /dev/null @@ -1,16 +0,0 @@ -############################################################################### -# Copyright (c) 2005 IBM Corporation and others. -# 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: -# IBM Corporation - initial API and implementation -############################################################################### -source.. = src/ -output.. = bin/ -bin.includes = .,\ - META-INF/MANIFEST.MF,\ - about.html -src.includes = about.html diff --git a/bundles/org.eclipse.core.resources.compatibility/pom.xml b/bundles/org.eclipse.core.resources.compatibility/pom.xml deleted file mode 100644 index de4b2208f..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/pom.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Copyright (c) 2012 Eclipse Foundation. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Distribution License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/org/documents/edl-v10.php - - Contributors: - Igor Fedorenko - initial implementation ---> - -<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <modelVersion>4.0.0</modelVersion> - <parent> - <artifactId>eclipse.platform.resources</artifactId> - <groupId>eclipse.platform.resources</groupId> - <version>3.8.0-SNAPSHOT</version> - <relativePath>../../</relativePath> - </parent> - <groupId>eclipse.platform.resources</groupId> - <artifactId>org.eclipse.core.resources.compatibility</artifactId> - <version>3.4.0-SNAPSHOT</version> - <packaging>eclipse-plugin</packaging> -</project> diff --git a/bundles/org.eclipse.core.resources.compatibility/readme.txt b/bundles/org.eclipse.core.resources.compatibility/readme.txt new file mode 100644 index 000000000..a92934408 --- /dev/null +++ b/bundles/org.eclipse.core.resources.compatibility/readme.txt @@ -0,0 +1,3 @@ +This directory used to contain a bundle used to support backward compatibility
+with an old implementation of the workspace history and property store.
+This bundle was removed after Eclipse platform release 3.5 (2009).
\ No newline at end of file diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/AbstractObjectPolicy.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/AbstractObjectPolicy.java deleted file mode 100644 index b50d4ada5..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/AbstractObjectPolicy.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -public abstract class AbstractObjectPolicy { - - /** - * Creates a new instance of an object for this object store. Uses - * the contents of the field to decide what type of object to create. - */ - public abstract StoredObject createObject(Field field, ObjectStore store, ObjectAddress address) throws ObjectStoreException; - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/AbstractPagePolicy.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/AbstractPagePolicy.java deleted file mode 100644 index 94b200c0f..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/AbstractPagePolicy.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -public abstract class AbstractPagePolicy { - - /** - * Returns a page given a page number, a buffer, and the page store. The - * buffer should be copied in the implementations as it may be reused later. - * The buffer is extended or truncated to the page size during this copy. - * Both the buffer contents and the page number can be used to determine - * the type of page to create. - */ - public abstract Page createPage(int pageNumber, byte[] buffer, PageStore pageStore); - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/BinarySmallObject.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/BinarySmallObject.java deleted file mode 100644 index a73e2c23e..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/BinarySmallObject.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -class BinarySmallObject extends IndexedStoreObject { - public static final int TYPE = 5; - public static final int VALUE_OFFSET = 2; - protected byte[] value; - - /** - * Constructs a new object that will be inserted into a store. - */ - public BinarySmallObject(byte[] value) { - super(); - this.value = new Buffer(value).get(); - } - - /** - * Constructs an object from bytes that came from the store. - */ - public BinarySmallObject(Field f, ObjectStore store, ObjectAddress address) throws ObjectStoreException { - super(f, store, address); - } - - /** - * Places the contents of the fields into the buffer. - * Subclasses should implement and call super. - * The value field is maintained in the contents directly and does not need - * to be copied there by this method. - */ - protected void insertValues(Field f) { - super.insertValues(f); - f.subfield(VALUE_OFFSET).put(value); - } - - /** - * Extracts the values from a field into the members of this object; - */ - protected void extractValues(Field f) throws ObjectStoreException { - super.extractValues(f); - value = f.subfield(VALUE_OFFSET).get(); - } - - /** - * Returns the maximum size of this object's instance -- including its type field. - * Subclasses should override. - */ - protected int getMaximumSize() { - return 6000 + VALUE_OFFSET; - } - - protected int length() { - return value.length + VALUE_OFFSET; - } - - /** - * Returns the minimum size of this object's instance -- including its type field. - * Subclasses should override. - */ - protected int getMinimumSize() { - return VALUE_OFFSET; - } - - /** - * Returns the required type of this class of object. - * Subclasses must override. - */ - protected int getRequiredType() { - return TYPE; - } - - /** - * Returns the value of the object. - */ - public byte[] getValue() { - return new Field(value).get(); - } - - /** - * Provides a printable representation of this object. - */ - public String toString() { - int n = 10; - StringBuffer b = new StringBuffer(); - b.append("BSOB("); //$NON-NLS-1$ - b.append(value.length); - b.append(" ["); //$NON-NLS-1$ - for (int i = 0; i < value.length; i++) { - if (i > 0) - b.append(" "); //$NON-NLS-1$ - if (i == n) - break; - b.append(value[i]); - } - if (value.length > n) - b.append(" ..."); //$NON-NLS-1$ - b.append("])"); //$NON-NLS-1$ - return b.toString(); - } - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Buffer.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Buffer.java deleted file mode 100644 index df668746e..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Buffer.java +++ /dev/null @@ -1,173 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -/** - * Implements a storage area that is accessible at various offsets and lengths. - */ -public class Buffer { - protected byte[] contents; - private static final byte[] ZEROES = new byte[1024]; - - /** - * Create a new buffer using the given byte array as contents. Note that this has - * the potential for aliasing side effects. - */ - public Buffer(byte[] contents) { - this.contents = contents; - } - - /** - * Create a new buffer of size n. - */ - public Buffer(int n) { - contents = new byte[n]; - } - - /** - * Constructor for a new Buffer from an Insertable. - */ - public Buffer(Insertable anObject) { - this.contents = anObject.toByteArray(); - } - - public void clear() { - clear(contents, 0, contents.length); - } - - private static void clear(byte[] buffer, int offset, int length) { - int n = length; - int p = offset; - while (n > 0) { - int m = Math.min(ZEROES.length, n); - System.arraycopy(ZEROES, 0, buffer, p, m); - p += m; - n -= m; - } - } - - public void clear(int offset, int length) { - clear(contents, offset, length); - } - - private static int compare(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2, int length2) { - if (length1 < length2) { - return -compare(buffer2, offset2, length2, buffer1, offset1, length1); - } - for (int i = 0; i < length2; i++) { - int j1 = buffer1[offset1 + i] & 255; - int j2 = buffer2[offset2 + i] & 255; - if (j1 > j2) - return 1; - if (j1 < j2) - return -1; - } - if (length1 > length2) - return 1; - return 0; - } - - public static int compare(Buffer buffer1, int offset1, int length1, Buffer buffer2, int offset2, int length2) { - return compare(buffer1.contents, offset1, length1, buffer2.contents, offset2, length2); - } - - public void copyInternal(int fromOffset, int toOffset, int length) { - System.arraycopy(contents, fromOffset, contents, toOffset, length); - } - - public void copyTo(byte[] buffer) { - int n = Math.min(buffer.length, contents.length); - System.arraycopy(contents, 0, buffer, 0, n); - } - - public void copyFrom(byte[] buffer) { - int n = Math.min(buffer.length, contents.length); - System.arraycopy(buffer, 0, contents, 0, n); - } - - public byte[] get() { - return get(0, contents.length); - } - - public byte[] get(int offset, int length) { - byte[] result = new byte[length]; - System.arraycopy(contents, offset, result, 0, length); - return result; - } - - public Field getField(int offset, int length) { - return new Field(this, offset, length); - } - - public byte getByte(int offset) { - return contents[offset]; - } - - public int getInt(int offset, int length) { - return (int) getLong(offset, length); - } - - public int getUInt(int offset, int length) { - int shift = Math.max(0, 32 - (length * 8)); - int mask = (-1 >>> shift) & Integer.MAX_VALUE; - return getInt(offset, length) & mask; - } - - public long getLong(int offset, int length) { - if (length <= 0) - return 0; - long v = contents[offset]; - for (int i = offset + 1; i < offset + length; i++) { - v = (v << 8) | (contents[i] & 255); - } - return v; - } - - public byte[] getByteArray() { - return contents; - } - - public int length() { - return contents.length; - } - - public void put(int offset, byte value) { - contents[offset] = value; - } - - public void put(int offset, byte[] source) { - System.arraycopy(source, 0, contents, offset, source.length); - } - - public void put(int offset, int length, byte[] source) { - int n = Math.min(length, source.length); - System.arraycopy(source, 0, contents, offset, n); - } - - public void put(int offset, int length, long n) { - long v = n; - int i = offset + length; - while (i > offset) { - i--; - contents[i] = (byte) v; - v = (v >>> 8); - } - } - - public void put(int offset, int length, int n) { - put(offset, length, (long) n); - } - - public void put(int offset, Insertable source) { - put(offset, source.toByteArray()); - } - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Convert.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Convert.java deleted file mode 100644 index bd13d1c1d..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Convert.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -import java.io.UnsupportedEncodingException; - -class Convert { - - /** - * Converts the string argument to a byte array. - */ - static String fromUTF8(byte[] b) { - String result; - try { - result = new String(b, "UTF8"); //$NON-NLS-1$ - } catch (UnsupportedEncodingException e) { - result = new String(b); - } - return result; - } - - /** - * Converts the string argument to a byte array. - */ - static byte[] toUTF8(String s) { - byte[] result; - try { - result = s.getBytes("UTF8"); //$NON-NLS-1$ - } catch (UnsupportedEncodingException e) { - result = s.getBytes(); - } - return result; - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Field.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Field.java deleted file mode 100644 index 81179ce3e..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Field.java +++ /dev/null @@ -1,148 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -public class Field implements Insertable { - protected Buffer buffer; // contents - protected int offset; // offset of the field within the buffer - protected int length; // length of the field - - /** - * Constructor for a new Field. - */ - public Field(byte[] bytes) { - this.buffer = new Buffer(bytes); - this.offset = 0; - this.length = bytes.length; - } - - /** - * Constructor for a new Field. - */ - public Field(int n) { - this.buffer = new Buffer(n); - this.offset = 0; - this.length = n; - } - - /** - * Constructor for a new Field. - */ - public Field(Buffer buffer, int offset, int length) { - this.buffer = buffer; - this.offset = offset; - this.length = length; - } - - /** - * Constructor for a new Field. - */ - public Field(Insertable anObject) { - buffer = new Buffer(anObject); - offset = 0; - length = buffer.length(); - } - - public Field clear() { - buffer.clear(offset, length); - return this; - } - - public int compareTo(Field that) { - return Buffer.compare(this.buffer, this.offset, this.length, that.buffer, that.offset, that.length); - } - - public Field subfield(int offset, int length) { - if (offset + length > this.length) - throw new IllegalArgumentException(); - return buffer.getField(this.offset + offset, length); - } - - public Field subfield(FieldDef d) { - if (d.offset + d.length > this.length) - throw new IllegalArgumentException(); - return buffer.getField(this.offset + d.offset, d.length); - } - - public Field subfield(int offset) { - return subfield(offset, this.length - offset); - } - - public byte[] get() { - return buffer.get(offset, length); - } - - public int getInt() { - return buffer.getInt(offset, length); - } - - public long getLong() { - return buffer.getLong(offset, length); - } - - public int getUInt() { - return buffer.getUInt(offset, length); - } - - public byte[] get(FieldDef d) { - return subfield(d).get(); - } - - public int getInt(FieldDef d) { - return subfield(d).getInt(); - } - - public int length() { - return length; - } - - public Pointer pointTo(int offset) { - return new Pointer(buffer, this.offset + offset); - } - - public Field put(byte[] b) { - buffer.put(offset, length, b); - return this; - } - - public Field put(int n) { - buffer.put(offset, length, n); - return this; - } - - public Field put(long n) { - buffer.put(offset, length, n); - return this; - } - - public Field put(Insertable anObject) { - put(anObject.toByteArray()); - return this; - } - - public Field put(FieldDef d, int n) { - subfield(d).put(n); - return this; - } - - public Field put(FieldDef d, Insertable anObject) { - subfield(d).put(anObject.toByteArray()); - return this; - } - - /** - * Implementation of the Insertable interface. - */ - public byte[] toByteArray() { - return get(); - } - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/FieldArray.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/FieldArray.java deleted file mode 100644 index bb1eccdf0..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/FieldArray.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -class FieldArray { - - protected Buffer buffer; // buffer over which this array is defined - protected int offset; // offset within the buffer of the first field in the array - protected int length; // length of a field - protected int stride; // the amount of space from one field to the next - protected int count; // the number of fields in the array - - /** - * Constructor. - * buffer is the underlying Buffer object. - * offset is the offset within that buffer. - * length is the length of each field in the array - * stride the number of bytes from the beginning of one element to the beginning of the next - * count is the number of elements in the array - */ - public FieldArray(Buffer buffer, int offset, int length, int stride, int count) { - this.buffer = buffer; - this.offset = offset; - this.length = length; - this.stride = stride; - this.count = count; - } - - /** - * Returns the ith field of the array. - */ - public Field fieldAt(int i) { - if (i >= count) - throw new ArrayIndexOutOfBoundsException(); - return new Field(buffer, offset + (i * stride), length); - } - - /** - * Inserts a new "empty" field before index i. - */ - public Field insert(int i) { - count++; - if (i >= count) - throw new ArrayIndexOutOfBoundsException(); - int s = offset + (i * stride); // source offset - int t = s + stride; // target offset - int n = (count - (i + 1)) * stride; // number of bytes to move - buffer.copyInternal(s, t, n); - return fieldAt(i).clear(); - } - - /** - * Removes the entry at index i and "squeezes the space up". Clears the last entry. - */ - public void remove(int i) { - if (i >= count) - throw new ArrayIndexOutOfBoundsException(); - int s = offset + ((i + 1) * stride); // source offset - int t = s - stride; // target offset - int n = (count - (i + 1)) * stride; // number of bytes to move - buffer.copyInternal(s, t, n); - fieldAt(count - 1).clear(); - count--; - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/FieldDef.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/FieldDef.java deleted file mode 100644 index 0e7be12f5..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/FieldDef.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -public class FieldDef { - - public static final int F_BYTE = 1; - public static final int F_INT = 2; - public static final int F_UINT = 3; - public static final int F_LONG = 4; - public static final int F_BYTES = 5; - - public int offset; - public int length; - public int type; - - public FieldDef(int type, int offset, int length) { - this.type = type; - this.offset = offset; - this.length = length; - } - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Index.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Index.java deleted file mode 100644 index dc90d6ff2..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Index.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -import java.util.Vector; - -/** - * This class provides the public interface to an index. - */ -public class Index { - - private IndexedStore store; - private ObjectAddress anchorAddress; - - /** - * Index constructor. - */ - Index(IndexedStore store, ObjectAddress anchorAddress) { - this.store = store; - this.anchorAddress = anchorAddress; - } - - /** - * Returns a vector of ObjectIDs whose keys match the key given in the index. - * This assumes that the underlying index has values that can be converted - * to ObjectIDs. - */ - public synchronized Vector getObjectIdentifiersMatching(byte[] key) throws IndexedStoreException { - IndexCursor cursor = open(); - cursor.find(key); - Vector vector = new Vector(20); - while (cursor.keyMatches(key)) { - vector.addElement(cursor.getValueAsObjectID()); - cursor.next(); - } - cursor.close(); - return vector; - } - - /** - * Inserts an entry into an index. The key and the value are byte arrays. - * Keys cannot be more than 1024 bytes in length. Values must not - * be greater than 2048 bytes in length. The other insert methods are - * convenience methods that use this for their implementation. - */ - public synchronized void insert(byte[] key, byte[] value) throws IndexedStoreException { - if (key.length > 1024) - throw new IndexedStoreException(IndexedStoreException.EntryKeyLengthError); - if (value.length > 2048) - throw new IndexedStoreException(IndexedStoreException.EntryValueLengthError); - IndexAnchor anchor = store.acquireAnchor(anchorAddress); - anchor.insert(key, value); - anchor.release(); - } - - public synchronized void insert(byte[] key, Insertable value) throws IndexedStoreException { - insert(key, value.toByteArray()); - } - - public synchronized void insert(String key, byte[] value) throws IndexedStoreException { - insert(Convert.toUTF8(key), value); - } - - /** - * Returns a cursor for this index. The cursor is initially in the unset state - * and should be positioned using "find" before being used. - */ - public synchronized IndexCursor open() throws IndexedStoreException { - IndexCursor c = new IndexCursor(store, anchorAddress); - return c; - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexAnchor.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexAnchor.java deleted file mode 100644 index 19bb2c1fd..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexAnchor.java +++ /dev/null @@ -1,183 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -/** - * An IndexAnchor provides a place to hang index-wide information in a fixed spot, especially - * since the root node may change due to a root node split. - */ - -class IndexAnchor extends IndexedStoreObject { - - public static final int SIZE = 32; - public static final int TYPE = 1; - - protected static final int RootNodeAddressOffset = 2; - protected static final int RootNodeAddressLength = 4; - - protected static final int NumberOfEntriesOffset = 14; - protected static final int NumberOfEntriesLength = 4; - - protected Field numberOfEntriesField; - protected int numberOfEntries; - - protected Field rootNodeAddressField; - protected ObjectAddress rootNodeAddress; - - /** - * Constructs a new index anchor from nothing. - */ - public IndexAnchor() { - super(); - numberOfEntries = 0; - rootNodeAddress = ObjectAddress.Null; - } - - /** - * Constructs a new index anchor from a field read from the store. Used by the factory. - */ - public IndexAnchor(Field f, ObjectStore store, ObjectAddress address) throws ObjectStoreException { - super(f, store, address); - } - - /** - * Sets the fields definitions. Done after the contents are set. - */ - private void setFields(Field f) { - rootNodeAddressField = f.subfield(RootNodeAddressOffset, RootNodeAddressLength); - numberOfEntriesField = f.subfield(NumberOfEntriesOffset, NumberOfEntriesLength); - } - - /** - * Places the contents of the fields into the buffer. - * Subclasses should implement and call super. - */ - protected void insertValues(Field f) { - super.insertValues(f); - setFields(f); - numberOfEntriesField.put(numberOfEntries); - rootNodeAddressField.put(rootNodeAddress); - } - - /** - * Places the contents of the buffer into the fields. - * Subclasses should implement and call super. - */ - protected void extractValues(Field f) throws ObjectStoreException { - super.extractValues(f); - setFields(f); - numberOfEntries = numberOfEntriesField.getInt(); - rootNodeAddress = new ObjectAddress(rootNodeAddressField.get()); - } - - /** - * Returns the minimum size of this object's instance -- including its type field. - * Subclasses should override. - */ - protected int getMinimumSize() { - return SIZE; - } - - /** - * Returns the required type of this class of object. - * Subclasses must override. - */ - protected int getRequiredType() { - return TYPE; - } - - /** - * Returns a printable representation of this object. - */ - public String toString() { - StringBuffer b = new StringBuffer(); - b.append("Anchor("); //$NON-NLS-1$ - b.append(numberOfEntries); - b.append(","); //$NON-NLS-1$ - b.append(rootNodeAddress); - b.append(")"); //$NON-NLS-1$ - return b.toString(); - } - - /** - * Processes the notification that an entry was inserted. - */ - void entryInserted(IndexNode node) { - if (node.isLeaf()) { - numberOfEntries++; - setChanged(); - } - } - - /** - * Processes the notification by a leaf node that an entry was removed. - */ - void entryRemoved(IndexNode node) { - if (node.isLeaf()) { - numberOfEntries--; - setChanged(); - } - } - - /** - * Sets the root node address. Set when root node is initialized or split. - */ - void setRootNodeAddress(ObjectAddress rootNodeAddress) { - this.rootNodeAddress = rootNodeAddress; - setChanged(); - } - - /** - * This method returns a cursor set to the first entry in the index whose key - * is greater than or equal to the key provided. To set a cursor to the beginning - * of the index use a key of zero length. - */ - void find(byte key[], IndexCursor cursor) throws IndexedStoreException { - if (rootNodeAddress.isNull()) { - cursor.reset(); - } else { - IndexNode rootNode = acquireNode(rootNodeAddress); - rootNode.find(key, cursor); - rootNode.release(); - } - } - - /** - * This method returns a cursor set to the first entry in the index. - */ - void findFirstEntry(IndexCursor cursor) throws IndexedStoreException { - if (rootNodeAddress.isNull()) { - cursor.reset(); - } else { - IndexNode rootNode = acquireNode(rootNodeAddress); - rootNode.findFirstEntry(cursor); - rootNode.release(); - } - } - - /** - * Insert an entry into an index. - */ - void insert(byte[] key, byte[] value) throws IndexedStoreException { - if (rootNodeAddress.isNull()) { - IndexNode rootNode = new IndexNode(this.address); - try { - store.insertObject(rootNode); - } catch (ObjectStoreException e) { - throw new IndexedStoreException(IndexedStoreException.IndexNodeNotCreated, e); - } - rootNodeAddress = rootNode.getAddress(); - } - IndexNode rootNode = acquireNode(rootNodeAddress); - rootNode.insertEntry(key, value); - rootNode.release(); - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexCursor.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexCursor.java deleted file mode 100644 index 3d5a7ac6c..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexCursor.java +++ /dev/null @@ -1,389 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -public class IndexCursor { - - private IndexedStore store; - private ObjectAddress anchorAddress; - private int entryNumber; - private IndexNode leafNode; - private boolean entryRemoved; - - /** - * Constructor for an IndexCursor. Cursors should only be constructed - * by the index during an open operation. - */ - IndexCursor(IndexedStore store, ObjectAddress anchorAddress) { - this.anchorAddress = anchorAddress; - this.store = store; - this.leafNode = null; - this.entryNumber = -1; - } - - /** - * Adjusts the position of a cursor to point to a "real" entry - * entry if it is pointing outside of the entries of a node. - * If there are no more entries then unset the cursor. - */ - private void adjust() throws IndexedStoreException { - if (leafNode == null) - return; - if (entryNumber >= leafNode.getNumberOfEntries()) { - ObjectAddress next = leafNode.getNextAddress(); - int n = entryNumber - leafNode.getNumberOfEntries(); - set(next, n); - } else if (entryNumber < 0) { - ObjectAddress previous = leafNode.getPreviousAddress(); - int n = entryNumber; - set(previous, n); - } - } - - /** - * Closes the cursor. This unsets the cursor and deregisters it from all the - * interested parties. - */ - public void close() throws IndexedStoreException { - reset(); - } - - /** - * Adjusts a cursor if there is a need after an entry is inserted. - * If not, it just returns. - */ - void entryInserted(int i) throws IndexedStoreException { - if (entryNumber >= i) - entryNumber++; - adjust(); - } - - /** - * Adjusts a cursor if there is a need after an entry is removed. - */ - void entryRemoved(int i) throws IndexedStoreException { - entryRemoved = (entryNumber == i); - if (entryNumber > i) - entryNumber--; - adjust(); - } - - /** - * Sets the cursor at the first entry of an index whose key is - * greater than or equal to that of the argument. Returns the cursor itself - * for convenience in chaining method invocations. - */ - public synchronized IndexCursor find(byte[] b) throws IndexedStoreException { - IndexAnchor anchor = store.acquireAnchor(anchorAddress); - anchor.find(b, this); - anchor.release(); - entryRemoved = false; - return this; - } - - /** - * Sets the cursor at the first entry of an index whose key is - * greater than or equal to that of the argument. Returns the cursor itself - * for convenience in chaining method invocations. - */ - public synchronized IndexCursor find(String s) throws IndexedStoreException { - return find(Convert.toUTF8(s)); - } - - /** - * Sets the cursor at the first entry of an index. - */ - public synchronized IndexCursor findFirstEntry() throws IndexedStoreException { - IndexAnchor anchor = store.acquireAnchor(anchorAddress); - anchor.findFirstEntry(this); - anchor.release(); - entryRemoved = false; - return this; - } - - /** - * Returns the byte array holding the key for the current cursor location. - * If the cursor is at the beginning or end of the index then return null. - * - * Throws an EntryRemoved condition if the entry at which it has - * been pointing has been removed by another cursor. - */ - public synchronized byte[] getKey() throws IndexedStoreException { - if (entryRemoved) - throw new IndexedStoreException(IndexedStoreException.EntryRemoved); - if (leafNode == null) - return null; - byte[] key = leafNode.getKey(entryNumber); - return key; - } - - /** - * Returns the byte array holding the value for the current cursor location. If the cursor is - * at the beginning or end of the index then return null. - * - * Throws an EntryRemoved condition if the entry at which it has - * been pointing has been removed by another cursor. - */ - public synchronized byte[] getValue() throws IndexedStoreException { - if (entryRemoved) - throw new IndexedStoreException(IndexedStoreException.EntryRemoved); - if (leafNode == null) - return null; - byte[] value = leafNode.getValue(entryNumber); - return value; - } - - /** - * Returns the value as an object address. May return null if the cursor is at the beginning - * or end of the index. - */ - ObjectAddress getValueAsObjectAddress() throws IndexedStoreException { - byte[] value = getValue(); - if (value == null) - return null; - return new ObjectAddress(value); - } - - /** - * Returns the ObjectID from the value for the current cursor location. - * If the cursor is at the beginning or end of the index then return null. - */ - public synchronized ObjectID getValueAsObjectID() throws IndexedStoreException { - byte[] value = getValue(); - if (value == null) - return null; - return new ObjectID(value); - } - - /** - * This method returns true if the current cursor location before the first entry in the index. - */ - public synchronized boolean isAtBeginning() throws IndexedStoreException { - if (entryRemoved) - throw new IndexedStoreException(IndexedStoreException.EntryRemoved); - return (leafNode == null); - } - - /** - * Returns true if the cursor is set to an entry. - * Returns false otherwise. - */ - public synchronized boolean isSet() throws IndexedStoreException { - if (entryRemoved) - throw new IndexedStoreException(IndexedStoreException.EntryRemoved); - return !(leafNode == null); - } - - /** - * Compares a byte array to the key in the cursor and - * returns true if the byte array is equal to the key at the entry in the cursor. - * - * Throws an EntryRemoved condition if the entry at which it has - * been pointing has been removed by another cursor. - */ - public synchronized boolean keyEquals(byte[] b) throws IndexedStoreException { - if (entryRemoved) - throw new IndexedStoreException(IndexedStoreException.EntryRemoved); - if (leafNode == null) - return false; - byte[] key = leafNode.getKey(entryNumber); - if (b.length != key.length) { - return false; - } - for (int i = 0; i < b.length; i++) { - if (key[i] != b[i]) { - return false; - } - } - return true; - } - - /** - * Compares a byte array to the key in the cursor and - * returns true if the byte array is a prefix - * of the key at the entry in the cursor. - * - * Throws an EntryRemoved condition if the entry at which it has - * been pointing has been removed by another cursor. - */ - public synchronized boolean keyMatches(byte[] b) throws IndexedStoreException { - if (entryRemoved) - throw new IndexedStoreException(IndexedStoreException.EntryRemoved); - if (leafNode == null) - return false; - byte[] key = leafNode.getKey(entryNumber); - if (key.length < b.length) { - return false; - } - for (int i = 0; i < b.length; i++) { - if (key[i] != b[i]) { - return false; - } - } - return true; - } - - /** - * Compares a String to the key in the cursor and - * returns true if the byte array is a prefix - * of the key at the entry in the cursor. - */ - public synchronized boolean keyMatches(String s) throws IndexedStoreException { - return keyMatches(Convert.toUTF8(s)); - } - - /** - * Moves the cursor to the next index entry. - * If the cursor is at the last entry, it becomes unset. - * If the cursor is unset, then it is set to the first entry. - * The cursor itself is returned. - * - * Throws an EntryRemoved condition if the entry at which it has - * been pointing has been removed by another cursor. - */ - public synchronized IndexCursor next() throws IndexedStoreException { - if (isAtBeginning()) { - findFirstEntry(); - } else { - entryNumber++; - adjust(); - } - return this; - } - - /** - * Adjusts a cursor if there is a need after a node has been split. - * If not, it just returns. - */ - void nodeSplit() throws IndexedStoreException { - adjust(); - } - - /** - * Removes the entry at the current cursor location. If the cursor is not set - * then no operation is done. If an element is removed - * the cursor automatically advances to the "next" element. - * Removing an element adjusts all cursors (including this one) pointing into this node. - * If there is no next element, the cursor is unset. - * - * Throws an EntryRemoved condition if the entry at which it has - * been pointing has been removed by another cursor. - */ - public synchronized void remove() throws IndexedStoreException { - removeEntry(); - } - - /** - * Removes the entry at the current cursor location. If the cursor is not set - * then no operation is done. If an element is removed - * the cursor automatically advances to the "next" element. - * Removing an element adjusts all cursors (including this one) pointing into this node. - * If there is no next element, the cursor is unset. - * - * Throws an EntryRemoved condition if the entry at which it has - * been pointing has been removed by another cursor. - */ - void removeEntry() throws IndexedStoreException { - if (entryRemoved) - throw new IndexedStoreException(IndexedStoreException.EntryRemoved); - if (leafNode == null) - return; - ObjectAddress address = leafNode.getAddress(); - leafNode.removeEntry(entryNumber); - entryRemoved = false; // Clear the flag. This cursor is positioned to the next entry and remains valid. - - /* remove empty nodes from the tree */ - while (!address.isNull()) { - IndexNode node = store.acquireNode(address); - if (node.getNumberOfEntries() > 0) { - node.release(); - break; - } - ObjectAddress parentAddress = node.getParentAddress(); - node.unlink(); - node.release(); - store.removeObject(address); - address = parentAddress; - } - } - - /** - * Places the cursor in the "unset" state. - */ - public synchronized void reset() throws IndexedStoreException { - unset(); - entryRemoved = false; - } - - /** - * Sets the cursor to a particular entry of an index node. - */ - void set(ObjectAddress leafNodeAddress, int entryNumber) throws IndexedStoreException { - unset(); - if (leafNodeAddress.isNull()) - return; - leafNode = store.acquireNode(leafNodeAddress); - leafNode.addCursor(this); - if (entryNumber >= 0) - this.entryNumber = entryNumber; - else - this.entryNumber = leafNode.getNumberOfEntries() + entryNumber; - adjust(); - } - - /** - * Places the cursor in the "unset" state. - */ - private void unset() throws IndexedStoreException { - if (leafNode != null) { - leafNode.removeCursor(this); - leafNode.release(); - } - entryNumber = -1; - leafNode = null; - entryRemoved = false; - } - - /** - * Updates the value of the index entry at the cursor. - * If the cursor is at the beginning or end of the index then do nothing. - * Returns true if the value is set, false otherwise. - */ - void updateEntry(byte[] b) throws IndexedStoreException { - if (entryRemoved) - throw new IndexedStoreException(IndexedStoreException.EntryRemoved); - if (b.length > 2048) - throw new IndexedStoreException(IndexedStoreException.EntryValueLengthError); - if (leafNode == null) - return; - leafNode.updateValueAt(entryNumber, b); - } - - /** - * Updates the value of the index entry at the cursor. - * If the cursor is at the beginning or end of the index then do nothing. - * Returns true if the value is set, false otherwise. - * - * Throws an EntryRemoved condition if the entry at which it has - * been pointing has been removed by another cursor. - */ - public synchronized void updateValue(byte[] b) throws IndexedStoreException { - updateEntry(b); - } - - /** - * Updates the value of the index entry at the cursor. - * If the cursor is at the beginning or end of the index then do nothing. - */ - public synchronized void updateValue(Insertable anObject) throws IndexedStoreException { - updateValue(anObject.toByteArray()); - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexNode.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexNode.java deleted file mode 100644 index 2186d898c..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexNode.java +++ /dev/null @@ -1,922 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -import java.util.HashSet; - -class IndexNode extends IndexedStoreObject { - - /* needed for all stored objects */ - public static final int SIZE = MAXIMUM_OBJECT_SIZE; - public static final int TYPE = 3; - - /* field definitions */ - private static final int EntriesFieldOffset = 64; - private static final int EntriesFieldSize = SIZE - EntriesFieldOffset; - private static final FieldDef NodeType = new FieldDef(FieldDef.F_INT, 2, 2); - private static final FieldDef AnchorAddress = new FieldDef(FieldDef.F_BYTES, 4, 4); - private static final FieldDef ParentAddress = new FieldDef(FieldDef.F_BYTES, 8, 4); - private static final FieldDef PreviousAddress = new FieldDef(FieldDef.F_BYTES, 12, 4); - private static final FieldDef NextAddress = new FieldDef(FieldDef.F_BYTES, 16, 4); - private static final FieldDef NumberOfEntries = new FieldDef(FieldDef.F_INT, 20, 2); - private static final FieldDef UsedSpace = new FieldDef(FieldDef.F_INT, 22, 2); - private static final FieldDef UsedSpaceMax = new FieldDef(FieldDef.F_INT, 24, 2); - private static final FieldDef EntriesField = new FieldDef(FieldDef.F_BYTES, EntriesFieldOffset, EntriesFieldSize); - - /* field values */ - private int nodeType; - private ObjectAddress anchorAddress; - private ObjectAddress parentAddress; - private ObjectAddress previousAddress; - private ObjectAddress nextAddress; - private int numberOfEntries; - private int usedSpace; - private int usedSpaceMax; - private Field entriesField; - - /* types of nodes in the index */ - private static final int RootNode = 1; - private static final int InteriorNode = 2; - private static final int LeafNode = 3; - - /* miscellaneous constants */ - private static final int DescriptorLength = 6; - - /* cursors in this node */ - private HashSet cursors = new HashSet(); - - /** - * Reconstructs a node from a field. - */ - IndexNode(Field f, ObjectStore store, ObjectAddress address) throws ObjectStoreException { - super(f, store, address); - } - - /** - * Constructor that creates a root node. - */ - IndexNode(ObjectAddress anchorAddress) { - super(); - this.anchorAddress = anchorAddress; - this.parentAddress = ObjectAddress.Null; - this.previousAddress = ObjectAddress.Null; - this.nextAddress = ObjectAddress.Null; - this.usedSpace = 0; - this.usedSpaceMax = 0; - this.numberOfEntries = 0; - this.nodeType = RootNode; - this.entriesField = new Field(SIZE - EntriesFieldOffset); - } - - /** - * Constructor that creates an interior node. - */ - IndexNode(ObjectAddress anchorAddress, ObjectAddress parentAddress) { - this(anchorAddress); - this.parentAddress = parentAddress; - this.nodeType = InteriorNode; - } - - /** - * Constructor that creates a leaf node. - */ - IndexNode(ObjectAddress anchorAddress, ObjectAddress parentAddress, ObjectAddress previousAddress, ObjectAddress nextAddress) { - this(anchorAddress, parentAddress); - this.previousAddress = previousAddress; - this.nextAddress = nextAddress; - this.nodeType = LeafNode; - } - - /** - * Registers a cursor with this node. - */ - void addCursor(IndexCursor cursor) { - cursors.add(cursor); - } - - /** - * Compares the key at a particular entry to a byte array. - */ - private int compareEntryToKey(int entryNumber, byte[] key) throws IndexedStoreException { - Field keyField = new Field(key); - Field entryKeyField = getKeyField(entryNumber); - return entryKeyField.compareTo(keyField); - } - - /** - * Compresses the space in the entries area of the node. - */ - private void compress() throws IndexedStoreException { - - /* some preliminaries */ - int entriesLength = entriesField.length(); - int descriptorBlockSize = numberOfEntries * DescriptorLength; - - /* need to make a copy of the entries in the area, this will compress it */ - Field f2 = new Field(entriesField.length()); - copyEntries(entriesField, 0, numberOfEntries, f2); - - /* copy the entries area back to the node and modify the usedSpaceMax to reflect the compression */ - entriesField.put(f2.get()); - usedSpaceMax = usedSpace; - - /* clear the space in the between the descriptor array and the entries heap */ - int freeBlockSize = entriesLength - (descriptorBlockSize + usedSpaceMax); - Field f3 = entriesField.subfield(descriptorBlockSize, freeBlockSize); - f3.clear(); - setChanged(); - } - - /** - * Compresses the space in the entries area of the node if the free space block - * is smaller than the given threshold. - */ - private void compress(int threshold) throws IndexedStoreException { - int entriesLength = entriesField.length(); - int descriptorBlockSize = numberOfEntries * DescriptorLength; - int freeBlockSize = entriesLength - (descriptorBlockSize + usedSpaceMax); - if (freeBlockSize >= threshold) - return; - compress(); - } - - /** - * Copies entries from one Field to another. Fields are assumed to contain an array of descriptors at the - * low end and a heap of (key,value) pairs at the high end. - */ - private static int copyEntries(Field sourceField, int sourceIndex, int numberOfEntries, Field targetField) { - - Pointer tDescriptor = targetField.pointTo(0); - Pointer sDescriptor = sourceField.pointTo(sourceIndex * DescriptorLength); - int tEntryOffset = targetField.length(); - - // for each descriptor make a new one in the new area and copy its (key,value) entry - for (int i = 0; i < numberOfEntries; i++) { - - // extract information from old descriptor - int sEntryOffset = sDescriptor.getField(0, 2).getUInt(); - int keyLength = sDescriptor.getField(2, 2).getUInt(); - int valueLength = sDescriptor.getField(4, 2).getUInt(); - int entryLength = keyLength + valueLength; - Field sEntry = sourceField.subfield(sEntryOffset, entryLength); - - // copy the (key,value) entry from the old to the new space - tEntryOffset -= entryLength; - Field tEntry = targetField.subfield(tEntryOffset, entryLength); - tEntry.put(sEntry.get()); - - // create a new descriptor - tDescriptor.getField(0, 2).put(tEntryOffset); - tDescriptor.getField(2, 2).put(keyLength); - tDescriptor.getField(4, 2).put(valueLength); - - // on to the next one - tDescriptor.inc(DescriptorLength); - sDescriptor.inc(DescriptorLength); - } - return targetField.length() - tEntryOffset; - } - - /** - * Places the contents of the fields into the buffer. - * Subclasses should implement and call super. - */ - protected void insertValues(Field f) { - super.insertValues(f); - f.put(AnchorAddress, anchorAddress); - f.put(ParentAddress, parentAddress); - f.put(NextAddress, nextAddress); - f.put(PreviousAddress, previousAddress); - f.put(NodeType, nodeType); - f.put(NumberOfEntries, numberOfEntries); - f.put(UsedSpace, usedSpace); - f.put(UsedSpaceMax, usedSpaceMax); - f.put(EntriesField, entriesField); - } - - /** - * Causes the node to remove its children from the store. - */ - void destroyChildren() throws IndexedStoreException { - if (!isLeaf()) { - for (int i = 0; i < numberOfEntries; i++) { - ObjectAddress childNodeAddress = new ObjectAddress(getValue(i)); - IndexNode childNode = acquireNode(childNodeAddress); - childNode.destroyChildren(); - childNode.release(); - removeObject(childNodeAddress); - } - } - } - - /** - * Places a cursor and the first entry greater than or equal to a key. - */ - void find(byte[] key, IndexCursor cursor) throws IndexedStoreException { - int i; - i = findLastEntryLT(key); - if (isLeaf()) { - cursor.set(address, i + 1); - } else if (i >= 0) { - IndexNode childNode = acquireNode(new ObjectAddress(getValue(i))); - childNode.find(key, cursor); - childNode.release(); - } else if (numberOfEntries > 0) { - IndexNode childNode = acquireNode(new ObjectAddress(getValue(0))); - childNode.find(key, cursor); - childNode.release(); - } else { - cursor.reset(); - } - } - - /** - * Places a cursor at the first entry of a node. - */ - void findFirstEntry(IndexCursor cursor) throws IndexedStoreException { - if (numberOfEntries == 0) { - cursor.reset(); - } else if (!isLeaf()) { - IndexNode childNode = acquireNode(new ObjectAddress(getValue(0))); - childNode.findFirstEntry(cursor); - childNode.release(); - } else { - cursor.set(address, 0); - } - } - - /** - * Returns the index of the first entry greater than a key. - */ - private int findFirstEntryGT(byte[] key) throws IndexedStoreException { - int lo = 0; - int hi = numberOfEntries - 1; - while (lo <= hi) { - int i = (lo + hi) / 2; - int c = compareEntryToKey(i, key); - if (c <= 0) { - lo = i + 1; - } else { - hi = i - 1; - } - } - return lo; - } - - /** - * Places a cursor at the last entry of a node. - */ - void findLastEntry(IndexCursor cursor) throws IndexedStoreException { - if (numberOfEntries == 0) { - cursor.reset(); - return; - } - int i = numberOfEntries - 1; - if (!isLeaf()) { - IndexNode childNode = acquireNode(new ObjectAddress(getValue(i))); - childNode.findLastEntry(cursor); - childNode.release(); - } else { - cursor.set(address, i); - } - } - - /** - * Returns the index of the last entry less than a key. - */ - private int findLastEntryLT(byte[] key) throws IndexedStoreException { - int lo = 0; - int hi = numberOfEntries - 1; - Field keyField = new Field(key); - while (lo <= hi) { - int i = (lo + hi) / 2; - int c = getKeyField(i).compareTo(keyField); - if (c < 0) { - lo = i + 1; - } else { - hi = i - 1; - } - } - return hi; - } - - /** - * Returns the descriptor field for the node entry at a given index. - */ - private Field getDescriptor(int i) { - return entriesField.subfield(i * DescriptorLength, DescriptorLength); - } - - /** - * Returns the entire array of entry descriptors. - */ - private FieldArray getDescriptorArray() { - return entriesField.pointTo(0).getArray(DescriptorLength, DescriptorLength, numberOfEntries); - } - - private Field getEntriesField() { - return entriesField; - } - - /** - * Returns the value of the key for an entry at a given index. - */ - byte[] getKey(int i) { - return getKeyField(i).get(); - } - - /** - * Returns a Field covering the key for an entry at a given index. - */ - private Field getKeyField(int i) { - // Field descriptor = getDescriptor(i); - // int keyOffset = descriptor.subfield(0, 2).getUInt(); - // int keyLength = descriptor.subfield(2, 2).getUInt(); - // return entriesField.subfield(keyOffset, keyLength); - //above is the original code that created three garbage field objects - //below is the optimized code that only creates one field object - int descriptorOff = i * DescriptorLength; - Buffer buffer = entriesField.buffer; - return entriesField.subfield(buffer.getUInt(descriptorOff, 2), //these bytes hold the key offset - buffer.getUInt(descriptorOff + 2, 2));//these bytes hold the key length - } - - /** - * Returns a Field covering the (key, value) pair for an entry at a given index. - */ - private Field getKeyValueField(int i) { - Field descriptor = getDescriptor(i); - int offset = descriptor.subfield(0, 2).getUInt(); - int keyLength = descriptor.subfield(2, 2).getUInt(); - int valueLength = descriptor.subfield(4, 2).getUInt(); - return entriesField.subfield(offset, keyLength + valueLength); - } - - /** - * Returns the lowest key in the node. If none, returns an empty byte arrray. - */ - private byte[] getLowKey() { - if (numberOfEntries == 0) - return new byte[0]; - return getKey(0); - } - - /** - * Returns the minimum size of this object's instance -- including its type field. - * Subclasses should override. - */ - protected int getMinimumSize() { - return SIZE; - } - - ObjectAddress getNextAddress() { - return nextAddress; - } - - int getNumberOfEntries() { - return numberOfEntries; - } - - /** - * Returns the number of nodes in this subtree (this one plus all descendants). - */ - int getNumberOfNodes() throws IndexedStoreException { - if (isLeaf()) - return 1; - int sum = 0; - for (int i = 0; i < numberOfEntries; i++) { - ObjectAddress childAddress = new ObjectAddress(getValue(i)); - IndexNode childNode = acquireNode(childAddress); - sum += childNode.getNumberOfNodes(); - childNode.release(); - } - return sum + 1; - } - - ObjectAddress getParentAddress() { - return parentAddress; - } - - ObjectAddress getPreviousAddress() { - return previousAddress; - } - - /** - * Returns the required type of this class of object. - * Subclasses must override. - */ - protected int getRequiredType() { - return TYPE; - } - - private int getUsedSpace() { - return usedSpace; - } - - /** - * Returns the value for an entry at a given index. - */ - byte[] getValue(int i) { - return getValueField(i).get(); - } - - /** - * Returns a Field covering the value for an entry at a given index. - */ - private Field getValueField(int i) { - Field descriptor = getDescriptor(i); - int keyOffset = descriptor.subfield(0, 2).getUInt(); - int keyLength = descriptor.subfield(2, 2).getUInt(); - int valueLength = descriptor.subfield(4, 2).getUInt(); - int valueOffset = keyOffset + keyLength; - return entriesField.subfield(valueOffset, valueLength); - } - - /** - * Inserts an entry into the node. If this was inserted in slot 0, then we must update the parent - * node's low key. If this was a leaf node then we must update the anchor'ss number of entries and - * adjust any cursors for this node. This may also cause a split. - * - * Implementation Note: Cannot use an iterator over the cursor set because - * notification of an insert may remove the cursor being notified from the cursor set. - */ - void insertEntry(byte[] key, byte[] value) throws IndexedStoreException { - int i = findFirstEntryGT(key); - if (isLeaf()) { - insertEntryBefore(i, key, value); - Object[] cursorArray = cursors.toArray(); - for (int j = 0; j < cursorArray.length; j++) { - IndexCursor cursor = (IndexCursor) cursorArray[j]; - cursor.entryInserted(i); - } - IndexAnchor anchor = acquireAnchor(anchorAddress); - anchor.entryInserted(this); - anchor.release(); - } else { - ObjectAddress childNodeAddress = null; - if (getNumberOfEntries() == 0) { - IndexNode childNode = new IndexNode(anchorAddress, address, ObjectAddress.Null, ObjectAddress.Null); - childNodeAddress = insertObject(childNode); - } else { - childNodeAddress = new ObjectAddress(getValue(Math.max(0, (i - 1)))); - } - IndexNode childNode = acquireNode(childNodeAddress); - childNode.insertEntry(key, value); - childNode.release(); - } - } - - /** - * Inserts a new (key, value) pair in front of the entry at the given index. - * If the node needs to be split, split it and then attempt the insert again. If this is a - * non-leaf node then the value is the address of a child. That child's parent address - * will be updated if that (key, value) is to be inserted into a new node. - */ - private void insertEntryBefore(int i, byte[] key, byte[] value) throws IndexedStoreException { - Field entries = entriesField; - int entriesLength = entries.length(); - int keyValueLength = key.length + value.length; - int neededSpace = keyValueLength + DescriptorLength; - int freeSpace = entriesLength - ((numberOfEntries * DescriptorLength) + usedSpace); - if (freeSpace < neededSpace) { - ObjectAddress newNodeAddress = split(); - if (i > numberOfEntries) { - if (!isLeaf()) { - ObjectAddress childAddress = new ObjectAddress(value); - IndexNode child = acquireNode(childAddress); - child.setParentAddress(newNodeAddress); - child.release(); - } - IndexNode newNode = acquireNode(newNodeAddress); - newNode.insertEntryBefore(i - getNumberOfEntries(), key, value); - newNode.release(); - } else { - insertEntryBefore(i, key, value); - } - return; - } - - /* place the value and key fields into the space */ - compress(neededSpace); - Pointer p = entries.pointTo(entriesLength - usedSpaceMax); - p.dec(value.length).put(value); - p.dec(key.length).put(key); - usedSpaceMax += keyValueLength; - usedSpace += keyValueLength; - - /* create a hole in the descriptor area for a new descriptor */ - Field newDescriptor = getDescriptorArray().insert(i); - numberOfEntries++; - - /* create a new descriptor */ - newDescriptor.subfield(0, 2).put(entriesLength - usedSpaceMax); - newDescriptor.subfield(2, 2).put(key.length); - newDescriptor.subfield(4, 2).put(value.length); - - /* update the parent key for this node if this was the 0th entry */ - if (i == 0 && !parentAddress.isNull()) { - IndexNode parent = acquireNode(parentAddress); - if (numberOfEntries == 1) { - parent.insertKeyForChild(address, key); - } else { - parent.updateKeyForChild(getKey(1), address, key); - } - parent.release(); - } - setChanged(); - } - - /** - * Inserts a child address into a non-leaf node. This may result in this node splitting. - */ - private void insertKeyForChild(ObjectAddress childAddress, byte[] key) throws IndexedStoreException { - int i = findFirstEntryGT(key); - insertEntryBefore(i, key, childAddress.toByteArray()); - if (i == 0 && !parentAddress.isNull()) { - IndexNode parent = acquireNode(parentAddress); - parent.updateKeyForChild(getKey(1), address, key); - parent.release(); - } - } - - boolean isInterior() { - return (nodeType == InteriorNode); - } - - boolean isLeaf() { - return (nodeType == LeafNode); - } - - boolean isRoot() { - return (nodeType == RootNode); - } - - /** - * Places the contents of the buffer into the fields. - * Subclasses should implement and call super. - */ - protected void extractValues(Field f) throws ObjectStoreException { - super.extractValues(f); - anchorAddress = new ObjectAddress(f.get(AnchorAddress)); - parentAddress = new ObjectAddress(f.get(ParentAddress)); - nextAddress = new ObjectAddress(f.get(NextAddress)); - previousAddress = new ObjectAddress(f.get(PreviousAddress)); - nodeType = f.getInt(NodeType); - numberOfEntries = f.getInt(NumberOfEntries); - usedSpace = f.getInt(UsedSpace); - usedSpaceMax = f.getInt(UsedSpaceMax); - entriesField = new Field(f.get(EntriesField)); - } - - /** - * Removes a cursor that is registered with this node. - */ - void removeCursor(IndexCursor cursor) { - cursors.remove(cursor); - } - - /** - * Removes the descriptor and key/value pair at the entry number given. This may - * result in the node becoming empty. The caller will need to take steps to plan for this. - */ - void removeEntry(int i) throws IndexedStoreException { - - /* remove the (key,value) entry */ - byte[] key = getKey(i); - Field f = getKeyValueField(i); - f.clear(); - usedSpace -= f.length(); - - /* remove the descriptor */ - getDescriptorArray().remove(i); - numberOfEntries--; - - /* if the 0th entry was removed, need to update the parent node with the new "low key" */ - if (i == 0 && !parentAddress.isNull()) { - IndexNode parent = acquireNode(parentAddress); - if (numberOfEntries > 0) { - parent.updateKeyForChild(key, address, getKey(0)); - } else { - parent.removeKeyForChild(address); - } - parent.release(); - } - - /* Notify any cursors and the anchor */ - Object[] cursorArray = cursors.toArray(); - for (int j = 0; j < cursorArray.length; j++) { - IndexCursor cursor = (IndexCursor) cursorArray[j]; - cursor.entryRemoved(i); - } - IndexAnchor anchor = acquireAnchor(anchorAddress); - anchor.entryRemoved(this); - anchor.release(); - setChanged(); - } - - /** - * Removes a child node address reference from a non-leaf node. - */ - private void removeKeyForChild(ObjectAddress childAddress) throws IndexedStoreException { - Field childAddressField = new Field(childAddress); - int i = 0; - while (i < numberOfEntries) { - if (getValueField(i).compareTo(childAddressField) == 0) - break; - i++; - } - if (i < numberOfEntries) - removeEntry(i); - } - - private void setNextAddress(ObjectAddress address) { - nextAddress = address; - setChanged(); - } - - private void setNodeType(int nodeType) { - this.nodeType = nodeType; - setChanged(); - } - - private void setNumberOfEntries(int numberOfEntries) { - this.numberOfEntries = numberOfEntries; - setChanged(); - } - - private void setParentAddress(ObjectAddress address) { - parentAddress = address; - setChanged(); - } - - private void setPreviousAddress(ObjectAddress address) { - previousAddress = address; - setChanged(); - } - - private void setUsedSpace(int usedSpace) { - this.usedSpace = usedSpace; - setChanged(); - } - - private void setUsedSpaceMax(int usedSpaceMax) { - this.usedSpaceMax = usedSpaceMax; - setChanged(); - } - - /** - * Splits an index node. This split results in a new "low key" being placed in the parent. This may - * cause a parent node to split as well. Splits eventually propagate to the root node, cause it - * to split and a new root node to be created. - */ - private ObjectAddress split() throws IndexedStoreException { - - /* Nodes can only be split if there are at least 2 entries */ - int n = numberOfEntries; - if (n < 2) { - throw new IndexedStoreException(IndexedStoreException.IndexNodeNotSplit); - } - - /* - If this is a root node, need to make it an interior node and create a new parent root node. - Also need to modify the index anchor to indicate the new root node, and place this node (the old root node) - into the new root node. The new root node can always accept its first entry without splitting. - */ - if (isRoot()) { - ObjectAddress newRootNodeAddress = insertObject(new IndexNode(anchorAddress)); - parentAddress = newRootNodeAddress; - nodeType = InteriorNode; - IndexNode newRootNode = acquireNode(newRootNodeAddress); - newRootNode.insertKeyForChild(address, getLowKey()); - newRootNode.release(); - IndexAnchor anchor = acquireAnchor(anchorAddress); - anchor.setRootNodeAddress(newRootNodeAddress); - anchor.release(); - } - - /* - Get a new node, fill it with half the entries from this node, then compress this node. The - new node is created with current parent. However, the node at the current parentAddress may - split when the key is added to it for the new node. Non-leaf nodes compensate for this - by updating the newNode's parentAddress during the insertion. - */ - ObjectAddress newNodeAddress = insertObject(new IndexNode(anchorAddress, parentAddress)); - IndexNode newNode = acquireNode(newNodeAddress); - Field f1 = entriesField; - Field f2 = newNode.getEntriesField(); - int k = n / 2; - newNode.setUsedSpace(copyEntries(f1, n - k, k, f2)); - newNode.setUsedSpaceMax(newNode.getUsedSpace()); - newNode.setNumberOfEntries(k); - usedSpace = usedSpace - newNode.getUsedSpace(); - numberOfEntries = n - k; - compress(); - - /* - If this was a leaf node, need to set the previous and next pointers of the this node, - the new node, and the old "next" node. - */ - if (isLeaf()) { - newNode.setNodeType(LeafNode); - newNode.setNextAddress(nextAddress); - newNode.setPreviousAddress(address); - if (!nextAddress.isNull()) { - IndexNode nextNode = acquireNode(nextAddress); - nextNode.setPreviousAddress(newNodeAddress); - nextNode.release(); - } - nextAddress = newNodeAddress; - } - - /* - If this is a non-leaf node, need to update the parent addresses of any child nodes - of the new node. k is the number of entries in the new node. - */ - if (!isLeaf()) { - for (int i = 0; i < k; i++) { - ObjectAddress childAddress = new ObjectAddress(newNode.getValue(i)); - IndexNode childNode = acquireNode(childAddress); - childNode.setParentAddress(newNodeAddress); - childNode.release(); - } - } - - /* - Need to insert the new node's low key and address into the parent. This may - result in the parent splitting and having to update the parent address of this node. - */ - IndexNode parentNode = acquireNode(parentAddress); - parentNode.insertKeyForChild(newNodeAddress, newNode.getLowKey()); - parentNode.release(); - - /* Clean up. */ - newNode.release(); - - /* Notify any cursors and the anchor */ - Object[] cursorArray = cursors.toArray(); - for (int j = 0; j < cursorArray.length; j++) { - IndexCursor cursor = (IndexCursor) cursorArray[j]; - cursor.nodeSplit(); - } - setChanged(); - return newNodeAddress; - } - - /** - * Unlinks a node from its parent and siblings. This does not modify the current node, but - * does modify all the nodes and anchors pointing to it. - */ - void unlink() throws IndexedStoreException { - if (isRoot()) { - IndexAnchor anchor = acquireAnchor(anchorAddress); - anchor.setRootNodeAddress(ObjectAddress.Null); - anchor.release(); - } - if (!parentAddress.isNull()) { - IndexNode parent = acquireNode(parentAddress); - parent.removeKeyForChild(address); - parent.release(); - } - if (!nextAddress.isNull()) { - IndexNode next = acquireNode(nextAddress); - next.setPreviousAddress(previousAddress); - next.release(); - } - if (!previousAddress.isNull()) { - IndexNode previous = acquireNode(previousAddress); - previous.setNextAddress(nextAddress); - previous.release(); - } - } - - /** - * Update the key and value at this entry to a new key and value. This may result in a node split. - * The caller must be able to recognize that the node has split and compensate for that. - */ - private void updateEntry(int i, byte[] key, byte[] value) throws IndexedStoreException { - - /* - If the node needs to be split, split it and then attempt the update again. Note that if - this is a non-leaf node the value is a child address. Unlike the insert of a key/value - pair, the child is already in the node, thus a split will update its parent address properly - and there is no need to handle that special case. - */ - Field entries = entriesField; - int entriesLength = entries.length(); - int newKeyValueLength = key.length + value.length; - int oldKeyValueLength = getKeyValueField(i).length(); - int neededSpace = newKeyValueLength - oldKeyValueLength; - int freeSpace = entriesLength - ((numberOfEntries * DescriptorLength) + usedSpace); - if (freeSpace < neededSpace) { - ObjectAddress newNodeAddress = split(); - if (i >= numberOfEntries) { - IndexNode newNode = acquireNode(newNodeAddress); - newNode.updateEntry(i - getNumberOfEntries(), key, value); - newNode.release(); - } else { - updateEntry(i, key, value); - } - return; - } - - /* - The node has enough free space to do the update. - Remove the old value and key fields from the space. - Clear the space used by the old value. - We can do this just by modifying the descriptor. - */ - Field keyValueField = getKeyValueField(i); - keyValueField.clear(); - Field descriptor = getDescriptor(i); - descriptor.clear(); - usedSpace -= oldKeyValueLength; - compress(newKeyValueLength); - - /* place the value and key fields into the space */ - Pointer p = entries.pointTo(entriesLength - usedSpaceMax); - p.dec(value.length).put(value); - p.dec(key.length).put(key); - usedSpaceMax += newKeyValueLength; - usedSpace += newKeyValueLength; - - /* update the descriptor */ - descriptor.subfield(0, 2).put(entriesLength - usedSpaceMax); - descriptor.subfield(2, 2).put(key.length); - descriptor.subfield(4, 2).put(value.length); - setChanged(); - } - - /** - * Sets the key at this entry to a new key. This may result in a node split. - * The caller must be able to recognize that the node has split and compensate for that if necessary. - */ - private void updateKeyAt(int i, byte[] key) throws IndexedStoreException { - updateEntry(i, key, getValue(i)); - } - - /** - * Updates the key of an (key,address) entry in a non-leaf node. The key must still be in order with respect - * to the other keys of the node. - */ - private void updateKeyForChild(byte[] key, ObjectAddress childAddress, byte[] newKey) throws IndexedStoreException { - Field childAddressField = new Field(childAddress.toByteArray()); - int i = findLastEntryLT(key) + 1; - while (i < numberOfEntries) { - if (getValueField(i).compareTo(childAddressField) == 0) - break; - i++; - } - if (i < numberOfEntries) { - updateKeyAt(i, newKey); - if (i == 0 && !parentAddress.isNull()) { - IndexNode parent = acquireNode(parentAddress); - parent.updateKeyForChild(key, address, newKey); - parent.release(); - } - } - } - - /** - * Sets the value at this entry to a new value. This may result in a node split. - * The caller must be able to recognize that the node has split and compensate for that. - */ - void updateValueAt(int i, byte[] value) throws IndexedStoreException { - updateEntry(i, getKey(i), value); - } - - public String toString() { - StringBuffer b = new StringBuffer(); - if (isLeaf()) - b.append("LeafNode"); //$NON-NLS-1$ - if (isRoot()) - b.append("RootNode"); //$NON-NLS-1$ - if (isInterior()) - b.append("InteriorNode"); //$NON-NLS-1$ - b.append("\n Address = "); //$NON-NLS-1$ - b.append(address); - b.append("\n AnchorAddress = "); //$NON-NLS-1$ - b.append(anchorAddress); - b.append("\n ParentAddress = "); //$NON-NLS-1$ - b.append(parentAddress); - b.append("\n PreviousAddress = "); //$NON-NLS-1$ - b.append(previousAddress); - b.append("\n NextAddress = "); //$NON-NLS-1$ - b.append(nextAddress); - b.append("\n NumberOfEntries = "); //$NON-NLS-1$ - b.append(numberOfEntries); - b.append("\n UsedSpace = "); //$NON-NLS-1$ - b.append(usedSpace); - b.append("\n UsedSpaceMax = "); //$NON-NLS-1$ - b.append(usedSpaceMax); - return b.toString(); - } - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexedStore.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexedStore.java deleted file mode 100644 index f073bac51..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexedStore.java +++ /dev/null @@ -1,389 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -import java.util.*; - -public class IndexedStore { - - private static final int CurrentVersion = 1; - private static final int MetadataID = 2; - /* - * Provides the storage for the registry of stores. Key is the name the store - * was opened under. The value is the store itself. This is used to facilitate - * recovery in the event of a thread being killed or dying. - */ - private static final Map registry = Collections.synchronizedMap(new HashMap()); - - private static final ObjectAddress ContextAddress10 = new ObjectAddress(1, 0); - private static final ObjectAddress ContextAddress11 = new ObjectAddress(1, 1); - - private ObjectAddress objectDirectoryAddress; /* initialized at open */ - private Index objectDirectory; /* initialized at open */ - private IndexCursor objectDirectoryCursor; /* initialized at open */ - - private ObjectAddress indexDirectoryAddress; /* initialized at open */ - private Index indexDirectory; /* initialized at open */ - private IndexCursor indexDirectoryCursor; /* initialized at open */ - private ObjectAddress contextAddress; - - private ObjectStore objectStore; /* initialized at open */ - private String name; /* initialized at open */ - - /** - * Acquires an anchor. - */ - IndexAnchor acquireAnchor(ObjectAddress address) throws IndexedStoreException { - return (IndexAnchor) acquireObject(address); - } - - /** - * Acquires a context. Returns null if the context could not be acquired. - */ - IndexedStoreContext acquireContext(ObjectAddress address) { - try { - return (IndexedStoreContext) acquireObject(address); - } catch (IndexedStoreException e) { - //context couldn't be acquired - return null - return null; - } - } - - /** - * Acquire an index node. - */ - IndexNode acquireNode(ObjectAddress address) throws IndexedStoreException { - return (IndexNode) acquireObject(address); - } - - /** - * Acquires an object. - */ - private StoredObject acquireObject(ObjectAddress address) throws IndexedStoreException { - StoredObject object; - try { - object = objectStore.acquireObject(address); - } catch (ObjectStoreException e) { - throw new IndexedStoreException(IndexedStoreException.ObjectNotAcquired, e); - } - return object; - } - - /** - * Acquires a Binary Object. - */ - BinarySmallObject acquireBinarySmallObject(ObjectAddress address) throws IndexedStoreException { - return (BinarySmallObject) acquireObject(address); - } - - /** - * Checks to see if the metadata stored in the object store matches that expected by this - * code. If not, a conversion is necessary. - */ - private void checkMetadata() throws IndexedStoreException { - Buffer metadata = getMetadataArea(MetadataID); - Field versionField = metadata.getField(0, 4); - int version = versionField.getInt(); - if (version == 0) { - // 0 indicates that the store is new - versionField.put(CurrentVersion); - putMetadataArea(MetadataID, metadata); - return; - } - if (version == CurrentVersion) - return; - convert(version); - } - - /** - * Closes the store. This is required to free the underlying file. - */ - public synchronized void close() throws IndexedStoreException { - if (name == null) - return;//already closed - try { - commit(); - if (objectDirectoryCursor != null) - objectDirectoryCursor.close(); - if (indexDirectoryCursor != null) - indexDirectoryCursor.close(); - } catch (IndexedStoreException e) { - //make sure the file gets closed no matter what - try { - objectStore.close(); - } catch (ObjectStoreException e2) { - //ignore this and rethrow the underlying exception - } - throw e; - } - try { - objectStore.close(); - } catch (ObjectStoreException e) { - throw new IndexedStoreException(IndexedStoreException.StoreNotClosed, e); - } - registry.remove(name); - name = null; - objectDirectory = null; - objectDirectoryAddress = null; - objectDirectoryCursor = null; - indexDirectory = null; - indexDirectoryAddress = null; - indexDirectoryCursor = null; - } - - public synchronized void commit() throws IndexedStoreException { - try { - objectStore.commit(); - } catch (Exception e) { - throw new IndexedStoreException(IndexedStoreException.StoreNotCommitted, e); - } - } - - /** - * Converts the store from a previous to the current version. - * No conversions are yet defined. - */ - private void convert(int fromVersion) throws IndexedStoreException { - throw new IndexedStoreException(IndexedStoreException.StoreNotConverted); - } - - /** - * Creates and initializes an IndexedStore. - */ - public static synchronized void create(String name) throws IndexedStoreException { - ObjectStore store = new ObjectStore(new IndexedStoreObjectPolicy()); - try { - ObjectStore.create(name); - store.open(name); - ObjectAddress contextAddress = store.insertObject(new IndexedStoreContext()); - IndexedStoreContext context = (IndexedStoreContext) store.acquireObject(contextAddress); - IndexAnchor anchor = new IndexAnchor(); - ObjectAddress address = store.insertObject(anchor); - context.setIndexDirectoryAddress(address); - anchor = new IndexAnchor(); - address = store.insertObject(anchor); - context.setObjectDirectoryAddress(address); - context.release(); - store.commit(); - store.close(); - } catch (Exception e1) { - try { - store.close(); - } catch (ObjectStoreException e2) { - //real exception thrown below - } - ObjectStore.delete(name); - throw new IndexedStoreException(IndexedStoreException.StoreNotCreated, e1); - } - } - - /** - * Creates an Index with the given name. - */ - public synchronized Index createIndex(String indexName) throws IndexedStoreException { - Index index = null; - indexDirectoryCursor.find(indexName); - if (indexDirectoryCursor.keyMatches(indexName)) { - throw new IndexedStoreException(IndexedStoreException.IndexExists); - } - ObjectAddress address = insertObject(new IndexAnchor()); - indexDirectory.insert(indexName, address.toByteArray()); - index = new Index(this, address); - return index; - } - - /** - * Places a byte array into the store, return a new object identifier. - */ - public synchronized ObjectID createObject(byte[] b) throws IndexedStoreException { - ObjectAddress address = insertObject(new BinarySmallObject(b)); - ObjectID id = getNextObjectID(); - objectDirectory.insert(id.toByteArray(), address.toByteArray()); - return id; - } - - /** - * Places a String into the store. - */ - public synchronized ObjectID createObject(String s) throws IndexedStoreException { - return createObject(Convert.toUTF8(s)); - } - - /** - * Tests to see if the file acting as the store exists. - */ - public static synchronized boolean exists(String filename) { - return ObjectStore.exists(filename); - } - - /** - * If a store disappears unexpectedly, make sure it gets closed. - */ - protected void finalize() { - try { - close(); - } catch (Exception e) { - //unsafe to throw exceptions from a finalize - } - } - - /** - * Finds the handle of an open store for a given its name. The store may continue with the current transaction, - * or may abort the current transaction. Used to initiate recovery if the reference to the store should be - * lost for some reason. Will return null if the store has not been opened. The name of the store to be found - * must compare equal to the name the store was opened under. - */ - public synchronized static IndexedStore find(String name) { - return (IndexedStore) registry.get(name); - } - - /** - * Returns an index given its name. - */ - public synchronized Index getIndex(String indexName) throws IndexedStoreException { - Index index; - byte[] key = Convert.toUTF8(indexName); - indexDirectoryCursor.find(key); - if (!indexDirectoryCursor.keyMatches(key)) - throw new IndexedStoreException(IndexedStoreException.IndexNotFound); - ObjectAddress address = indexDirectoryCursor.getValueAsObjectAddress(); - index = new Index(this, address); - return index; - } - - private Buffer getMetadataArea(int i) throws IndexedStoreException { - try { - return objectStore.getMetadataArea(i); - } catch (ObjectStoreException e) { - throw new IndexedStoreException(IndexedStoreException.MetadataRequestError, e); - } - } - - /** - * Returns the next ObjectID - */ - private ObjectID getNextObjectID() throws IndexedStoreException { - IndexedStoreContext context = acquireContext(contextAddress); - if (context == null) - throw new IndexedStoreException(IndexedStoreException.ContextNotAvailable); - long objectNumber = context.getNextObjectNumber(); - context.release(); - return new ObjectID(objectNumber); - } - - /** - * Returns a byte array given its object identifier. - */ - public synchronized byte[] getObject(ObjectID id) throws IndexedStoreException { - objectDirectoryCursor.find(id.toByteArray()); - ObjectAddress address = objectDirectoryCursor.getValueAsObjectAddress(); - BinarySmallObject object = acquireBinarySmallObject(address); - byte[] b = object.getValue(); - object.release(); - return b; - } - - /** - * Returns an object as a string, truncated at the first null. - */ - public synchronized String getObjectAsString(ObjectID id) throws IndexedStoreException { - String s; - s = Convert.fromUTF8(getObject(id)); - int i = s.indexOf(0); - if (i == -1) - return s; - return s.substring(0, i); - } - - /** - * Inserts a new object into my store. - */ - ObjectAddress insertObject(StoredObject object) throws IndexedStoreException { - try { - ObjectAddress address = objectStore.insertObject(object); - return address; - } catch (ObjectStoreException e) { - throw new IndexedStoreException(IndexedStoreException.ObjectNotStored, e); - } - } - - /** - * Opens the store. - */ - public synchronized void open(String name) throws IndexedStoreException { - if (registry.get(name) != null) { - throw new IndexedStoreException(IndexedStoreException.StoreIsOpen); - } - if (!exists(name)) - create(name); - try { - objectStore = new ObjectStore(new IndexedStoreObjectPolicy()); - objectStore.open(name); - // setting the name signals the indexed store as open - this.name = name; - checkMetadata(); - contextAddress = ContextAddress10; - IndexedStoreContext context = acquireContext(contextAddress); - if (context == null) { - contextAddress = ContextAddress11; - context = acquireContext(contextAddress); - } - if (context == null) { - throw new IndexedStoreException(IndexedStoreException.StoreFormatError); - } - indexDirectoryAddress = context.getIndexDirectoryAddress(); - objectDirectoryAddress = context.getObjectDirectoryAddress(); - context.release(); - indexDirectory = new Index(this, indexDirectoryAddress); - indexDirectoryCursor = indexDirectory.open(); - objectDirectory = new Index(this, objectDirectoryAddress); - objectDirectoryCursor = objectDirectory.open(); - registry.put(name, this); - } catch (IndexedStoreException e) { - throw e; - } catch (Exception e) { - throw new IndexedStoreException(IndexedStoreException.GenericError, e); - } - } - - private void putMetadataArea(int i, Buffer b) throws IndexedStoreException { - try { - objectStore.putMetadataArea(i, b); - } catch (ObjectStoreException e) { - throw new IndexedStoreException(IndexedStoreException.MetadataRequestError, e); - } - } - - /** - * Removes an object from my store. - */ - void removeObject(ObjectAddress address) throws IndexedStoreException { - try { - objectStore.removeObject(address); - } catch (ObjectStoreException e) { - throw new IndexedStoreException(IndexedStoreException.ObjectNotRemoved, e); - } - } - - /** - * Removes the object identified by id from the store. - */ - public synchronized void removeObject(ObjectID id) throws IndexedStoreException { - byte[] key = id.toByteArray(); - objectDirectoryCursor.find(key); - if (!objectDirectoryCursor.keyMatches(key)) { - throw new IndexedStoreException(IndexedStoreException.ObjectNotFound); - } - ObjectAddress address = objectDirectoryCursor.getValueAsObjectAddress(); - objectDirectoryCursor.remove(); - removeObject(address); - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexedStoreContext.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexedStoreContext.java deleted file mode 100644 index 1f887dccd..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexedStoreContext.java +++ /dev/null @@ -1,173 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -class IndexedStoreContext extends IndexedStoreObject { - - public static final int SIZE = 32; - public static final int TYPE = 2; - - /* - The open number field is no longer used to generate object ids, but may not be deleted since a non-zero - open number indicates that the object number field has not been initialized. - */ - private static final int OpenNumberOffset = 2; - private static final int OpenNumberLength = 4; - private Field openNumberField; - private int openNumber; - - private static final int ObjectDirectoryAddressOffset = 6; - private static final int ObjectDirectoryAddressLength = 4; - private Field objectDirectoryAddressField; - private ObjectAddress objectDirectoryAddress; - - private static final int IndexDirectoryAddressOffset = 10; - private static final int IndexDirectoryAddressLength = 4; - private Field indexDirectoryAddressField; - private ObjectAddress indexDirectoryAddress; - - private static final int ObjectNumberOffset = 14; - private static final int ObjectNumberLength = 8; - private Field objectNumberField; - private long objectNumber; - - /** - * Constructs a new context. - */ - IndexedStoreContext() { - super(); - indexDirectoryAddress = ObjectAddress.Null; - objectDirectoryAddress = ObjectAddress.Null; - openNumber = 0; - objectNumber = 0; - } - - /** - * Constructs a context from a field read from the store. - */ - IndexedStoreContext(Field f, ObjectStore store, ObjectAddress address) throws ObjectStoreException { - super(f, store, address); - } - - /** - * Sets the fields definitions as subfields of a contents field. - */ - protected void setFields(Field contents) { - openNumberField = contents.subfield(OpenNumberOffset, OpenNumberLength); - objectDirectoryAddressField = contents.subfield(ObjectDirectoryAddressOffset, ObjectDirectoryAddressLength); - indexDirectoryAddressField = contents.subfield(IndexDirectoryAddressOffset, IndexDirectoryAddressLength); - objectNumberField = contents.subfield(ObjectNumberOffset, ObjectNumberLength); - } - - /** - * Places the contents of the buffer into the fields. - * Subclasses should implement and call super. - */ - protected void extractValues(Field contents) throws ObjectStoreException { - super.extractValues(contents); - setFields(contents); - openNumber = openNumberField.getInt(); - objectDirectoryAddress = new ObjectAddress(objectDirectoryAddressField.get()); - indexDirectoryAddress = new ObjectAddress(indexDirectoryAddressField.get()); - objectNumber = objectNumberField.getLong(); - /* here is where we transition to using object numbers -- upward compatible change */ - if (openNumber > 0) { - objectNumber = (long) openNumber << 32; - openNumber = 0; - setChanged(); - } - } - - /** - * Places the contents of the fields into the buffer. - * Subclasses should implement and call super. - */ - protected void insertValues(Field contents) { - super.insertValues(contents); - setFields(contents); - openNumberField.put(openNumber); - objectDirectoryAddressField.put(objectDirectoryAddress); - indexDirectoryAddressField.put(indexDirectoryAddress); - objectNumberField.put(objectNumber); - } - - /** - * Returns the index directory address from the buffer. - */ - ObjectAddress getIndexDirectoryAddress() { - return indexDirectoryAddress; - } - - /** - * Returns the minimum size of this object's instance -- including its type field. - * Subclasses should override. - */ - protected int getMinimumSize() { - return SIZE; - } - - /** - * Returns the object directory address from the buffer. - */ - ObjectAddress getObjectDirectoryAddress() { - return objectDirectoryAddress; - } - - /** - * Returns the required type of this class of object. - * Subclasses must override. - */ - protected int getRequiredType() { - return TYPE; - } - - /** - * Generates and returns the next object number. This is essentially the - * count of the number of user-defined objects generated in this store. - */ - long getNextObjectNumber() { - objectNumber++; - setChanged(); - return objectNumber; - } - - /** - * Sets the index directory address. - */ - void setIndexDirectoryAddress(ObjectAddress address) { - this.indexDirectoryAddress = address; - setChanged(); - } - - /** - * Sets the object directory address. - */ - void setObjectDirectoryAddress(ObjectAddress address) { - this.objectDirectoryAddress = address; - setChanged(); - } - - /** - * Provides a printable representation of this object. - */ - public String toString() { - StringBuffer b = new StringBuffer(); - b.append("Context("); //$NON-NLS-1$ - b.append(objectNumber); - b.append(","); //$NON-NLS-1$ - b.append(indexDirectoryAddress); - b.append(","); //$NON-NLS-1$ - b.append(objectDirectoryAddress); - b.append(")"); //$NON-NLS-1$ - return b.toString(); - } - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexedStoreException.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexedStoreException.java deleted file mode 100644 index acab8e425..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexedStoreException.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -import org.eclipse.core.internal.resources.CompatibilityMessages; - - -public class IndexedStoreException extends StoreException { - - public static final int GenericError = 0; - public static final int EntryKeyLengthError = 1; - public static final int EntryNotRemoved = 2; - public static final int EntryValueLengthError = 3; - public static final int EntryValueNotUpdated = 4; - public static final int IndexNodeNotRetrieved = 5; - public static final int IndexNodeNotStored = 6; - public static final int IndexNodeNotSplit = 7; - public static final int IndexNodeNotCreated = 8; - public static final int IndexExists = 9; - public static final int IndexNotCreated = 10; - public static final int IndexNotFound = 11; - public static final int IndexNotRemoved = 12; - public static final int ObjectExists = 13; - public static final int ObjectNotAcquired = 14; - public static final int ObjectNotCreated = 15; - public static final int ObjectNotFound = 16; - public static final int ObjectNotReleased = 17; - public static final int ObjectNotRemoved = 18; - public static final int ObjectNotUpdated = 19; - public static final int ObjectNotStored = 20; - public static final int ObjectTypeError = 21; - public static final int StoreEmpty = 22; - public static final int StoreFormatError = 23; - public static final int StoreNotCreated = 24; - public static final int StoreNotOpen = 25; - public static final int StoreNotClosed = 26; - public static final int StoreNotFlushed = 27; - public static final int StoreNotOpened = 28; - public static final int StoreNotReadWrite = 29; - public static final int ContextNotAvailable = 30; - public static final int ObjectIDInvalid = 31; - public static final int MetadataRequestError = 32; - public static final int EntryRemoved = 33; - public static final int StoreNotConverted = 34; - public static final int StoreIsOpen = 35; - public static final int StoreNotCommitted = 36; - public static final int StoreNotRolledBack = 37; - - public static String[] messages = new String[40]; - - /** - * All serializable objects should have a stable serialVersionUID - */ - private static final long serialVersionUID = 1L; - - static { - initializeMessages(); - } - - public int id = GenericError; - - /** - * IndexedStoreException constructor comment. - */ - public IndexedStoreException(int id) { - super(messages[id]); - this.id = id; - } - - /** - * IndexedStoreException constructor comment. - */ - public IndexedStoreException(int id, Throwable e) { - super(messages[id], e); - this.id = id; - } - - /** - * Initializes the messages at class load time. - */ - private static void initializeMessages() { - messages[GenericError] = CompatibilityMessages.indexedStore_genericError; - messages[EntryKeyLengthError] = CompatibilityMessages.indexedStore_entryKeyLengthError; - messages[EntryNotRemoved] = CompatibilityMessages.indexedStore_entryNotRemoved; - messages[EntryValueLengthError] = CompatibilityMessages.indexedStore_entryValueLengthError; - messages[EntryValueNotUpdated] = CompatibilityMessages.indexedStore_entryValueNotUpdated; - messages[IndexNodeNotRetrieved] = CompatibilityMessages.indexedStore_indexNodeNotRetrieved; - messages[IndexNodeNotStored] = CompatibilityMessages.indexedStore_indexNodeNotStored; - messages[IndexNodeNotSplit] = CompatibilityMessages.indexedStore_indexNodeNotSplit; - messages[IndexNodeNotCreated] = CompatibilityMessages.indexedStore_indexNodeNotCreated; - messages[IndexExists] = CompatibilityMessages.indexedStore_indexExists; - messages[IndexNotCreated] = CompatibilityMessages.indexedStore_indexNotCreated; - messages[IndexNotFound] = CompatibilityMessages.indexedStore_indexNotFound; - messages[IndexNotRemoved] = CompatibilityMessages.indexedStore_indexNotRemoved; - messages[ObjectExists] = CompatibilityMessages.indexedStore_objectExists; - messages[ObjectNotAcquired] = CompatibilityMessages.indexedStore_objectNotAcquired; - messages[ObjectNotCreated] = CompatibilityMessages.indexedStore_objectNotCreated; - messages[ObjectNotFound] = CompatibilityMessages.indexedStore_objectNotFound; - messages[ObjectNotReleased] = CompatibilityMessages.indexedStore_objectNotReleased; - messages[ObjectNotRemoved] = CompatibilityMessages.indexedStore_objectNotRemoved; - messages[ObjectNotUpdated] = CompatibilityMessages.indexedStore_objectNotUpdated; - messages[ObjectNotStored] = CompatibilityMessages.indexedStore_objectNotStored; - messages[ObjectTypeError] = CompatibilityMessages.indexedStore_objectTypeError; - messages[StoreEmpty] = CompatibilityMessages.indexedStore_storeEmpty; - messages[StoreFormatError] = CompatibilityMessages.indexedStore_storeFormatError; - messages[StoreNotCreated] = CompatibilityMessages.indexedStore_storeNotCreated; - messages[StoreNotOpen] = CompatibilityMessages.indexedStore_storeNotOpen; - messages[StoreNotClosed] = CompatibilityMessages.indexedStore_storeNotClosed; - messages[StoreNotFlushed] = CompatibilityMessages.indexedStore_storeNotFlushed; - messages[StoreNotOpened] = CompatibilityMessages.indexedStore_storeNotOpened; - messages[StoreNotReadWrite] = CompatibilityMessages.indexedStore_storeNotReadWrite; - messages[ContextNotAvailable] = CompatibilityMessages.indexedStore_contextNotAvailable; - messages[ObjectIDInvalid] = CompatibilityMessages.indexedStore_objectIDInvalid; - messages[MetadataRequestError] = CompatibilityMessages.indexedStore_metadataRequestError; - messages[EntryRemoved] = CompatibilityMessages.indexedStore_entryRemoved; - messages[StoreNotConverted] = CompatibilityMessages.indexedStore_storeNotConverted; - messages[StoreIsOpen] = CompatibilityMessages.indexedStore_storeIsOpen; - messages[StoreNotCommitted] = CompatibilityMessages.indexedStore_storeNotCommitted; - messages[StoreNotRolledBack] = CompatibilityMessages.indexedStore_storeNotRolledBack; - } - - /** - * Creates a printable representation of this exception. - */ - public String toString() { - StringBuffer buffer = new StringBuffer(50); - buffer.append("IndexedStoreException:"); //$NON-NLS-1$ - buffer.append(getMessage()); - if (wrappedException != null) { - buffer.append("\n"); //$NON-NLS-1$ - buffer.append(wrappedException.toString()); - } - return buffer.toString(); - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexedStoreObject.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexedStoreObject.java deleted file mode 100644 index fd36623a9..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexedStoreObject.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -abstract class IndexedStoreObject extends StoredObject { - - public IndexedStoreObject() { - super(); - } - - /** - * Constructs an object from bytes that came from the store. - * These bytes include the 2 byte type field. - */ - public IndexedStoreObject(Field f, ObjectStore store, ObjectAddress address) throws ObjectStoreException { - super(f, store, address); - } - - /** - * Acquires an anchor. - */ - protected final IndexAnchor acquireAnchor(ObjectAddress address) throws IndexedStoreException { - return (IndexAnchor) acquireObject(address); - } - - /** - * Acquires a node. - */ - protected final IndexNode acquireNode(ObjectAddress address) throws IndexedStoreException { - return (IndexNode) acquireObject(address); - } - - /** - * Acquires an object. - */ - protected final StoredObject acquireObject(ObjectAddress address) throws IndexedStoreException { - StoredObject object; - try { - object = store.acquireObject(address); - } catch (ObjectStoreException e) { - throw new IndexedStoreException(IndexedStoreException.ObjectNotAcquired, e); - } - return object; - } - - /** - * Inserts a new object into my store. Subclasses must not override. - */ - protected final ObjectAddress insertObject(StoredObject object) throws IndexedStoreException { - try { - ObjectAddress address = store.insertObject(object); - return address; - } catch (ObjectStoreException e) { - throw new IndexedStoreException(IndexedStoreException.ObjectNotStored, e); - } - } - - /** - * Releases this object. Subclasses must not override. - */ - protected final void release() throws IndexedStoreException { - try { - store.releaseObject(this); - } catch (ObjectStoreException e) { - throw new IndexedStoreException(IndexedStoreException.ObjectNotReleased, e); - } - } - - /** - * Removes an object from my store. Subclasses must not override. - */ - protected final void removeObject(ObjectAddress address) throws IndexedStoreException { - try { - store.removeObject(address); - } catch (ObjectStoreException e) { - throw new IndexedStoreException(IndexedStoreException.ObjectNotRemoved, e); - } - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexedStoreObjectPolicy.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexedStoreObjectPolicy.java deleted file mode 100644 index 88419e23a..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/IndexedStoreObjectPolicy.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -public class IndexedStoreObjectPolicy extends AbstractObjectPolicy { - - /** - * Default constructor - */ - public IndexedStoreObjectPolicy() { - super(); - } - - /** - * Creates an IndexedStoreObject from a field. The contents of the field are - * used to create the internal structure of the object. The field begins with a - * two byte type code that is used to determine the type of object to create. - */ - public StoredObject createObject(Field field, ObjectStore store, ObjectAddress address) throws ObjectStoreException { - int offset = StoredObject.TYPE_OFFSET; - int length = StoredObject.TYPE_LENGTH; - int type = field.subfield(offset, length).getInt(); - StoredObject object = null; - switch (type) { - case IndexAnchor.TYPE : - object = new IndexAnchor(field, store, address); - break; - case IndexNode.TYPE : - object = new IndexNode(field, store, address); - break; - case IndexedStoreContext.TYPE : - object = new IndexedStoreContext(field, store, address); - break; - case BinarySmallObject.TYPE : - object = new BinarySmallObject(field, store, address); - break; - default : - throw new ObjectStoreException(ObjectStoreException.ObjectTypeFailure); - } - return object; - } - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Insertable.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Insertable.java deleted file mode 100644 index cfd0491df..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Insertable.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -public interface Insertable { - - /** - *Creates a byte array from this object. - */ - byte[] toByteArray(); -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Log.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Log.java deleted file mode 100644 index 1be3cc325..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Log.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -import java.io.*; - -class Log { - - /** - * Deletes the transaction log from the file system. - */ - static void delete(String storeName) { - new File(name(storeName)).delete(); - } - - /** - * Returns true iff the transaction log exists in the file system. - */ - static boolean exists(String storeName) { - return new File(name(storeName)).exists(); - } - - /** - * Returns the name of the log file, given the store name. - */ - static String name(String storeName) { - return storeName + ".log"; //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/LogReader.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/LogReader.java deleted file mode 100644 index 0f6f54da9..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/LogReader.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Map; -import java.util.TreeMap; - -class LogReader { - - protected FileInputStream in; - protected PageStore store; - protected byte[] b4; - protected byte[] pageBuffer; - - /** - * Returns the Hashmap of the modified pages. - */ - public static Map getModifiedPages(PageStore store) throws PageStoreException { - LogReader reader = new LogReader(store); - Map modifiedPages = null; - try { - reader.open(store); - modifiedPages = reader.getModifiedPages(); - } finally { - reader.close(); - } - return modifiedPages; - } - - public LogReader(PageStore store) { - this.store = store; - this.pageBuffer = new byte[Page.SIZE]; - this.b4 = new byte[4]; - } - - /** - * Open a log for reading. - */ - protected void open(PageStore pageStore) throws PageStoreException { - String name = pageStore.getName(); - if (!Log.exists(name)) - return; - try { - in = new FileInputStream(Log.name(name)); - } catch (IOException e) { - throw new PageStoreException(PageStoreException.LogOpenFailure, e); - } - } - - /** - * Closes the log. - */ - protected void close() { - try { - if (in != null) - in.close(); - } catch (IOException e) { - // ignore - } - in = null; - } - - /** - * Returns the Hashmap of modified pages read from the log. - */ - protected Map getModifiedPages() throws PageStoreException { - Map modifiedPages = new TreeMap(); - if (in == null) - return modifiedPages; - Field f4 = new Field(b4); - readBuffer(b4); - int numberOfPages = f4.getInt(); - int recordSize = 4 + Page.SIZE; - if (bytesAvailable() != (numberOfPages * recordSize)) - return modifiedPages; - for (int i = 0; i < numberOfPages; i++) { - readBuffer(b4); - readBuffer(pageBuffer); - int pageNumber = f4.getInt(); - Page page = store.getPolicy().createPage(pageNumber, pageBuffer, store); - Integer key = new Integer(pageNumber); - modifiedPages.put(key, page); - } - return modifiedPages; - } - - public void readBuffer(byte[] buffer) throws PageStoreException { - try { - in.read(buffer); - } catch (IOException e) { - throw new PageStoreException(PageStoreException.LogReadFailure, e); - } - } - - protected int bytesAvailable() throws PageStoreException { - try { - return in.available(); - } catch (IOException e) { - throw new PageStoreException(PageStoreException.LogReadFailure, e); - } - } - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/LogWriter.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/LogWriter.java deleted file mode 100644 index d1fb243bb..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/LogWriter.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Iterator; -import java.util.Map; - -class LogWriter { - - protected FileOutputStream out; - protected PageStore pageStore; - - /** - * Puts the modified pages to the log file. - */ - public static void putModifiedPages(PageStore pageStore, Map modifiedPages) throws PageStoreException { - LogWriter writer = new LogWriter(); - try { - writer.open(pageStore); - writer.putModifiedPages(modifiedPages); - } finally { - writer.close(); - } - } - - /** - * Opens the log. - */ - protected void open(PageStore store) throws PageStoreException { - this.pageStore = store; - try { - out = new FileOutputStream(Log.name(store.getName())); - } catch (IOException e) { - throw new PageStoreException(PageStoreException.LogOpenFailure, e); - } - } - - /** - * Closes the log. - */ - protected void close() { - try { - if (out != null) - out.close(); - } catch (IOException e) { - // ignore - } - out = null; - } - - /** - * Puts the modified pages into the log. - */ - protected void putModifiedPages(Map modifiedPages) throws PageStoreException { - Buffer b4 = new Buffer(4); - byte[] pageBuffer = new byte[Page.SIZE]; - int numberOfPages = modifiedPages.size(); - b4.put(0, 4, numberOfPages); - try { - write(b4.getByteArray()); - Iterator pageStream = modifiedPages.values().iterator(); - while (pageStream.hasNext()) { - Page page = (Page) pageStream.next(); - int pageNumber = page.getPageNumber(); - b4.put(0, 4, pageNumber); - write(b4.getByteArray()); - page.toBuffer(pageBuffer); - write(pageBuffer); - } - } catch (IOException e) { - throw new PageStoreException(PageStoreException.LogWriteFailure, e); - } - } - - public void write(byte[] buffer) throws IOException { - out.write(buffer); - } - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectAddress.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectAddress.java deleted file mode 100644 index e6b42ec39..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectAddress.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -public class ObjectAddress implements Insertable { - - public static final int Size = 4; - public static ObjectAddress Null = new ObjectAddress(0, 0); - private static final int PageNumberOffset = 0; - private static final int ObjectNumberOffset = 3; - private int pageNumber; - private int objectNumber; - - /** - * Constructor for an address from a four byte field. - */ - public ObjectAddress(byte[] b) throws IllegalArgumentException { - if (b.length != Size) - throw new IllegalArgumentException(); - Buffer buf = new Buffer(b); - pageNumber = buf.getUInt(PageNumberOffset, 3); - objectNumber = buf.getUInt(ObjectNumberOffset, 1); - } - - /** - * Constructs an address from its constituent page and object numbers. - */ - public ObjectAddress(int pageNumber, int objectNumber) throws IllegalArgumentException { - if (pageNumber == 0 && objectNumber == 0) { - this.pageNumber = 0; - this.objectNumber = 0; - return; - } - if (pageNumber < 0 || pageNumber > 0xFFFFFF) - throw new IllegalArgumentException(); - if (pageNumber % ObjectStorePage.SIZE == 0) - throw new IllegalArgumentException(); - if (objectNumber < 0 || objectNumber > 0xFF) - throw new IllegalArgumentException(); - this.pageNumber = pageNumber; - this.objectNumber = objectNumber; - } - - /** - * Returns true if and only if the addresses are equal. - */ - public boolean equals(Object anObject) { - if (!(anObject instanceof ObjectAddress)) - return false; - ObjectAddress address = (ObjectAddress) anObject; - if (pageNumber != address.pageNumber) - return false; - if (objectNumber != address.objectNumber) - return false; - return true; - } - - /** - * Returns the object number from the address. - */ - public int getObjectNumber() { - return objectNumber; - } - - /** - * Returns the page number from the address. - */ - public int getPageNumber() { - return pageNumber; - } - - /** - * Returns an int representing the hash code for the address. - */ - public int hashCode() { - return (pageNumber << 8) | objectNumber; - } - - /** - * Tests the address for the null address value. - */ - public boolean isNull() { - return (pageNumber == 0 && objectNumber == 0); - } - - /** - * Returns a byte array form of the address. - */ - public byte[] toByteArray() { - Buffer buf = new Buffer(Size); - buf.put(PageNumberOffset, 3, pageNumber); - buf.put(ObjectNumberOffset, 1, objectNumber); - return buf.get(); - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectHeader.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectHeader.java deleted file mode 100644 index 1167a9e9c..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectHeader.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -class ObjectHeader implements Insertable { - - public static final int SIZE = 4; - private static final int HeaderTagValue = 0xFFFF; - private static final int HeaderTagOffset = 0; - private static final int ObjectLengthOffset = 2; - private int objectLength; - - /** - * ObjectHeader constructor comment. - */ - public ObjectHeader(byte[] buffer) throws ObjectStoreException { - if (buffer.length != SIZE) - throw new IllegalArgumentException(); - Buffer buf = new Buffer(buffer); - if (buf.getUInt(HeaderTagOffset, 2) != HeaderTagValue) { - throw new ObjectStoreException(ObjectStoreException.ObjectHeaderFailure); - } - this.objectLength = buf.getUInt(ObjectLengthOffset, 2); - } - - /** - * ObjectHeader constructor comment. - */ - public ObjectHeader(int objectLength) { - this.objectLength = objectLength; - } - - public int getObjectLength() { - return objectLength; - } - - public byte[] toByteArray() { - Buffer buf = new Buffer(SIZE); - buf.put(HeaderTagOffset, 2, HeaderTagValue); - buf.put(ObjectLengthOffset, 2, objectLength); - return buf.get(); - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectID.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectID.java deleted file mode 100644 index 18bcc18f6..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectID.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -public class ObjectID implements Insertable { - - private static final int Size = 8; - private static final int ObjectNumberOffset = 0; - private long objectNumber; - - public ObjectID(byte[] b) throws IndexedStoreException { - if (b.length != Size) { - throw new IndexedStoreException(IndexedStoreException.ObjectIDInvalid); - } - Buffer buf = new Buffer(b); - objectNumber = buf.getLong(ObjectNumberOffset, 8); - } - - public ObjectID(long objectNumber) { - this.objectNumber = objectNumber; - } - - public boolean equals(Object anObject) { - if (!(anObject instanceof ObjectID)) - return false; - ObjectID id = (ObjectID) anObject; - if (this.objectNumber != id.objectNumber) - return false; - return true; - } - - public int hashCode() { - return (int) objectNumber; - } - - public byte[] toByteArray() { - Buffer buf = new Buffer(Size); - buf.put(ObjectNumberOffset, 8, objectNumber); - return buf.get(); - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectPage.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectPage.java deleted file mode 100644 index c70332c83..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectPage.java +++ /dev/null @@ -1,264 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -/** - An ObjectPage is a page in a page file that contains objects. Objects are byte arrays. - An object page contains metainformation about the objects located on that page as well - as information about the state of the page. This information is updated as the page - has objects placed on it or removed from it. Objects within a page are identified by - their object number, which is in the range of 1-255 inclusive. - - All pages are numbered. Space map pages are located at page numbers i*(Page.Size) in - the page file. Object pages are located at all page numbers between space map pages. - Thus object pages will never have page numbers that are multiples of the page size. - */ - -class ObjectPage extends ObjectStorePage { - - protected static final int MaxEntries = 256; - protected static final int ObjectDirectoryOffset = 64; - protected static final int ObjectSpaceOffset = ObjectDirectoryOffset + 512; - protected static final int FlagOffset = 0; - protected static final int UsedSpaceOffset = 2; - protected static final int UsedEntriesOffset = 4; - protected static final int InitialEntryOffset = 6; - protected static final int FreeSpaceOffset = 8; - - public static final int ObjectSpaceSize = SIZE - ObjectSpaceOffset; - - protected int usedSpace; - protected int usedEntries; - protected int freeSpaceOffset; - protected int initialEntry; - - /** - * Creates a new page from a buffer. - */ - public ObjectPage(int pageNumber, byte[] buffer, PageStore pageStore) { - super(pageNumber, buffer, pageStore); - } - - /** - * Writes the contents of the page to a buffer. - */ - public void toBuffer(byte[] buffer) { - dematerialize(); - pageBuffer.copyTo(buffer); - } - - /** - * Updates the page fields from its bytes. This is used when the page has just been mutated from - * a its superclass. - */ - - protected void materialize() { - int initialized = pageBuffer.getUInt(FlagOffset, 2); - if (initialized == 0xEEEE) { - usedSpace = pageBuffer.getUInt(UsedSpaceOffset, 2); - usedEntries = pageBuffer.getUInt(UsedEntriesOffset, 2); - initialEntry = pageBuffer.getUInt(InitialEntryOffset, 2); - freeSpaceOffset = pageBuffer.getUInt(FreeSpaceOffset, 2); - } else { - usedSpace = 0; - usedEntries = 0; - initialEntry = 0; - freeSpaceOffset = ObjectSpaceOffset; - } - } - - /** - * Writes the object page header and from the header instance variables. This is used just before - * the page is to be written to the page store. - */ - protected void dematerialize() { - pageBuffer.put(FlagOffset, 2, 0xEEEE); - pageBuffer.put(UsedSpaceOffset, 2, usedSpace); - pageBuffer.put(UsedEntriesOffset, 2, usedEntries); - pageBuffer.put(InitialEntryOffset, 2, initialEntry); - pageBuffer.put(FreeSpaceOffset, 2, freeSpaceOffset); - } - - /** - * This method returns the Field mapped over the object for a given object number. - */ - public Field getObjectField(int objectNumber) throws ObjectStoreException { - int entryOffset = ObjectDirectoryOffset + 2 * objectNumber; - int blockOffset = pageBuffer.getUInt(entryOffset, 2); - if (blockOffset == 0) - return null; - ObjectHeader header = new ObjectHeader(pageBuffer.get(blockOffset, ObjectHeader.SIZE)); - Field f = pageBuffer.getField(blockOffset + ObjectHeader.SIZE, header.getObjectLength()); - return f; - } - - /** - * Places an object into a page. The object must have a reservation. - */ - public void insertObject(StoredObject object) throws ObjectStoreException { - - // ensure that there is space for this object - int blockLength = object.length() + ObjectHeader.SIZE; - if (getFreeSpace() < blockLength) { - throw new ObjectStoreException(ObjectStoreException.ObjectSizeFailure); - } - - // make sure the slot is still empty - int objectNumber = object.getAddress().getObjectNumber(); - int entryOffset = ObjectDirectoryOffset + (objectNumber * 2); - int blockOffset = pageBuffer.getUInt(entryOffset, 2); - if (blockOffset != 0) { - throw new ObjectStoreException(ObjectStoreException.PageVacancyFailure); - } - - // place the object into the object space portion of the page - if (blockLength > (SIZE - freeSpaceOffset)) - compress(); // compress the space if necessary - blockOffset = freeSpaceOffset; // place the object at the beginning of the free space - ObjectHeader header = new ObjectHeader(object.length()); - pageBuffer.put(blockOffset, header); - pageBuffer.put(blockOffset + ObjectHeader.SIZE, object.toByteArray()); - pageBuffer.put(entryOffset, 2, blockOffset); - freeSpaceOffset += blockLength; // update where the new free space is - usedSpace += blockLength; // indicate that space is used up - usedEntries++; // indicate that an entry is used up - initialEntry = (objectNumber + 1) % MaxEntries; // set where to begin the next search - setChanged(); - notifyObservers(); - } - - /** - * Reserves space for an object on the page. Records the reservation in the - * reservation table. - */ - public int reserveObject(StoredObject object, ReservationTable reservations) throws ObjectStoreException { - - // ensure that there is space for this object, there should be since we check beforehand - int blockLength = object.length() + ObjectHeader.SIZE; - if (getFreeSpace() < blockLength) { - throw new ObjectStoreException(ObjectStoreException.ObjectSizeFailure); - } - - // get the reservation for this page from the table, create a new one if necessary - Reservation r = reservations.get(pageNumber); - if (r == null) { - r = new Reservation(getFreeSpace(), MaxEntries - usedEntries, initialEntry); - reservations.put(pageNumber, r); - } - - // find an empty slot that is not already reserved - int objectNumber = r.getInitialEntry(); - int blockOffset = 0; - int entryOffset = 0; - for (int i = 0; i < MaxEntries; i++) { - if (!r.contains(objectNumber)) { - entryOffset = ObjectDirectoryOffset + (objectNumber * 2); - blockOffset = pageBuffer.getUInt(entryOffset, 2); - if (blockOffset == 0) - break; - } - objectNumber = (objectNumber + 1) % MaxEntries; - } - if (blockOffset != 0) { - throw new ObjectStoreException(ObjectStoreException.PageVacancyFailure); - } - - // begin the next search just after where we left off - r.setInitialEntry((objectNumber + 1) % MaxEntries); - - // update the reservation for this page - r.add(objectNumber, blockLength); - return objectNumber; - } - - public void removeObject(int objectNumber) throws ObjectStoreException { - - /* check for existence of the object to be removed */ - int entryOffset = ObjectDirectoryOffset + 2 * objectNumber; - int blockOffset = pageBuffer.getUInt(entryOffset, 2); - if (blockOffset == 0) - throw new ObjectStoreException(ObjectStoreException.ObjectExistenceFailure); - - /* remove the object */ - pageBuffer.put(entryOffset, 2, 0); // remove its offset from the object table - ObjectHeader h = new ObjectHeader(pageBuffer.get(blockOffset, ObjectHeader.SIZE)); - int objectLength = h.getObjectLength(); - int blockLength = objectLength + ObjectHeader.SIZE; // find the length of it in the object space - pageBuffer.clear(blockOffset, blockLength); // clear its spot in the object space - usedSpace -= blockLength; // space has been freed - usedEntries--; // an entry has been freed; - setChanged(); - notifyObservers(); - } - - /** - * Updates an object value on the page. An object may not change its size. - */ - public void updateObject(StoredObject object) throws ObjectStoreException { - - int objectNumber = object.getAddress().getObjectNumber(); - - /* check for existence of the object to be updated */ - int entryOffset = ObjectDirectoryOffset + 2 * objectNumber; - int blockOffset = pageBuffer.getUInt(entryOffset, 2); - if (blockOffset == 0) { - throw new ObjectStoreException(ObjectStoreException.ObjectExistenceFailure); - } - - /* retrieve the header and check the size */ - ObjectHeader header = new ObjectHeader(pageBuffer.get(blockOffset, ObjectHeader.SIZE)); - if (header.getObjectLength() != object.length()) { - throw new ObjectStoreException(ObjectStoreException.ObjectSizeFailure); - } - - /* update in place */ - int objectOffset = blockOffset + ObjectHeader.SIZE; - pageBuffer.put(objectOffset, object.toByteArray()); - setChanged(); - notifyObservers(); - } - - /** - * Compresses the space in the page, putting all the free space at the end of the page. - * This will adjust the free space offset and the offsets of the individual objects. All - * of the other parameters of the page remain the same. Resets the number of - * used entries to fix an old bug. - */ - private void compress() throws ObjectStoreException { - Buffer temp = new Buffer(SIZE); - int newBlockOffset = ObjectSpaceOffset; - int entryOffset = ObjectDirectoryOffset; - usedEntries = 0; - for (int i = 0; i < MaxEntries; i++) { - int oldBlockOffset = pageBuffer.getUInt(entryOffset, 2); - if (oldBlockOffset > 0) { - ObjectHeader h = new ObjectHeader(pageBuffer.get(oldBlockOffset, ObjectHeader.SIZE)); - int blockLength = h.getObjectLength() + ObjectHeader.SIZE; - temp.put(newBlockOffset, pageBuffer.get(oldBlockOffset, blockLength)); - pageBuffer.put(entryOffset, 2, newBlockOffset); - newBlockOffset += blockLength; - usedEntries++; - } - entryOffset += 2; - } - pageBuffer.put(ObjectSpaceOffset, temp.get(ObjectSpaceOffset, SIZE - ObjectSpaceOffset)); - freeSpaceOffset = newBlockOffset; - } - - /** - * Returns the amount of free space on this page. - */ - public int getFreeSpace() { - if (usedEntries >= MaxEntries) - return 0; - return SIZE - (ObjectSpaceOffset + usedSpace); - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectStore.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectStore.java deleted file mode 100644 index c9dbbac04..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectStore.java +++ /dev/null @@ -1,435 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -import java.util.*; - -public class ObjectStore implements Observer { - - public static final int MAXIMUM_OBJECT_SIZE = ObjectPage.ObjectSpaceSize - ObjectHeader.SIZE; - protected static final int CurrentObjectStoreVersion = 1; - protected static final int ObjectStoreMetadataAreaID = 1; - - protected PageStore pageStore; /* initialized in open */ - protected String name; /* initialized in open */ - protected Map acquiredObjects; // objects which are currently active - protected Map modifiedObjects; // objects that have been modified since the last sync point. - protected LinkedList cachedObjects; // objects that are just hanging around waiting to be acquired. Kept for performance. - protected Set phantoms; // the set of objects that needs to be deleted since the last sync point. - protected ReservationTable reservations; - - protected ObjectStorePagePolicy pagePolicy; - protected AbstractObjectPolicy objectPolicy; - - /** - * Creates a repository for the pathname. - */ - public static void create(String path) throws ObjectStoreException { - try { - PageStore.create(path); - } catch (PageStoreException e) { - throw new ObjectStoreException(ObjectStoreException.StoreCreateFailure, e); - } - } - - /** - * Deletes the underlying page store. - */ - public static void delete(String path) { - PageStore.delete(path); - } - - /** - * Checks for existence of an object store file. - */ - public static boolean exists(String path) { - return PageStore.exists(path); - } - - /** - * Creates an object store. This store is unusable until opened. - */ - public ObjectStore(AbstractObjectPolicy objectPolicy) { - this.pagePolicy = new ObjectStorePagePolicy(); - this.objectPolicy = objectPolicy; - } - - /** - * Opens an object store. - */ - public void open(String name) throws ObjectStoreException { - try { - pageStore = new PageStore(pagePolicy); - pageStore.open(name); - } catch (PageStoreException e) { - throw new ObjectStoreException(ObjectStoreException.StoreOpenFailure, e); - } - checkMetadata(); - acquiredObjects = new HashMap(); - modifiedObjects = new HashMap(); - cachedObjects = new LinkedList(); - phantoms = new HashSet(); - reservations = new ReservationTable(); - } - - /** - * Closes the object store. - */ - public void close() throws ObjectStoreException { - try { - commit(); - } catch (ObjectStoreException e) { - //make sure the page store file gets closed no matter what - pageStore.close(false); - throw e; - } - try { - pageStore.close(); - } catch (Exception e) { - //ignore failure to close - } - acquiredObjects = null; - modifiedObjects = null; - cachedObjects = null; - phantoms = null; - reservations = null; - } - - public Buffer getMetadataArea(int i) throws ObjectStoreException { - try { - return new Buffer(pageStore.readMetadataArea(i)); - } catch (PageStoreException e) { - throw new ObjectStoreException(ObjectStoreException.MetadataRequestFailure, e); - } - } - - public void putMetadataArea(int i, Buffer buffer) throws ObjectStoreException { - try { - pageStore.writeMetadataArea(i, buffer.getByteArray()); - } catch (PageStoreException e) { - throw new ObjectStoreException(ObjectStoreException.MetadataRequestFailure, e); - } - } - - /** - * Checks to see if the metadata stored in the object store matches that expected by this - * code. If not, a conversion is necessary. - */ - protected void checkMetadata() throws ObjectStoreException { - Buffer metadata = getMetadataArea(ObjectStoreMetadataAreaID); - Field versionField = metadata.getField(0, 4); - int objectStoreVersion = versionField.getInt(); - if (objectStoreVersion == 0) { - // 0 indicates that the store is new and opened for read/write - versionField.put(CurrentObjectStoreVersion); - putMetadataArea(ObjectStoreMetadataAreaID, metadata); - return; - } - if (objectStoreVersion == CurrentObjectStoreVersion) - return; - convert(objectStoreVersion); - } - - /** - * Converts the object store from a previous to the current version. - * No conversions are yet defined. - */ - protected void convert(int fromVersion) throws ObjectStoreException { - throw new ObjectStoreException(ObjectStoreException.StoreConversionFailure); - } - - /** - * Commits the modified object collection to the underlying page store. - */ - public void commit() throws ObjectStoreException { - for (Iterator z = acquiredObjects.values().iterator(); z.hasNext();) { - StoredObject object = (StoredObject) z.next(); - object.notifyObservers(); - } - for (Iterator z = phantoms.iterator(); z.hasNext();) { - ObjectAddress address = (ObjectAddress) z.next(); - int pageNumber = address.getPageNumber(); - ObjectPage page = acquireObjectPage(pageNumber); - page.removeObject(address.getObjectNumber()); - updateSpaceMapPage(page.getPageNumber(), page.getFreeSpace()); - page.release(); - } - phantoms.clear(); - for (Iterator z = modifiedObjects.values().iterator(); z.hasNext();) { - StoredObject object = (StoredObject) z.next(); - z.remove(); - addToCache(object); - ObjectAddress address = object.getAddress(); - int pageNumber = address.getPageNumber(); - ObjectPage page = acquireObjectPage(pageNumber); - if (reservations.contains(address)) { - page.insertObject(object); - updateSpaceMapPage(pageNumber, page.getFreeSpace()); - } else { - page.updateObject(object); - } - page.release(); - } - reservations.clear(); - try { - pageStore.commit(); - } catch (PageStoreException e) { - throw new ObjectStoreException(ObjectStoreException.PageWriteFailure, e); - } - } - - /** - * Returns the StoredObject at a given address. This registers the store as an - * observer of changes to this object. - */ - public StoredObject acquireObject(ObjectAddress address) throws ObjectStoreException { - if (phantoms.contains(address)) { - throw new ObjectStoreException(ObjectStoreException.ObjectExistenceFailure); - } - StoredObject object = (StoredObject) acquiredObjects.get(address); - if (object == null) { - object = (StoredObject) modifiedObjects.get(address); - if (object == null) { - object = removeFromCache(address); - if (object == null) { - int pageNumber = address.getPageNumber(); - ObjectPage page = acquireObjectPage(pageNumber); - try { - Field f = page.getObjectField(address.getObjectNumber()); - if (f == null) - throw new ObjectStoreException(ObjectStoreException.ObjectExistenceFailure); - object = objectPolicy.createObject(f, this, address); - } catch (ObjectStoreException e) { - page.release(); - throw e; - } - page.release(); - } - } - acquiredObjects.put(address, object); - object.addObserver(this); - } - object.addReference(); - return object; - } - - /** - * Releases an object. If there are no more references and the object is not - * in the modified cache, return the object to - * the standard cache. Objects in the standard cache always maintain a - * reference count of 0. - */ - public void releaseObject(StoredObject object) throws ObjectStoreException { - object.removeReference(); - if (object.hasReferences()) - return; - object.notifyObservers(); // one last chance to collect changed objects - object.deleteObserver(this); - acquiredObjects.remove(object.getAddress()); - addToCache(object); - } - - /** - * Updates the store when receiving an object change notification. Required by - * Observer. This places the object in the modified objects cache. This will - * be cleared during commit/rollback processing. An object may reside simultaneously - * in the modified and acquired object caches. - */ - public void update(Observable object, Object arg) { - StoredObject storedObject = (StoredObject) object; - modifiedObjects.put(storedObject.getAddress(), storedObject); - } - - /** - * Adds an object to the backing cache. Objects in this cache are neither in - * the modified set or the acquired set. - */ - protected void addToCache(StoredObject object) { - synchronized (cachedObjects) { - if (acquiredObjects.containsKey(object.getAddress())) - return; - if (modifiedObjects.containsKey(object.getAddress())) - return; - cachedObjects.addFirst(object); - if (cachedObjects.size() <= 50) - return; - cachedObjects.removeLast(); - } - } - - /** - * Removes an object from the backing cache given its address. - */ - protected StoredObject removeFromCache(ObjectAddress address) { - synchronized (cachedObjects) { - StoredObject object = null; - for (Iterator z = cachedObjects.iterator(); z.hasNext();) { - StoredObject o = (StoredObject) z.next(); - if (o.getAddress().equals(address)) { - z.remove(); - object = o; - break; - } - } - return object; - } - } - - /** - * Places an object into the store. This assigns it an address. The address - * is returned. The object is not observed until it is acquired. - */ - // public ObjectAddress insertObject(StoredObject object) throws ObjectStoreException { - // int bytesNeeded = object.length() + ObjectHeader.SIZE; - // ObjectPage page = acquireObjectPageForSize(bytesNeeded); - // int objectNumber = page.insertObject(object); - // int pageNumber = page.getPageNumber(); - // updateSpaceMapPage(page.getPageNumber(), page.getFreeSpace()); - // page.release(); - // object.setAddress(new ObjectAddress(pageNumber, objectNumber)); - // object.setStore(this); - // return object.getAddress(); - // } - /** - * "Inserts" an object into the store by reserving a place for the - * object. This assigns it an address and - * places it in the modified objects map. A reservation is created that - * records the address and the amount of space used. The object is not - * actually added to the underlying store until a commit operation is executed. - */ - public ObjectAddress insertObject(StoredObject object) throws ObjectStoreException { - int bytesNeeded = object.length() + ObjectHeader.SIZE; - ObjectPage page = acquireObjectPageForSize(bytesNeeded); - int pageNumber = page.getPageNumber(); - int objectNumber = page.reserveObject(object, reservations); - page.release(); - ObjectAddress address = new ObjectAddress(pageNumber, objectNumber); - object.setAddress(address); - object.setStore(this); - modifiedObjects.put(address, object); - return address; - } - - /** - * Removes an object from the object store. In doing so, it must remove it from the cache as well. - */ - public void removeObject(ObjectAddress address) throws ObjectStoreException { - if (phantoms.contains(address)) { - throw new ObjectStoreException(ObjectStoreException.ObjectExistenceFailure); - } - if (acquiredObjects.containsKey(address)) { - throw new ObjectStoreException(ObjectStoreException.ObjectIsLocked); - } - StoredObject object = (StoredObject) modifiedObjects.get(address); - boolean inStore = !reservations.contains(address); - if (object != null) { - reservations.remove(address); - modifiedObjects.remove(address); - } - removeFromCache(address); - if (inStore) - phantoms.add(address); - } - - /** - * Places the object in the modified objects cache and marks it as in use. The modified objects - * cache is flushed at commit or rollback time. At that point, the reference to the object - * is dropped. - */ - // public void updateObject(StoredObject object) { - // ObjectAddress address = object.getAddress(); - // if (modifiedObjects.get(address) == null) { - // modifiedObjects.put(address, object); - // try { - // acquireObject(address); - // } catch (ObjectStoreException e) { - // } - // } - // } - - protected void updateSpaceMapPage(int objectPageNumber, int freeSpace) throws ObjectStoreException { - SpaceMapPage p = acquireSpaceMapPage(objectPageNumber); - p.setFreeSpace(objectPageNumber, freeSpace); - p.release(); - } - - /** - * Acquires an object page. This is a convenience method to translate exceptions. - */ - protected ObjectPage acquireObjectPage(int pageNumber) throws ObjectStoreException { - ObjectPage page; - try { - page = (ObjectPage) pageStore.acquire(pageNumber); - } catch (PageStoreException e) { - throw new ObjectStoreException(ObjectStoreException.PageReadFailure, e); - } - return page; - } - - /** - * Looks for the first page that guarantees enough space to meet the criteria. - * This is the "first fit" algorithm and will get slow as the page file grows since - * it is O(n**2). (Each addition of a new page is preceded by a search of all pages.) - * We reduce the overhead by maintaining SpaceMapPages that tell us how full each page - * is. A space map page is the first page of a span of 8K pages (64M total). - * Each byte in a space map page indicates the fullness of each page in the span. - * Since databases are expected to be quite small (<200Mb) we might be able to live with - * this simple algorithm. - */ - protected ObjectPage acquireObjectPageForSize(int bytesNeeded) throws ObjectStoreException { - int oPageNumber = 0; - int numberOfSpans = ((pageStore.numberOfPages() - 1) / ObjectStorePage.SIZE) + 1; - for (int i = 0; i <= numberOfSpans; i++) { - try { - int sPageNumber = i * ObjectStorePage.SIZE; - SpaceMapPage sPage = (SpaceMapPage) pageStore.acquire(sPageNumber); - for (int j = 1; j < ObjectStorePage.SIZE; j++) { - int n = sPageNumber + j; - Reservation r = reservations.get(n); - int bytesAvailable = (r == null) ? sPage.getFreeSpace(n) : r.getFreeSpace(); - if (bytesNeeded <= bytesAvailable) { - oPageNumber = n; - break; - } - } - sPage.release(); - } catch (PageStoreException e) { - throw new ObjectStoreException(ObjectStoreException.PageReadFailure, e); - } - if (oPageNumber != 0) - break; - } - if (oPageNumber == 0) { - throw new ObjectStoreException(ObjectStoreException.PageReadFailure); - } - try { - ObjectPage oPage = (ObjectPage) pageStore.acquire(oPageNumber); - return oPage; - } catch (PageStoreException e) { - throw new ObjectStoreException(ObjectStoreException.PageReadFailure, e); - } - } - - /** - * Acquires a space map page. This is a convenience method to translate exceptions. - */ - protected SpaceMapPage acquireSpaceMapPage(int objectPageNumber) throws ObjectStoreException { - int pageNumber = objectPageNumber & 0xFFFFE000; - SpaceMapPage p = null; - try { - p = (SpaceMapPage) pageStore.acquire(pageNumber); - } catch (PageStoreException e) { - throw new ObjectStoreException(ObjectStoreException.PageReadFailure, e); - } - return p; - } - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectStoreException.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectStoreException.java deleted file mode 100644 index 588bd14a6..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectStoreException.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -import org.eclipse.core.internal.resources.CompatibilityMessages; - -public class ObjectStoreException extends StoreException { - - public final static int GenericFailure = 0; - public final static int InternalFailure = 1; - public final static int StoreCreateFailure = 10; - public final static int StoreConversionFailure = 11; - public final static int StoreOpenFailure = 12; - public final static int StoreCloseFailure = 13; - public final static int PageReadFailure = 20; - public final static int PageWriteFailure = 21; - public final static int PageVacancyFailure = 22; - public final static int ObjectTypeFailure = 23; - public final static int ObjectSizeFailure = 24; - public final static int ObjectExistenceFailure = 25; - public final static int ObjectHeaderFailure = 26; - public final static int ObjectInsertFailure = 27; - public final static int ObjectRemoveFailure = 28; - public final static int ObjectUpdateFailure = 29; - public final static int ObjectIsLocked = 30; - public final static int MetadataRequestFailure = 40; - - public final static String[] message = new String[50]; - - /** - * All serializable objects should have a stable serialVersionUID - */ - private static final long serialVersionUID = 1L; - - static { - initializeMessages(); - } - - public int id = 0; // exception id - - public ObjectStoreException(int id) { - this(id, null); - } - - public ObjectStoreException(int id, Throwable exception) { - super(message[id], exception); - this.id = id; - } - - /** - * Initializes the messages at class load time. - */ - private static void initializeMessages() { - message[GenericFailure] = CompatibilityMessages.objectStore_genericFailure; - message[InternalFailure] = CompatibilityMessages.objectStore_internalFailure; - message[StoreCreateFailure] = CompatibilityMessages.objectStore_storeCreateFailure; - message[StoreConversionFailure] = CompatibilityMessages.objectStore_storeConversionFailure; - message[StoreOpenFailure] = CompatibilityMessages.objectStore_storeOpenFailure; - message[StoreCloseFailure] = CompatibilityMessages.objectStore_storeCloseFailure; - message[PageReadFailure] = CompatibilityMessages.objectStore_pageReadFailure; - message[PageWriteFailure] = CompatibilityMessages.objectStore_pageWriteFailure; - message[PageVacancyFailure] = CompatibilityMessages.objectStore_pageVacancyFailure; - message[ObjectTypeFailure] = CompatibilityMessages.objectStore_objectTypeFailure; - message[ObjectSizeFailure] = CompatibilityMessages.objectStore_objectSizeFailure; - message[ObjectExistenceFailure] = CompatibilityMessages.objectStore_objectExistenceFailure; - message[ObjectHeaderFailure] = CompatibilityMessages.objectStore_objectHeaderFailure; - message[ObjectInsertFailure] = CompatibilityMessages.objectStore_objectInsertFailure; - message[ObjectRemoveFailure] = CompatibilityMessages.objectStore_objectRemoveFailure; - message[ObjectUpdateFailure] = CompatibilityMessages.objectStore_objectUpdateFailure; - message[ObjectIsLocked] = CompatibilityMessages.objectStore_objectIsLocked; - message[MetadataRequestFailure] = CompatibilityMessages.objectStore_metadataRequestFailure; - } - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectStorePage.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectStorePage.java deleted file mode 100644 index 788648e30..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectStorePage.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -abstract class ObjectStorePage extends Page { - - public static final int SIZE = 8192; - - public ObjectStorePage(int pageNumber, byte[] buffer, PageStore pageStore) { - super(pageNumber, pageStore); - pageBuffer = new Buffer(SIZE); - pageBuffer.copyFrom(buffer); - materialize(); - } - protected abstract void materialize(); -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectStorePagePolicy.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectStorePagePolicy.java deleted file mode 100644 index b4d04f1b3..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ObjectStorePagePolicy.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -public class ObjectStorePagePolicy extends AbstractPagePolicy { - - /** - * @see AbstractPagePolicy#createPage(int, byte[], PageStore) - */ - public final Page createPage(int pageNumber, byte[] buffer, PageStore pageStore) { - if (pageNumber % Page.SIZE == 0) { - return new SpaceMapPage(pageNumber, buffer, pageStore); - } - return new ObjectPage(pageNumber, buffer, pageStore); - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Page.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Page.java deleted file mode 100644 index cbf052e9c..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Page.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -import java.util.Observable; - -public abstract class Page extends Observable implements Referable { - - public static final int SIZE = 8192; - - protected int pageNumber; - protected int referenceCount; - protected Buffer pageBuffer; - protected PageStore pageStore; - - /** - * Constructs a new page of the given size. - */ - public Page(int pageNumber, PageStore pageStore) { - this.pageNumber = pageNumber; - this.pageStore = pageStore; - this.referenceCount = 0; - } - - /** - * Adds a reference for this entity to track. - */ - public int addReference() { - referenceCount++; - return referenceCount; - } - - /** - * Returns the page number of the page. - */ - public int getPageNumber() { - return pageNumber; - } - - /** - * Tests for existing references. - */ - public boolean hasReferences() { - return referenceCount > 0; - } - - /** - * Releases a page back to the store. - */ - public void release() { - pageStore.release(this); - } - - /** - * Removes a reference. - */ - public int removeReference() { - if (referenceCount > 0) - referenceCount--; - return referenceCount; - } - - /** - * Writes the contents of the page to a buffer. - */ - public abstract void toBuffer(byte[] buffer); - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/PageStore.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/PageStore.java deleted file mode 100644 index 6dc300750..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/PageStore.java +++ /dev/null @@ -1,446 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -import java.io.*; -import java.util.*; - -public class PageStore implements Observer { - - private static final int NumberOfMetadataAreas = 16; // NEVER change this - private static final int SizeOfMetadataArea = 64; // NEVER change this - private static final int CurrentPageStoreVersion = 1; // version 1 - private static final byte[] ZEROES = new byte[1024]; - - private String name; - private RandomAccessFile file; - private int numberOfPages; - private Map modifiedPages; - private Map acquiredPages; - private int storeOffset; - private AbstractPagePolicy policy; - private byte[] pageBuffer; - private byte[] metadataBuffer; - - /** - * Creates the page file on the file system. Creates a file of zero length. - */ - public static void create(String fileName) throws PageStoreException { - try { - FileOutputStream out = new FileOutputStream(fileName); - out.close(); - } catch (IOException e) { - throw new PageStoreException(PageStoreException.CreateFailure, e); - } - } - - /** - * Deletes the page file from the file system. - */ - public static void delete(String fileName) { - new File(fileName).delete(); - } - - /** - * Returns true if the file exists in the file system. - */ - public static boolean exists(String fileName) { - return new File(fileName).exists(); - } - - /** - * Creates a new PageStore with a given policy. - */ - public PageStore(AbstractPagePolicy policy) { - this.policy = policy; - this.storeOffset = NumberOfMetadataAreas * SizeOfMetadataArea; - } - - /** - * Acquires a new empty page. - */ - //public Page acquire(IPageFactory pageFactory) throws PageStoreException { - // return acquire(pageFactory, numberOfPages); - //} - /** - * Returns the page that has the given page number from the page file. - */ - //public Page acquire(IPageFactory pageFactory, int pageNumber) throws PageStoreException { - // Page p = null; - // numberOfReads++; - // Integer key = new Integer(pageNumber); - // p = (Page)acquiredPages.get(key); - // if (p != null) { - // numberOfCacheHits++; - // addReference(p); - // return p; - // } - // p = (Page)modifiedPages.get(key); - // if (p != null) { - // numberOfCacheHits++; - // addReference(p); - // return p; - // } - // p = readCache.get(pageNumber); - // if (p != null) { - // numberOfCacheHits++; - // addReference(p); - // return p; - // } - // numberOfPages = Math.max(pageNumber + 1, numberOfPages); - // p = pageFactory.create(this, pageNumber); - // getPageFromFile(pageNumber, p); - // addReference(p); - // return p; - //} - /** - * Adds a reference to a page. - */ - //private void addReference(Page page) { - // Integer key = new Integer(page.getPageNumber()); - // if (!page.hasReferences()) acquiredPages.put(key, page); - // page.addReference(); - //} - /** - * Opens the PageStore. The file is created if necessary. - * This will raise an exception if the - * media on which the file is located is read-only - * or not authorized to the user. - */ - public void open(String name) throws PageStoreException { - this.name = name; - pageBuffer = new byte[Page.SIZE]; - metadataBuffer = new byte[SizeOfMetadataArea]; - if (!exists(name)) - create(name); - try { - this.file = new RandomAccessFile(name, "rw"); //$NON-NLS-1$ - } catch (IOException e) { - throw new PageStoreException(PageStoreException.OpenFailure, e); - } - checkMetadata(); - numberOfPages = numberOfPagesInFile(); - /* apply any outstanding transaction by reading the log file and applying it */ - modifiedPages = LogReader.getModifiedPages(this); - flush(); - Log.delete(name); - /* prepare for normal operation */ - acquiredPages = new HashMap(); - } - - /** - * Checks to see if the metadata stored in the page store matches that expected by this - * code. If not, a conversion is necessary. - */ - private void checkMetadata() throws PageStoreException { - byte[] md = readMetadataArea(0); - Buffer metadata = new Buffer(md); - Field versionField = metadata.getField(0, 4); - int pageStoreVersion = versionField.getInt(); - if (pageStoreVersion == 0) { - versionField.put(CurrentPageStoreVersion); - writeMetadataArea(0, md); - return; - } - if (pageStoreVersion == CurrentPageStoreVersion) - return; - convertPageStore(pageStoreVersion); - } - - /** - * Converts the page store file from a previous to the current version. - * No conversions are yet defined. - */ - private void convertPageStore(int fromVersion) throws PageStoreException { - throw new PageStoreException(PageStoreException.ConversionFailure); - } - - /** - * Commits all changes and closes the page store. - */ - public void close() { - close(true); - } - - /** - * Closes the page store. - */ - public void close(boolean commit) { - if (commit) { - try { - commit(); - } catch (PageStoreException e) { - // ignore - } - } - try { - file.close(); - } catch (IOException e) { - // ignore - } - file = null; - } - - /** - * Commits all modified pages to the file. - */ - public void commit() throws PageStoreException { - if (modifiedPages.size() == 0) - return; - LogWriter.putModifiedPages(this, modifiedPages); - flush(); - Log.delete(name); - } - - /** - * Writes the modified pages to the page file. - */ - private void flush() throws PageStoreException { - if (modifiedPages.size() == 0) - return; - Iterator pageStream = modifiedPages.values().iterator(); - while (pageStream.hasNext()) { - Page page = (Page) pageStream.next(); - writePage(page); - } - modifiedPages.clear(); - } - - //public void readFrom(RandomAccessFile file, long offset) throws IOException { - // long n = file.length() - offset; - // if (n <= 0) { - // clear(contents, 0, contents.length); - // return; - // } - // file.seek(offset); - // int m = (int)Math.min((long)contents.length, n); - // file.readFully(contents, 0, m); - // if (m < contents.length) { - // clear(contents, m, contents.length - m); - // } - //} - //public void writeTo(OutputStream out) throws IOException { - // out.write(contents); - //} - //public void writeTo(OutputStream out, int offset, int length) throws IOException { - // out.write(contents, offset, length); - //} - //public void writeTo(RandomAccessFile file, long offset) throws IOException { - // long p = file.length(); - // long n = offset - p; - // while (n > 0) { - // int m = (int)Math.min((long)ZEROES.length, n); - // file.seek(p); - // file.write(ZEROES, 0, m); - // p += m; - // n -= m; - // } - // file.seek(offset); - // file.write(contents); - //} - - /** - * Opens the PageStore with a cache size of 40. - */ - //public void open(String name) throws PageStoreException { - // open(name, 40); - //} - /** - * Opens the PageStore. The file is created if necessary. - * This will raise an exception if the - * media on which the file is located is read-only - * or not authorized to the user. - */ - //public void open(String name, int cacheSize) throws PageStoreException { - // if (!exists(name)) create(name); - // try { - // this.file = new RandomAccessFile(name, "rw"); - // } catch (IOException e) { - // throw new PageStoreException(PageStoreException.OpenFailure); - // } - // this.name = name; - // checkMetadata(); - // numberOfPages = numberOfPagesInFile(); - // numberOfFileReads = 0; - // numberOfFileWrites = 0; - // numberOfReads = 0; - // numberOfWrites = 0; - // numberOfCacheHits = 0; - // /* apply any outstanding transaction by reading the log file and applying it */ - // readCache = new PageCache(0); - // modifiedPages = LogReader.getModifiedPages(name); - // flush(); - // Log.delete(name); - // /* prepare for normal operation */ - // readCache = new PageCache(cacheSize); - // acquiredPages = new HashMap(); - //} - /** - * Acquires the page that has the given page number from the page store. - */ - public Page acquire(int pageNumber) throws PageStoreException { - Integer key = new Integer(pageNumber); - Page page = (Page) acquiredPages.get(key); - if (page == null) { - page = (Page) modifiedPages.get(key); - if (page == null) { - numberOfPages = Math.max(pageNumber + 1, numberOfPages); - page = readPage(pageNumber); - } - acquiredPages.put(key, page); - page.addObserver(this); - } - page.addReference(); - return page; - } - - /** - * Releases a page and decrements its reference count. - */ - public void release(Page page) { - Integer key = new Integer(page.getPageNumber()); - page.removeReference(); - if (page.hasReferences()) - return; - page.deleteObserver(this); - acquiredPages.remove(key); - } - - /** - * Processes a page update. - */ - public void update(Observable object, Object arg) { - Page page = (Page) object; - Integer key = new Integer(page.getPageNumber()); - modifiedPages.put(key, page); - } - - /** - * Returns the file seek offset for a given page number. - */ - protected long offsetOfPage(int pageNumber) { - return (long) (pageNumber * Page.SIZE) + storeOffset; - } - - protected Page readPage(int pageNumber) throws PageStoreException { - if (!readBuffer(offsetOfPage(pageNumber), pageBuffer)) { - throw new PageStoreException(PageStoreException.ReadFailure); - } - Page p = policy.createPage(pageNumber, pageBuffer, this); - p.addObserver(this); - return p; - } - - protected void writePage(Page page) throws PageStoreException { - page.toBuffer(pageBuffer); - long fileOffset = offsetOfPage(page.getPageNumber()); - if (!writeBuffer(fileOffset, pageBuffer, 0, pageBuffer.length)) { - throw new PageStoreException(PageStoreException.WriteFailure); - } - } - - /** - * Returns the file seek offset for a given metadata area - */ - protected long offsetOfMetadataArea(int i) { - return (long) i * SizeOfMetadataArea; - } - - public byte[] readMetadataArea(int i) throws PageStoreException { - if (!readBuffer(offsetOfMetadataArea(i), metadataBuffer)) { - throw new PageStoreException(PageStoreException.MetadataRequestFailure); - } - return new Buffer(metadataBuffer).get(0, metadataBuffer.length); - } - - public void writeMetadataArea(int i, byte[] buffer) throws PageStoreException { - if (i < 0 || i >= NumberOfMetadataAreas) - throw new PageStoreException(PageStoreException.MetadataRequestFailure); - if (buffer.length != SizeOfMetadataArea) - throw new PageStoreException(PageStoreException.MetadataRequestFailure); - if (!writeBuffer(offsetOfMetadataArea(i), buffer, 0, buffer.length)) { - throw new PageStoreException(PageStoreException.MetadataRequestFailure); - } - return; - } - - protected boolean readBuffer(long fileOffset, byte[] buffer) { - new Buffer(buffer).clear(); - long fileLength = getFileLength(); - if (fileOffset >= fileLength) - return true; - int bytesToRead = (int) Math.min(buffer.length, (fileLength - fileOffset)); - try { - file.seek(fileOffset); - file.readFully(buffer, 0, bytesToRead); - } catch (IOException e) { - return false; - } - return true; - } - - protected boolean writeBuffer(long fileOffset, byte[] buffer, int offset, int length) { - clearFileToOffset(fileOffset); - try { - file.seek(fileOffset); - file.write(buffer, offset, length); - } catch (IOException e) { - return false; - } - return true; - } - - protected long getFileLength() { - long n = 0; - try { - n = file.length(); - } catch (IOException e) { - return 0; - } - return n; - } - - protected void clearFileToOffset(long fileOffset) { - long fileLength = getFileLength(); - while (fileLength < fileOffset) { - int m = (int) Math.min(ZEROES.length, (fileOffset - fileLength)); - writeBuffer(fileLength, ZEROES, 0, m); - fileLength += m; - } - } - - /** - * Returns the number of pages actually in the underlying file. - */ - protected int numberOfPagesInFile() { - return (int) ((getFileLength() - offsetOfPage(0)) / Page.SIZE); - } - - /** - * Returns the name of the page store. - */ - public String getName() { - return name; - } - - public AbstractPagePolicy getPolicy() { - return policy; - } - - /** - * Returns the number of pages known about in the PageFile. This can be greater than - * the number of pages actually in the underlying file in the file system if new ones - * have been manufactured and not yet written to the underlying file. - */ - public int numberOfPages() { - return numberOfPages; - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/PageStoreException.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/PageStoreException.java deleted file mode 100644 index bfe935839..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/PageStoreException.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -import org.eclipse.core.internal.resources.CompatibilityMessages; - - -public class PageStoreException extends StoreException { - public final static int GenericFailure = 0; - public final static int CreateFailure = 1; - public final static int OpenFailure = 2; - public final static int LengthFailure = 3; - public final static int WriteFailure = 4; - public final static int ReadFailure = 5; - public final static int CommitFailure = 6; - public final static int IntegrityFailure = 7; - public final static int MetadataRequestFailure = 8; - public final static int ConversionFailure = 9; - - public final static int LogCreateFailure = 20; - public final static int LogOpenFailure = 21; - public final static int LogReadFailure = 23; - public final static int LogWriteFailure = 24; - - public final static String[] message = new String[30]; - - /** - * All serializable objects should have a stable serialVersionUID - */ - private static final long serialVersionUID = 1L; - - static { - initializeMessages(); - } - - public int id = 0; // exception id - - public PageStoreException(int id) { - this(id, null); - } - - public PageStoreException(int id, Throwable exception) { - super(message[id], exception); - this.id = id; - } - - /** - * Initialize the messages at class load time. - */ - private static void initializeMessages() { - message[GenericFailure] = CompatibilityMessages.pageStore_genericFailure; - message[CreateFailure] = CompatibilityMessages.pageStore_createFailure; - message[OpenFailure] = CompatibilityMessages.pageStore_openFailure; - message[LengthFailure] = CompatibilityMessages.pageStore_lengthFailure; - message[WriteFailure] = CompatibilityMessages.pageStore_writeFailure; - message[ReadFailure] = CompatibilityMessages.pageStore_readFailure; - message[CommitFailure] = CompatibilityMessages.pageStore_commitFailure; - message[IntegrityFailure] = CompatibilityMessages.pageStore_integrityFailure; - message[MetadataRequestFailure] = CompatibilityMessages.pageStore_metadataRequestFailure; - message[ConversionFailure] = CompatibilityMessages.pageStore_conversionFailure; - message[LogCreateFailure] = CompatibilityMessages.pageStore_logCreateFailure; - message[LogOpenFailure] = CompatibilityMessages.pageStore_logOpenFailure; - message[LogReadFailure] = CompatibilityMessages.pageStore_logReadFailure; - message[LogWriteFailure] = CompatibilityMessages.pageStore_logWriteFailure; - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Pointer.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Pointer.java deleted file mode 100644 index 0b4d0a0ec..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Pointer.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -class Pointer { - protected Buffer buffer; // contents - protected int offset; // offset of the field within the buffer - - /** - * Constructor for a new Pointer. - */ - public Pointer(Buffer buffer, int offset) { - this.buffer = buffer; - this.offset = offset; - } - - public Pointer dec(int n) { - offset -= n; - return this; - } - - public FieldArray getArray(int length, int stride, int count) { - return new FieldArray(buffer, offset, length, stride, count); - } - - public Field getField(int offset, int length) { - return new Field(buffer, this.offset + offset, length); - } - - public Pointer inc(int n) { - offset += n; - return this; - } - - public Pointer put(byte[] bytes) { - buffer.put(offset, bytes); - return this; - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Referable.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Referable.java deleted file mode 100644 index efc0298da..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Referable.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -interface Referable { - - /** - * Adds a reference for this entity to track. Returns the current count. - */ - int addReference(); - - /** - * Tests for existing references. - */ - boolean hasReferences(); - - /** - * Removes a reference. Returns the current count. - */ - int removeReference(); - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Reservation.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Reservation.java deleted file mode 100644 index 4d6acc205..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/Reservation.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -import java.util.HashMap; -import java.util.Map; - -public class Reservation { - - protected int freeSlots = 0; - protected int freeSpace = 0; - protected int reservedSpace = 0; - protected int initialEntry = 0; - protected Map reservedItems = new HashMap(); - - public Reservation(int freeSpace, int freeSlots, int initialEntry) { - this.freeSlots = freeSlots; - this.freeSpace = freeSpace; - this.initialEntry = initialEntry; - } - - public void add(int slot, int bytes) { - reservedSpace += bytes; - reservedItems.put(new Integer(slot), new Integer(bytes)); - } - - public void remove(int slot) { - Integer bytes = (Integer) reservedItems.remove(new Integer(slot)); - if (bytes == null) - return; - reservedSpace -= bytes.intValue(); - } - - boolean contains(int slot) { - return reservedItems.containsKey(new Integer(slot)); - } - - int getFreeSpace() { - if (reservedItems.size() >= freeSlots) - return 0; - return Math.max(0, freeSpace - reservedSpace); - } - - public int getInitialEntry() { - return initialEntry; - } - - public void setInitialEntry(int n) { - initialEntry = n; - } - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ReservationTable.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ReservationTable.java deleted file mode 100644 index 60f5b4832..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/ReservationTable.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -import java.util.HashMap; -import java.util.Map; - -public class ReservationTable { - - protected Map table = new HashMap(); - - public ReservationTable() { - super(); - } - - public Reservation get(int pageNumber) { - return (Reservation) table.get(new Integer(pageNumber)); - } - - public void put(int pageNumber, Reservation r) { - table.put(new Integer(pageNumber), r); - } - - public boolean contains(int pageNumber) { - return table.containsKey(new Integer(pageNumber)); - } - - public boolean contains(ObjectAddress address) { - int pageNumber = address.getPageNumber(); - int objectNumber = address.getObjectNumber(); - if (contains(pageNumber)) { - if (get(pageNumber).contains(objectNumber)) - return true; - } - return false; - } - - public void remove(ObjectAddress address) { - int pageNumber = address.getPageNumber(); - int objectNumber = address.getObjectNumber(); - Reservation r = (Reservation) table.get(new Integer(pageNumber)); - if (r == null) - return; - r.remove(objectNumber); - } - - public void clear() { - table.clear(); - } - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/SpaceMapPage.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/SpaceMapPage.java deleted file mode 100644 index b25c6c225..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/SpaceMapPage.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -class SpaceMapPage extends ObjectStorePage { - private static int[] SpaceClassSize = {7616, 6906, 6196, 5486, 4776, 4066, 3356, 2646, 1936, 1226, 516, 258, 129, 64, 32, 0}; - - /** - * Returns the guaranteed amount of free space available for a given space class. - */ - public static int freeSpaceForClass(int spaceClass) { - return SpaceClassSize[spaceClass]; - } - - /** - * Creates a new page from a buffer. - */ - public SpaceMapPage(int pageNumber, byte[] buffer, PageStore pageStore) { - super(pageNumber, buffer, pageStore); - } - - /** - * Writes the contents of the page to a buffer. - */ - public void toBuffer(byte[] buffer) { - int n = Math.min(buffer.length, pageBuffer.length()); - System.arraycopy(pageBuffer.getByteArray(), 0, buffer, 0, n); - } - - /** - * Searches a space map page in the page file for an object page - * that has at least "bytesNeeded" bytes free. Returns 0 if there is no - * object page in this space map page that meets this criteria. 0 is not a valid - * object page number. All page numbers that are 0 mod 8192 are space map pages. - */ - // public int findObjectPageNumberForSize(int bytesNeeded) { - // for (int i = 1; i < SIZE; i++) { // begin at 1, 0 is the space map page - // int spaceClass = pageBuffer.getByte(i); - // int freeSpace = freeSpaceForClass(spaceClass); - // if (freeSpace >= bytesNeeded) return pageNumber + i; - // } - // return 0; - // } - /** - * Returns the guaranteed amount of free space on a page. - * If the page number is a space map page number, 0 is returned. - */ - public int getFreeSpace(int pageNumber) { - int slot = pageNumber - this.pageNumber; - if (slot < 1 || slot >= SIZE) - return 0; - int spaceClass = pageBuffer.getByte(slot); - int freeSpace = freeSpaceForClass(spaceClass); - return freeSpace; - } - - /** - * Sets the spaceClass for a given object page. - */ - public void setFreeSpace(int pageNumber, int freeSpace) { - int slot = pageNumber - this.pageNumber; - if (slot < 1 || slot >= SIZE) - return; - byte spaceClass = 0; - while (SpaceClassSize[spaceClass] > freeSpace) - spaceClass++; - pageBuffer.put(slot, spaceClass); - setChanged(); - notifyObservers(); - } - - protected void materialize() { - // do nothing - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/StoreException.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/StoreException.java deleted file mode 100644 index f753996a2..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/StoreException.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -import java.io.PrintStream; -import java.io.PrintWriter; - -public abstract class StoreException extends Exception { - private static final long serialVersionUID = -6565251688819493750L; - protected Throwable wrappedException; - - public StoreException(String message) { - super(message); - } - - public StoreException(String message, Throwable wrappedException) { - super(message); - this.wrappedException = wrappedException; - } - - /** - * Prints a stack trace out for the exception. - */ - public void printStackTrace() { - printStackTrace(System.err); - } - - /** - * Prints a stack trace out for the exception. - */ - public void printStackTrace(PrintStream output) { - synchronized (output) { - super.printStackTrace(output); - if (wrappedException != null) - wrappedException.printStackTrace(output); - } - } - - /** - * Prints a stack trace out for the exception. - */ - public void printStackTrace(PrintWriter output) { - synchronized (output) { - super.printStackTrace(output); - if (wrappedException != null) - wrappedException.printStackTrace(output); - } - } - -} - diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/StoredObject.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/StoredObject.java deleted file mode 100644 index 3197ebb65..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/indexing/StoredObject.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.indexing; - -import java.util.Observable; - -public abstract class StoredObject extends Observable implements Referable, Insertable { - - public static final int MAXIMUM_OBJECT_SIZE = ObjectStore.MAXIMUM_OBJECT_SIZE; - public static final int TYPE_OFFSET = 0; - public static final int TYPE_LENGTH = 2; - - protected ObjectStore store; - protected ObjectAddress address; - protected int referenceCount; - protected int type; - - /** - * Constructs a new object so that it can be stored. - */ - protected StoredObject() { - type = getRequiredType(); - } - - /** - * Constructs a new instance from a field. - */ - protected StoredObject(Field f, ObjectStore store, ObjectAddress address) throws ObjectStoreException { - if (f.length() < getMinimumSize()) { - throw new ObjectStoreException(ObjectStoreException.ObjectSizeFailure); - } - if (f.length() > getMaximumSize()) { - throw new ObjectStoreException(ObjectStoreException.ObjectSizeFailure); - } - extractValues(f); - setStore(store); - setAddress(address); - } - - /** - * Provides a printable representation of this object. Subclasses must implement. - */ - public abstract String toString(); - - /** - * Returns the required type of this class of object. - * Subclasses must override. - */ - protected abstract int getRequiredType(); - - /** - * Returns a byte array value of the object. - */ - public final byte[] toByteArray() { - Field f = new Field(length()); - insertValues(f); - return f.get(); - } - - /** - * Adds a reference. - */ - public final int addReference() { - referenceCount++; - return referenceCount; - } - - /** - * Removes a reference. - */ - public final int removeReference() { - if (referenceCount > 0) - referenceCount--; - return referenceCount; - } - - /** - * Tests for existing references. - */ - public final boolean hasReferences() { - return referenceCount > 0; - } - - /** - * Returns the address of the object. - * Subclasses must not override. - */ - public final ObjectAddress getAddress() { - return address; - } - - public final void setStore(ObjectStore store) { - this.store = store; - } - - public final void setAddress(ObjectAddress address) { - this.address = address; - } - - /** - * Places the contents of the buffer into the members. - * Subclasses should implement and call super. - */ - protected void extractValues(Field f) throws ObjectStoreException { - type = f.subfield(TYPE_OFFSET, TYPE_LENGTH).getInt(); - if (type != getRequiredType()) - throw new ObjectStoreException(ObjectStoreException.ObjectTypeFailure); - } - - /** - * Places the contents of the fields into the buffer. - * Subclasses should implement and call super. - */ - protected void insertValues(Field f) { - f.subfield(TYPE_OFFSET, TYPE_LENGTH).put(type); - } - - /** - * Returns the maximum size of this object's instance -- including its type field. - * Subclasses can override. The default is to have the this be equal to the minimum - * size, forcing a fixed size object. - */ - protected int getMaximumSize() { - return getMinimumSize(); - } - - /** - * Returns the minimum size of this object's instance -- including its type field. - * Subclasses should override. - */ - protected int getMinimumSize() { - return 2; - } - - /** - * Returns the actual size of this object's instance -- including its type field. - * Subclasses should override. - */ - protected int length() { - return getMinimumSize(); - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/localstore/HistoryStore.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/localstore/HistoryStore.java deleted file mode 100644 index f57ac043b..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/localstore/HistoryStore.java +++ /dev/null @@ -1,609 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.localstore; - -import java.io.InputStream; -import java.util.*; -import org.eclipse.core.filesystem.*; -import org.eclipse.core.internal.indexing.*; -import org.eclipse.core.internal.properties.IndexedStoreWrapper; -import org.eclipse.core.internal.resources.*; -import org.eclipse.core.internal.utils.*; -import org.eclipse.core.internal.utils.Convert; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.osgi.util.NLS; - -public class HistoryStore implements IHistoryStore { - /* package */final static String INDEX_FILE = ".index"; //$NON-NLS-1$ - protected BlobStore blobStore; - Set blobsToRemove = new HashSet(); - IndexedStoreWrapper store; - - protected Workspace workspace; - - public HistoryStore(Workspace workspace, IPath location, int limit) { - this.workspace = workspace; - this.blobStore = new BlobStore(EFS.getLocalFileSystem().getStore(location), limit); - this.store = new IndexedStoreWrapper(location.append(INDEX_FILE)); - } - - /** - * Searches indexed store for key, and invokes visitor's defined behaviour on key matches. - * - * @param key key prefix on which to perform search. This is assumed to be - * a path only unless the flag includeLastModTime is true. - * @param visitOnPartialMatch indicates whether visitor's defined behavior is to be invoked - * on partial or full key matches. Partial key matches are not supported on keys which - * contain a last modified time. - * @param includeLastModTime indicates if the key includes a last modified - * time. If set to false, the key is assumed to have only a path. - */ - protected void accept(byte[] key, IHistoryStoreVisitor visitor, boolean visitOnPartialMatch, boolean includeLastModTime) { - try { - IndexCursor cursor = store.getCursor(); - cursor.find(key); - // Check for a prefix match. - while (cursor.keyMatches(key)) { - byte[] storedKey = cursor.getKey(); - - int bytesToOmit = includeLastModTime ? ILocalStoreConstants.SIZE_COUNTER : ILocalStoreConstants.SIZE_KEY_SUFFIX; - // visit if we have an exact match - if (storedKey.length - bytesToOmit == key.length) { - HistoryStoreEntry storedEntry = HistoryStoreEntry.create(store, cursor); - if (!visitor.visit(storedEntry)) - break; - cursor.next(); - continue; - } - - // return if we aren't checking partial matches - if (!visitOnPartialMatch) { - cursor.next(); - continue; - } - - // if the last character of the key is a path - // separator or if the next character in the match - // is a path separator then visit since it is a child - // based on path segment matching. - byte b = storedKey[key.length]; - if (key[key.length - 1] == 47 || b == 47) { - HistoryStoreEntry storedEntry = HistoryStoreEntry.create(store, cursor); - if (!visitor.visit(storedEntry)) - break; - } - cursor.next(); - } - cursor.close(); - } catch (Exception e) { - String message = CompatibilityMessages.history_problemsAccessing; - Policy.log(new ResourceStatus(IResourceStatus.FAILED_READ_LOCAL, null, message, e)); - } - } - - protected void accept(IPath path, IHistoryStoreVisitor visitor, boolean visitOnPartialMatch) { - accept(Convert.toUTF8(path.toString()), visitor, visitOnPartialMatch, false); - } - - /** - * @see IHistoryStore#addState(IPath, IFileStore, IFileInfo, boolean) - */ - public IFileState addState(IPath key, IFileStore localFile, IFileInfo info, boolean moveContents) { - long lastModified = info.getLastModified(); - if (Policy.DEBUG_HISTORY) - System.out.println("History: Adding state for key: " + key + ", file: " + localFile + ", timestamp: " + lastModified + ", size: " + localFile.fetchInfo().getLength()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - if (!isValid(localFile)) - return null; - UniversalUniqueIdentifier uuid = null; - try { - uuid = blobStore.addBlob(localFile, moveContents); - addState(key, uuid, lastModified); - store.commit(); - } catch (CoreException e) { - Policy.log(e); - } - return new FileState(this, key, lastModified, uuid); - } - - /** - * Adds state into history log. - * - * @param path Full workspace path to the resource being logged. - * @param uuid UUID for stored file contents. - * @param lastModified Timestamp for resource being logged. - */ - protected void addState(IPath path, UniversalUniqueIdentifier uuid, long lastModified) { - // Determine how many states already exist for this path and timestamp. - class BitVisitor implements IHistoryStoreVisitor { - BitSet bits = new BitSet(); - - public byte useNextClearBit(byte[] key) { - // Don't use an empty slot as this will put this state - // out of order relative to the other states with the same - // path and last modified time. So find the first clear bit - // after the last set bit. - int nextBit = bits.length(); - // This value must fit in a byte. If we are running off the - // end of the byte, check to see if there are any empty bits - // in the middle. If so, reorganize the counters so we maintain - // the ordering of the states but use up the least number - // of bits (i.e., de-fragment the bit set). - if (nextBit > Byte.MAX_VALUE) { - if (bits.cardinality() < Byte.MAX_VALUE) { - // We know we have some clear bits. - try { - IndexCursor cursor = store.getCursor(); - // destCount will always be the count value of the - // next key we want to assign a state to - byte destCount = (byte) bits.nextClearBit(0); - if (destCount < 0) - // There are no clear bits - return (byte) -1; - // sourceCount will always be the count value of the - // next key we want to move to destCount. When - // sourceCount is -1, there are no more source states - // to move so we are done. - byte sourceCount = (byte) bits.nextSetBit(destCount); - if (sourceCount < 0) - // There are no more states to move - return destCount; - byte[] completeKey = new byte[key.length + 1]; - System.arraycopy(key, 0, completeKey, 0, key.length); - for (; sourceCount >= 0 && destCount >= 0; destCount++) { - completeKey[completeKey.length - 1] = sourceCount; - cursor.find(completeKey); - if (cursor.keyMatches(completeKey)) { - HistoryStoreEntry storedEntry = HistoryStoreEntry.create(store, cursor); - HistoryStoreEntry entryToInsert = new HistoryStoreEntry(storedEntry.getPath(), storedEntry.getUUID(), storedEntry.getLastModified(), destCount); - remove(storedEntry); - ObjectID valueID = store.createObject(entryToInsert.valueToBytes()); - store.getIndex().insert(entryToInsert.getKey(), valueID); - sourceCount = (byte) bits.nextSetBit(sourceCount + 1); - } - } - cursor.close(); - return destCount; - } catch (Exception e) { - String message = CompatibilityMessages.history_problemsAccessing; - Policy.log(new ResourceStatus(IResourceStatus.FAILED_READ_LOCAL, null, message, e)); - } - } else { - // Every count is being used. Too many states. - return (byte) -1; - } - } - return (byte) nextBit; - } - - public boolean visit(HistoryStoreEntry entry) { - bits.set(entry.getCount()); - return true; - } - } - - // Build partial key for which matches will be found. - byte[] keyPrefix = HistoryStoreEntry.keyPrefixToBytes(path, lastModified); - BitVisitor visitor = new BitVisitor(); - accept(keyPrefix, visitor, false, true); - byte index = visitor.useNextClearBit(keyPrefix); - try { - if (index < 0) { - String message = NLS.bind(CompatibilityMessages.history_tooManySimUpdates, path, new Date(lastModified)); - Policy.log(new ResourceStatus(IResourceStatus.FAILED_WRITE_LOCAL, path, message, null)); - return; - } - HistoryStoreEntry entryToInsert = new HistoryStoreEntry(path, uuid, lastModified, index); - // valueToBytes just converts the uuid to byte form - ObjectID valueID = store.createObject(entryToInsert.valueToBytes()); - store.getIndex().insert(entryToInsert.getKey(), valueID); - } catch (Exception e) { - resetIndexedStore(); - String message = NLS.bind(CompatibilityMessages.history_couldNotAdd, path); - Policy.log(new ResourceStatus(IResourceStatus.FAILED_WRITE_LOCAL, path, message, e)); - } - } - - /** - * @see IHistoryStore#allFiles(IPath, int, IProgressMonitor) - */ - public Set allFiles(IPath path, final int depth, IProgressMonitor monitor) { - final Set allFiles = new HashSet(); - final int pathLength = path.segmentCount(); - class PathCollector implements IHistoryStoreVisitor { - public boolean visit(HistoryStoreEntry state) { - IPath memberPath = state.getPath(); - boolean withinDepthRange = false; - switch (depth) { - case IResource.DEPTH_ZERO : - withinDepthRange = memberPath.segmentCount() == pathLength; - break; - case IResource.DEPTH_ONE : - withinDepthRange = memberPath.segmentCount() <= pathLength + 1; - break; - case IResource.DEPTH_INFINITE : - withinDepthRange = true; - break; - } - if (withinDepthRange) { - allFiles.add(memberPath); - } - // traverse children as long as we're still within depth range - return withinDepthRange; - } - } - accept(path, new PathCollector(), true); - return allFiles; - } - - /** - * @see IHistoryStore#clean(IProgressMonitor) - */ - public void clean(IProgressMonitor monitor) { - long start = System.currentTimeMillis(); - int entryCount = 0; - IWorkspaceDescription description = workspace.internalGetDescription(); - long minimumTimestamp = System.currentTimeMillis() - description.getFileStateLongevity(); - int max = description.getMaxFileStates(); - IPath current = null; - List result = new ArrayList(Math.min(max, 1000)); - try { - IndexCursor cursor = store.getCursor(); - cursor.findFirstEntry(); - while (cursor.isSet()) { - entryCount++; - HistoryStoreEntry entry = HistoryStoreEntry.create(store, cursor); - // is it old? - if (entry.getLastModified() < minimumTimestamp) { - remove(entry); - continue; - } - if (!entry.getPath().equals(current)) { - removeOldestEntries(result, max); - result.clear(); - current = entry.getPath(); - } - result.add(entry); - cursor.next(); - } - removeOldestEntries(result, max); - cursor.close(); - store.commit(); - if (Policy.DEBUG_HISTORY) { - Policy.debug("Time to apply history store policies: " + (System.currentTimeMillis() - start) + "ms."); //$NON-NLS-1$ //$NON-NLS-2$ - Policy.debug("Total number of history store entries: " + entryCount); //$NON-NLS-1$ - } - start = System.currentTimeMillis(); - // remove unreferenced blobs - blobStore.deleteBlobs(blobsToRemove); - if (Policy.DEBUG_HISTORY) - Policy.debug("Time to remove " + blobsToRemove.size() + " unreferenced blobs: " + (System.currentTimeMillis() - start) + "ms."); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ - blobsToRemove = new HashSet(); - } catch (Exception e) { - String message = CompatibilityMessages.history_problemsCleaning; - Policy.log(new ResourceStatus(IResourceStatus.FAILED_DELETE_LOCAL, null, message, e)); - } - } - - /* (non-Javadoc) - * @see org.eclipse.core.internal.localstore.IHistoryStore#closeHistory(org.eclipse.core.resources.IResource) - */ - public void closeHistoryStore(IResource resource) { - //old history store does not need to be saved - } - - /** - * @see IHistoryStore#copyHistory(IResource, IResource, boolean) - * @since 2.1 - */ - public void copyHistory(final IResource sourceResource, final IResource destinationResource, boolean moving) { - // Note that if any states in the local history for destination - // have the same timestamp as a state for the local history - // for source, the local history for destination will appear - // as an older state than the one for source. - - // return early if either of the paths are null or if the source and - // destination are the same. - if (sourceResource == null || destinationResource == null) { - String message = CompatibilityMessages.history_copyToNull; - Policy.log(new ResourceStatus(IResourceStatus.INTERNAL_ERROR, null, message, null)); - return; - } - if (sourceResource.equals(destinationResource)) { - String message = CompatibilityMessages.history_copyToSelf; - Policy.log(new ResourceStatus(IResourceStatus.INTERNAL_ERROR, sourceResource.getFullPath(), message, null)); - return; - } - - final IPath source = sourceResource.getFullPath(); - final IPath destination = destinationResource.getFullPath(); - // Note that if any states in the local history for destination - // have the same timestamp as a state for the local history - // for source, the local history for destination will appear - // as an older state than the one for source. - - // matches will be a list of all the places we add local history (without - // any duplicates). - final Set matches = new HashSet(); - - IHistoryStoreVisitor visitor = new IHistoryStoreVisitor() { - public boolean visit(HistoryStoreEntry entry) { - IPath path = entry.getPath(); - int prefixSegments = source.matchingFirstSegments(path); - // if there are no matching segments then we have an internal error...something - // is wrong with the visitor - if (prefixSegments == 0) { - String message = NLS.bind(CompatibilityMessages.history_interalPathErrors, source, path); - Policy.log(new ResourceStatus(IResourceStatus.INTERNAL_ERROR, source, message, null)); - return false; - } - path = destination.append(path.removeFirstSegments(prefixSegments)); - if (!stateAlreadyExists(path, entry.getUUID())) { - matches.add(path); - addState(path, entry.getUUID(), entry.getLastModified()); - } - return true; - } - }; - - // Visit all the entries. Visit partial matches too since this is a depth infinity operation - // and we want to copy history for children. - accept(source, visitor, true); - - // For each match, make sure we haven't exceeded the maximum number of - // states allowed. - IWorkspaceDescription description = workspace.internalGetDescription(); - int maxFileStates = description.getMaxFileStates(); - try { - for (Iterator i = matches.iterator(); i.hasNext();) { - List removeEntries = new LinkedList(); - IndexCursor cursor = store.getCursor(); - IPath path = (IPath) i.next(); - byte key[] = Convert.toUTF8(path.toString()); - cursor.find(key); - // If this key is a match, grab the history store entry for it. - // Don't need to worry about whether or not this is a full path - // match as we know we used this path to add new state information - // to the local history. - while (cursor.keyMatches(key)) { - removeEntries.add(HistoryStoreEntry.create(store, cursor)); - cursor.next(); - } - cursor.close(); - removeOldestEntries(removeEntries, maxFileStates); - } - } catch (IndexedStoreException e) { - String message = NLS.bind(CompatibilityMessages.history_problemsPurging, source, destination); - ResourceStatus status = new ResourceStatus(IResourceStatus.FAILED_WRITE_METADATA, source, message, e); - Policy.log(status); - } catch (CoreException e) { - String message = NLS.bind(CompatibilityMessages.history_problemsPurging, source, destination); - ResourceStatus status = new ResourceStatus(IResourceStatus.FAILED_WRITE_METADATA, source, message, e); - Policy.log(status); - } - - // We need to do a commit here. The addState method we are - // using won't commit store. The public ones will. - try { - store.commit(); - } catch (CoreException e) { - String message = NLS.bind(CompatibilityMessages.history_problemCopying, source, destination); - ResourceStatus status = new ResourceStatus(IResourceStatus.FAILED_WRITE_METADATA, source, message, e); - Policy.log(status); - } - } - - /** - * @see IHistoryStore#exists(IFileState) - */ - public boolean exists(IFileState target) { - return blobStore.fileFor(((FileState) target).getUUID()).fetchInfo().exists(); - } - - /** - * @see IHistoryStore#getContents(IFileState) - */ - public InputStream getContents(IFileState target) throws CoreException { - if (!target.exists()) { - String message = CompatibilityMessages.history_notValid; - throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, target.getFullPath(), message, null); - } - return blobStore.getBlob(((FileState) target).getUUID()); - } - - /** - * @see IHistoryStore#getStates(IPath, IProgressMonitor) - */ - public IFileState[] getStates(final IPath key, IProgressMonitor monitor) { - final int max = workspace.internalGetDescription().getMaxFileStates(); - final List result = new ArrayList(max); - IHistoryStoreVisitor visitor = new IHistoryStoreVisitor() { - public boolean visit(HistoryStoreEntry entry) { - result.add(new FileState(HistoryStore.this, key, entry.getLastModified(), entry.getUUID())); - return true; - } - }; - accept(key, visitor, false); - if (result.isEmpty()) - return ICoreConstants.EMPTY_FILE_STATES; - // put in the order of newer first - IFileState[] states = new IFileState[result.size()]; - for (int i = 0; i < states.length; i++) - states[i] = (IFileState) result.get(result.size() - (i + 1)); - return states; - } - - /** - * Return a boolean value indicating whether or not the given file - * should be added to the history store based on the current history - * store policies. - * - * @param localFile the file to check - * @return <code>true</code> if this file should be added to the history - * store and <code>false</code> otherwise - */ - private boolean isValid(IFileStore localFile) { - WorkspaceDescription description = workspace.internalGetDescription(); - long length = localFile.fetchInfo().getLength(); - boolean result = length <= description.getMaxFileStateSize(); - if (Policy.DEBUG_HISTORY && !result) - System.out.println("History: Ignoring file (too large). File: " + localFile.toString() + //$NON-NLS-1$ - ", size: " + length + //$NON-NLS-1$ - ", max: " + description.getMaxFileStateSize()); //$NON-NLS-1$ - return result; - } - - protected void remove(HistoryStoreEntry entry) throws IndexedStoreException { - try { - Vector objectIds = store.getIndex().getObjectIdentifiersMatching(entry.getKey()); - if (objectIds.size() == 1) { - store.removeObject((ObjectID) objectIds.get(0)); - } else if (objectIds.size() > 1) { - // There is a problem with more than one entry having the same - // key. - String message = NLS.bind(CompatibilityMessages.history_tooManySimUpdates, entry.getPath(), new Date(entry.getLastModified())); - ResourceStatus status = new ResourceStatus(IResourceStatus.FAILED_DELETE_LOCAL, entry.getPath(), message, null); - Policy.log(status); - } - } catch (Exception e) { - String[] messageArgs = {entry.getPath().toString(), new Date(entry.getLastModified()).toString(), entry.getUUID().toString()}; - String message = NLS.bind(CompatibilityMessages.history_specificProblemsCleaning, messageArgs); - ResourceStatus status = new ResourceStatus(IResourceStatus.FAILED_DELETE_LOCAL, null, message, e); - Policy.log(status); - } - // Do not remove the blob yet. It may be referenced by another - // history store entry. - blobsToRemove.add(entry.getUUID()); - entry.remove(); - } - - /** - * @see IHistoryStore#remove(IPath, IProgressMonitor) - */ - public void remove(IPath path, IProgressMonitor monitor) { - if (Path.ROOT.equals(path)) { - removeAll(); - return; - } - try { - IndexCursor cursor = store.getCursor(); - byte[] key = Convert.toUTF8(path.toString()); - cursor.find(key); - while (cursor.keyMatches(key)) { - HistoryStoreEntry entry = HistoryStoreEntry.create(store, cursor); - remove(entry); - } - cursor.close(); - store.commit(); - } catch (Exception e) { - String message = NLS.bind(CompatibilityMessages.history_problemsRemoving, path); - ResourceStatus status = new ResourceStatus(IResourceStatus.FAILED_DELETE_LOCAL, path, message, e); - Policy.log(status); - } - } - - /** - * Remove all the entries in the store. - */ - private void removeAll() { - // TODO: should implement a method with a better performance - try { - IndexCursor cursor = store.getCursor(); - cursor.findFirstEntry(); - while (cursor.isSet()) { - HistoryStoreEntry entry = HistoryStoreEntry.create(store, cursor); - remove(entry); - } - cursor.close(); - store.commit(); - } catch (Exception e) { - String message = NLS.bind(CompatibilityMessages.history_problemsRemoving, workspace.getRoot().getFullPath()); - ResourceStatus status = new ResourceStatus(IResourceStatus.FAILED_DELETE_LOCAL, workspace.getRoot().getFullPath(), message, e); - Policy.log(status); - } - } - - /** - * Go through the history store and remove all of the unreferenced blobs. - * Check the instance variable which holds onto a set of UUIDs of potential - * candidates to be removed. - * - * @see IHistoryStore#removeGarbage() - */ - public void removeGarbage() { - try { - IndexCursor cursor = store.getCursor(); - cursor.findFirstEntry(); - while (!blobsToRemove.isEmpty() && cursor.isSet()) { - HistoryStoreEntry entry = HistoryStoreEntry.create(store, cursor); - blobsToRemove.remove(entry.getUUID()); - cursor.next(); - } - cursor.close(); - blobStore.deleteBlobs(blobsToRemove); - blobsToRemove = new HashSet(); - } catch (Exception e) { - String message = CompatibilityMessages.history_problemsCleaning; - ResourceStatus status = new ResourceStatus(IResourceStatus.FAILED_DELETE_LOCAL, null, message, e); - Policy.log(status); - } - } - - protected void removeOldestEntries(List entries, int maxEntries) throws IndexedStoreException { - // do we have more states than necessary? - if (entries.size() <= maxEntries) - return; - int limit = entries.size() - maxEntries; - for (int i = 0; i < limit; i++) - remove((HistoryStoreEntry) entries.get(i)); - } - - protected void resetIndexedStore() { - store.reset(); - java.io.File target = workspace.getMetaArea().getHistoryStoreLocation().toFile(); - Workspace.clear(target); - target.mkdirs(); - String message = CompatibilityMessages.history_corrupt; - ResourceStatus status = new ResourceStatus(IResourceStatus.INTERNAL_ERROR, null, message, null); - Policy.log(status); - } - - /** - * @see IManager#shutdown(IProgressMonitor) - */ - public void shutdown(IProgressMonitor monitor) { - if (store == null) - return; - store.close(); - } - - /** - * @see IManager#startup(IProgressMonitor) - */ - public void startup(IProgressMonitor monitor) { - // do nothing - } - - boolean stateAlreadyExists(IPath path, final UniversalUniqueIdentifier uuid) { - final boolean[] rc = new boolean[] {false}; - IHistoryStoreVisitor visitor = new IHistoryStoreVisitor() { - public boolean visit(HistoryStoreEntry entry) { - if (rc[0] || uuid.equals(entry.getUUID())) { - rc[0] = true; - return false; - } - return true; - } - }; - accept(path, visitor, false); - return rc[0]; - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/localstore/HistoryStoreConverter.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/localstore/HistoryStoreConverter.java deleted file mode 100644 index f2318d01e..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/localstore/HistoryStoreConverter.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.localstore; - -import org.eclipse.core.internal.resources.CompatibilityMessages; -import org.eclipse.core.internal.resources.Workspace; -import org.eclipse.core.internal.utils.Policy; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.*; - -public class HistoryStoreConverter { - /** - * Converts an existing history store lying on disk to the new history store. - * Returns Status.OK_STATUS if nothing is done, an IStatus.INFO status if - * the conversion happens successfully or an IStatus.ERROR status if an error - * happened during the conversion process. - */ - public IStatus convertHistory(Workspace workspace, IPath location, int limit, final HistoryStore2 destination, boolean rename) { - if (!location.toFile().isDirectory()) - // nothing to be converted - return Status.OK_STATUS; - IPath indexFile = location.append(HistoryStore.INDEX_FILE); - if (!indexFile.toFile().isFile()) - // nothing to be converted - return Status.OK_STATUS; - // visit all existing entries and add them to the new history store - long start = System.currentTimeMillis(); - final CoreException[] exception = new CoreException[1]; - final BucketTree tree = destination.getTree(); - final HistoryBucket currentBucket = (HistoryBucket) tree.getCurrent(); - HistoryStore source = new HistoryStore(workspace, location, limit); - source.accept(Path.ROOT, new IHistoryStoreVisitor() { - public boolean visit(HistoryStoreEntry state) { - try { - tree.loadBucketFor(state.getPath()); - } catch (CoreException e) { - // failed while loading bucket - exception[0] = e; - return false; - } - currentBucket.addBlob(state.getPath(), state.getUUID(), state.getLastModified()); - return true; - } - }, true); - try { - // the last bucket changed will not have been saved - tree.getCurrent().save(); - // we are done using the old history store instance - source.shutdown(null); - } catch (CoreException e) { - // failed during save - exception[0] = e; - } - if (Policy.DEBUG_HISTORY) - Policy.debug("Time to convert local history: " + (System.currentTimeMillis() - start) + "ms."); //$NON-NLS-1$ //$NON-NLS-2$ - if (exception[0] != null) { - // failed while visiting the old data or saving the new data - String conversionFailed = CompatibilityMessages.history_conversionFailed; - Status failure = new MultiStatus(ResourcesPlugin.PI_RESOURCES, IResourceStatus.FAILED_READ_METADATA, new IStatus[] {exception[0].getStatus()}, conversionFailed, null); - // we failed, so don't do anything else - we might try converting again later - return failure; - } - // everything went fine - // if requested rename the index file to something else - // so we don't try converting again in the future - if (rename) - indexFile.toFile().renameTo(indexFile.addFileExtension(Long.toString(System.currentTimeMillis())).toFile()); - String conversionOk = CompatibilityMessages.history_conversionSucceeded; - // leave a note to the user so this does not happen silently - return new Status(IStatus.INFO, ResourcesPlugin.PI_RESOURCES, IStatus.OK, conversionOk, null); - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/localstore/HistoryStoreEntry.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/localstore/HistoryStoreEntry.java deleted file mode 100644 index 44b370098..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/localstore/HistoryStoreEntry.java +++ /dev/null @@ -1,192 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.localstore; - -import org.eclipse.core.internal.indexing.*; -import org.eclipse.core.internal.properties.IndexedStoreWrapper; -import org.eclipse.core.internal.utils.Convert; -import org.eclipse.core.internal.utils.UniversalUniqueIdentifier; -import org.eclipse.core.runtime.*; - -/** - * HistoryStoreEntry objects perform all required conversion operations - * when performing insertion and retrieval from the history store. - * Following retrieval, removal from the store is also performed - * through the entry objects. - * <p> - * For insertion: - * - Create an entry object using create(IndexedStore, IndexCursor). - * - Insert the entry to the store using the keyToBytes() and - * valueToBytes() methods. - * <p> - * For retrieval: - * - Create an entry object by providing the indexed store and - * the cursor location from which version information can be read. - * <p> - * A static method keyPrefixToBytes() is provided to perform the - * conversion of key prefix values to byte array representation. The - * returned value is intended to be used when traversing the indexed - * store on partial key matches (path + timestamp) is required. - * - */ -public class HistoryStoreEntry implements ILocalStoreConstants { - private IndexCursor cursor; - private UniversalUniqueIdentifier uuid; - private byte[] key; - - /** - * Constructs an entry object for retrieval from the history store. - */ - private HistoryStoreEntry(byte[] key, byte[] value, IndexCursor cursor) { - this.cursor = cursor; - this.key = key; - this.uuid = new UniversalUniqueIdentifier(value); - } - - /** - * Constructs an entry object to perform insertion to the history store. - */ - public HistoryStoreEntry(IPath path, UniversalUniqueIdentifier uuid, long lastModified, byte count) { - this.key = keyToBytes(path, lastModified, count); - this.uuid = uuid; - } - - protected boolean compare(byte[] one, byte[] another) { - if (one.length != another.length) - return false; - for (int i = 0; i < one.length; i++) - if (one[i] != another[i]) - return false; - return true; - } - - /** - * Returns an entry object containing the information retrieved from the history store. - * - * @param store Indexed history store from which data is to be read. - * @param cursor Position from which data is to be read. - */ - public static HistoryStoreEntry create(IndexedStoreWrapper store, IndexCursor cursor) throws CoreException, IndexedStoreException { - byte[] key = cursor.getKey(); - ObjectID valueID = cursor.getValueAsObjectID(); - byte[] value = store.getObject(valueID); - return new HistoryStoreEntry(key, value, cursor); - } - - public byte getCount() { - return key[key.length - 1]; - } - - public byte[] getKey() { - return key; - } - - public long getLastModified() { - byte[] lastModifiedBytes = new byte[SIZE_LASTMODIFIED]; - int position = (key.length - SIZE_KEY_SUFFIX); - System.arraycopy(key, position, lastModifiedBytes, 0, SIZE_LASTMODIFIED); - return Convert.bytesToLong(lastModifiedBytes); - } - - public IPath getPath() { - byte[] pathBytes = new byte[key.length - SIZE_KEY_SUFFIX]; - System.arraycopy(key, 0, pathBytes, 0, pathBytes.length); - return new Path(Convert.fromUTF8(pathBytes)); - } - - public UniversalUniqueIdentifier getUUID() { - return uuid; - } - - /** - * Converts the provided parameters into a single byte array representation. - * Format: - * path + lastModified. - * - * @return Converted byte array. - */ - public static byte[] keyPrefixToBytes(IPath path, long lastModified) { - // Retrieve byte array representations of values. - byte[] pathBytes = Convert.toUTF8(path.toString()); - byte[] lastModifiedBytes = Convert.longToBytes(lastModified); - // Byte array to hold key prefix. - byte[] keyPrefixBytes = new byte[pathBytes.length + lastModifiedBytes.length]; - // Copy values. - System.arraycopy(pathBytes, 0, keyPrefixBytes, 0, pathBytes.length); - System.arraycopy(lastModifiedBytes, 0, keyPrefixBytes, pathBytes.length, lastModifiedBytes.length); - return keyPrefixBytes; - } - - /** - * Converts the key for this entry object into byte array representation. - * Format: - * path + lastModified + count. - * - * Note that the count variable consists of a single byte. All other portions - * of the entry consist of multiple bytes. - * - * @return Key as a byte array. - */ - protected byte[] keyToBytes(IPath path, long lastModified, byte count) { - // Get beginning portion of key. - byte[] keyPrefix = keyPrefixToBytes(path, lastModified); - // Byte array to hold full key. The count value is 1 byte in length. - byte[] keyBytes = new byte[keyPrefix.length + 1]; - // Copy all values into full key. - int destPosition = 0; - System.arraycopy(keyPrefix, 0, keyBytes, destPosition, keyPrefix.length); - destPosition += keyPrefix.length; - keyBytes[destPosition] = count; - return keyBytes; - } - - /** - * Removes this entry from the store. - */ - public void remove() throws IndexedStoreException { - if (cursor == null) - return; - reposition(); - if (!cursor.isSet()) - return; - cursor.remove(); - } - - protected void reposition() throws IndexedStoreException { - if (cursor.isSet()) - if (compare(cursor.getKey(), key)) - return; - cursor.find(key); - } - - /** - * Used for debug. - */ - public String toString() { - StringBuffer s = new StringBuffer(); - s.append("Path: ").append(getPath()).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ - s.append("Last Modified: ").append(getLastModified()).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ - s.append("Count: ").append(getCount()).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ - s.append("UUID: ").append(uuid.toStringAsBytes()).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ - return s.toString(); - } - - /** - * Converts the value for this entry object into byte array representation. - * Format: - * uuid. - * - * @return Value as a byte array. - */ - public byte[] valueToBytes() { - return uuid.toBytes(); - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/localstore/IHistoryStoreVisitor.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/localstore/IHistoryStoreVisitor.java deleted file mode 100644 index dc43221da..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/localstore/IHistoryStoreVisitor.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.localstore; - -import org.eclipse.core.internal.indexing.IndexedStoreException; - -public interface IHistoryStoreVisitor { - /** - * Performs required behaviour whenever a match is found in the history store query. - * - * @param state State to be visited in IndexedStore. - */ - public boolean visit(HistoryStoreEntry state) throws IndexedStoreException; -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/IVisitor.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/IVisitor.java deleted file mode 100644 index 05c0d597f..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/IVisitor.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.properties; - -import org.eclipse.core.internal.indexing.IndexCursor; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.QualifiedName; - -/* package */interface IVisitor { - /** - * Answers whether the visitor requires that the <code>IStoredProperty</code> - * has its value filled when matched from the store. - * <p> - * Retrieving the property value may be expensive in time and memory usage - * (dependent upon the size of the property value.)</p> - * <p> - * If the visitor answers true, the <code>visit()</code> method will be - * invoked with a complete property; if the visitor answers false the property - * value will be <code>null</code>. - * - * @param resourceName the name of the matching resource - * @param propertyName the name of the matching property - * @return whether the visit method requires a value - */ - public boolean requiresValue(ResourceName resourceName, QualifiedName propertyName); - - /** - * Performs whatever actions are appropriate to the visitor when a - * match is made to the property store query. - * <p> - * This method is invoked each time a matching entry is found in the store.</p> - * <p> - * Note that the property will have a <code>null</code> value if the <code> - * requiresValue()</code> method returned <code>false</code> for this property. - * - * @see IndexCursor - * @param resourceName the matching resource. - * @param property the matching property. - * @param cursor the cursor positioned at this property in the <code>IndexStore</code>. - */ - public void visit(ResourceName resourceName, StoredProperty property, IndexCursor cursor) throws CoreException; -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/IndexedStoreWrapper.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/IndexedStoreWrapper.java deleted file mode 100644 index 89063a69d..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/IndexedStoreWrapper.java +++ /dev/null @@ -1,211 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.properties; - -import org.eclipse.core.internal.indexing.*; -import org.eclipse.core.internal.resources.*; -import org.eclipse.core.internal.utils.Policy; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.osgi.util.NLS; - -public class IndexedStoreWrapper { - - private IndexedStore store; - private IPath location; - - /* constants */ - private static final String INDEX_NAME = "index"; //$NON-NLS-1$ - - public IndexedStoreWrapper(IPath location) { - this.location = location; - } - - private void open() throws CoreException { - try { - String name = location.toOSString(); - store = IndexedStore.find(name); - if (store == null) { - store = new IndexedStore(); - store.open(name); - } - } catch (Exception e) { - String message = NLS.bind(CompatibilityMessages.indexed_couldNotOpen, location.toOSString()); - ResourceStatus status = new ResourceStatus(IResourceStatus.FAILED_WRITE_LOCAL, location, message, e); - throw new CoreException(status); - } - } - - private void recreate() throws CoreException { - close(); - // Rename the problematic store for future analysis. - java.io.File file = location.toFile(); - file.renameTo(location.addFileExtension("001").toFile()); //$NON-NLS-1$ - file.delete(); - if (!file.exists()) { - try { - open(); - } catch (CoreException e) { - //failed again, null the store to make sure we - //don't attempt to access an invalid store. - store = null; - throw e; - } - } - } - - public synchronized void close() { - if (store == null) - return; - try { - store.close(); - } catch (Exception e) { - String message = NLS.bind(CompatibilityMessages.indexed_couldNotClose, location.toOSString()); - Policy.log(new ResourceStatus(IResourceStatus.FAILED_WRITE_LOCAL, location, message, e)); - } finally { - store = null; - } - } - - public synchronized void commit() throws CoreException { - if (store == null) - return; - try { - store.commit(); - } catch (Exception e) { - String message = NLS.bind(CompatibilityMessages.indexed_couldNotCommit, location.toOSString()); - ResourceStatus status = new ResourceStatus(IResourceStatus.FAILED_WRITE_LOCAL, location, message, e); - throw new ResourceException(status); - } - } - - private void create() throws CoreException { - try { - open(); - } catch (CoreException e) { - Policy.log(e.getStatus()); - //failed to open -- copy store elsewhere and create a new one - recreate(); - if (store == null) { - String message = NLS.bind(CompatibilityMessages.indexed_couldNotCreate, location.toOSString()); - ResourceStatus status = new ResourceStatus(IResourceStatus.FAILED_WRITE_LOCAL, location, message, null); - throw new ResourceException(status); - } - } - } - - private Index createIndex() throws CoreException { - try { - return getStore().createIndex(INDEX_NAME); - } catch (Exception e) { - String message = NLS.bind(CompatibilityMessages.indexed_couldNotCreateIndex, location.toOSString()); - ResourceStatus status = new ResourceStatus(IResourceStatus.FAILED_WRITE_LOCAL, location, message, e); - throw new ResourceException(status); - } - } - - public synchronized Index getIndex() throws CoreException { - Exception problem = null; - try { - return getStore().getIndex(INDEX_NAME); - } catch (IndexedStoreException e) { - if (e.id == IndexedStoreException.IndexNotFound) - return createIndex(); - problem = e; - return null; - } catch (CoreException e) { - //just rethrow - throw e; - } catch (Exception e) { - problem = e; - return null; - } finally { - if (problem != null) { - String message = NLS.bind(CompatibilityMessages.indexed_couldNotGetIndex, location.toOSString()); - ResourceStatus status = new ResourceStatus(IResourceStatus.FAILED_READ_LOCAL, location, message, problem); - throw new ResourceException(status); - } - } - } - - public synchronized String getObjectAsString(ObjectID id) throws CoreException { - try { - return getStore().getObjectAsString(id); - } catch (Exception e) { - String message = NLS.bind(CompatibilityMessages.indexed_couldNotRead, location.toOSString()); - throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, location, message, e); - } - } - - private IndexedStore getStore() throws CoreException { - if (store == null) - create(); - return store; - } - - public synchronized IndexCursor getCursor() throws CoreException { - try { - return getIndex().open(); - } catch (Exception e) { - String message = NLS.bind(CompatibilityMessages.indexed_couldNotCreateCursor, location.toOSString()); - throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, location, message, e); - } - } - - public synchronized ObjectID createObject(String s) throws CoreException { - try { - return getStore().createObject(s); - } catch (Exception e) { - String message = NLS.bind(CompatibilityMessages.indexed_couldNotWrite, location.toOSString()); - throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, location, message, e); - } - } - - public synchronized ObjectID createObject(byte[] b) throws CoreException { - try { - return getStore().createObject(b); - } catch (Exception e) { - String message = NLS.bind(CompatibilityMessages.indexed_couldNotWrite, location.toOSString()); - throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, location, message, e); - } - } - - public synchronized void removeObject(ObjectID id) throws CoreException { - try { - getStore().removeObject(id); - } catch (Exception e) { - String message = NLS.bind(CompatibilityMessages.indexed_couldNotDelete, location.toOSString()); - throw new ResourceException(IResourceStatus.FAILED_DELETE_LOCAL, location, message, e); - } - } - - public synchronized byte[] getObject(ObjectID id) throws CoreException { - try { - return getStore().getObject(id); - } catch (Exception e) { - String message = NLS.bind(CompatibilityMessages.indexed_couldNotRead, location.toOSString()); - throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, location, message, e); - } - } - - /** - * Something has gone wrong. Make a best effort at copying the file - * elsewhere and creating a new one. Log exceptions. - */ - public synchronized void reset() { - try { - recreate(); - } catch (CoreException e) { - Policy.log(e.getStatus()); - } - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/PropertyManager.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/PropertyManager.java deleted file mode 100644 index 874e89a79..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/PropertyManager.java +++ /dev/null @@ -1,293 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.properties; - -import java.util.*; -import org.eclipse.core.internal.events.ILifecycleListener; -import org.eclipse.core.internal.events.LifecycleEvent; -import org.eclipse.core.internal.resources.*; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.*; -import org.eclipse.osgi.util.NLS; - -/** - * @see org.eclipse.core.internal.properties.IPropertyManager - */ -public class PropertyManager implements IManager, ILifecycleListener, IPropertyManager { - protected Workspace workspace; - - public PropertyManager(Workspace workspace) { - this.workspace = workspace; - } - - public void closePropertyStore(IResource target) throws CoreException { - PropertyStore store = getPropertyStoreOrNull(target); - if (store == null) - return; - synchronized (store) { - store.shutdown(null); - setPropertyStore(target, null); - } - } - - /** - * Copy all the properties of one resource to another. Both resources - * must have a property store available. - */ - public void copy(IResource source, IResource destination, int depth) throws CoreException { - // cache stores to avoid problems in concurrency - PropertyStore sourceStore = getPropertyStore(source); - PropertyStore destinationStore = getPropertyStore(destination); - synchronized (sourceStore) { - assertRunning(source, sourceStore); - synchronized (destinationStore) { - assertRunning(destination, destinationStore); - copyProperties(source, destination, depth); - sourceStore.commit(); - destinationStore.commit(); - } - } - } - - /** - * Throws an exception if the store has been shut down - */ - private void assertRunning(IResource target, PropertyStore store) throws CoreException { - if (!store.isRunning()) { - //if the store is not running then the resource is in the process of being deleted, - //so report the error as if the resource was not found - String message = NLS.bind(CompatibilityMessages.resources_mustExist, target.getFullPath()); - throw new ResourceException(IResourceStatus.RESOURCE_NOT_FOUND, target.getFullPath(), message, null); - } - } - - private void copyProperties(IResource source, IResource destination, int depth) throws CoreException { - PropertyStore sourceStore = getPropertyStore(source); - PropertyStore destStore = getPropertyStore(destination); - ResourceName sourceName = getPropertyKey(source); - ResourceName destName = getPropertyKey(destination); - QueryResults results = sourceStore.getAll(sourceName, depth); - for (Enumeration resources = results.getResourceNames(); resources.hasMoreElements();) { - ResourceName resourceName = (ResourceName) resources.nextElement(); - List properties = results.getResults(resourceName); - if (properties.isEmpty()) - continue; - StoredProperty[] propsArray = new StoredProperty[properties.size()]; - propsArray = (StoredProperty[]) properties.toArray(propsArray); - int segmentsToDrop = source.getProjectRelativePath().matchingFirstSegments(resourceName.getPath()); - IPath path = destName.getPath().append(resourceName.getPath().removeFirstSegments(segmentsToDrop)); - resourceName = new ResourceName(resourceName.getQualifier(), path); - destStore.set(resourceName, propsArray, IResource.DEPTH_ZERO, PropertyStore.SET_UPDATE); - } - } - - public void deleteProperties(IResource target, int depth) throws CoreException { - switch (target.getType()) { - case IResource.FILE : - case IResource.FOLDER : - PropertyStore store = getPropertyStore(target); - synchronized (store) { - assertRunning(target, store); - store.removeAll(getPropertyKey(target), depth); - store.commit(); - } - break; - case IResource.PROJECT : - case IResource.ROOT : - deletePropertyStore(target, true); - } - } - - /** - * The resource is being deleted so permanently erase its properties. - * In the case of projects, this means the property store will not be - * accessible again. - */ - public void deleteResource(IResource target) throws CoreException { - switch (target.getType()) { - case IResource.FILE : - case IResource.FOLDER : - case IResource.ROOT : - deleteProperties(target, IResource.DEPTH_INFINITE); - break; - case IResource.PROJECT : - //permanently delete the store - deletePropertyStore(target, false); - } - } - - private void deletePropertyStore(IResource target, boolean restart) throws CoreException { - PropertyStore store = getPropertyStoreOrNull(target); - if (store == null) - return; - synchronized (store) { - store.shutdown(null); - workspace.getMetaArea().getPropertyStoreLocation(target).toFile().delete(); - //if we want to allow restart, null the store and it will be recreated lazily - if (restart) { - ResourceInfo info = getPropertyHost(target).getResourceInfo(false, false); - if (info != null) - info.setPropertyStore(null); - } - } - } - - /** - * Returns the value of the identified property on the given resource as - * maintained by this store. - */ - public String getProperty(IResource target, QualifiedName name) throws CoreException { - PropertyStore store = getPropertyStore(target); - synchronized (store) { - assertRunning(target, store); - StoredProperty result = store.get(getPropertyKey(target), name); - return result == null ? null : result.getStringValue(); - } - } - - /** - * Returns the resource which hosts the property store - * for the given resource. - */ - private Resource getPropertyHost(IResource target) { - return (Resource) (target.getType() == IResource.ROOT ? target : target.getProject()); - } - - /** - * Returns the key to use in the property store when accessing - * the properties of the given resource. - */ - private ResourceName getPropertyKey(IResource target) { - return new ResourceName("", target.getProjectRelativePath()); //$NON-NLS-1$ - } - - PropertyStore getPropertyStore(IResource target) throws CoreException { - return getPropertyStore(target, true); - } - - /** - * Returns the property store to use when storing a property for the - * given resource. - * @throws CoreException if the store could not be obtained for any reason. - */ - PropertyStore getPropertyStore(IResource target, boolean createIfNeeded) throws CoreException { - try { - Resource host = getPropertyHost(target); - ResourceInfo info = host.getResourceInfo(false, false); - if (info == null) { - String message = NLS.bind(CompatibilityMessages.properties_storeNotAvailable, target.getFullPath()); - throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, target.getFullPath(), message, null); - } - PropertyStore store = (PropertyStore) info.getPropertyStore(); - if (store == null) - store = openPropertyStore(host, createIfNeeded); - return store; - } catch (Exception e) { - if (e instanceof CoreException) - throw (CoreException) e; - String message = NLS.bind(CompatibilityMessages.properties_storeNotAvailable, target.getFullPath()); - throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, target.getFullPath(), message, e); - } - } - - /** - * Returns the property store to use when storing a property for the - * given resource, or null if the store is not available. - */ - private PropertyStore getPropertyStoreOrNull(IResource target) { - Resource host = getPropertyHost(target); - ResourceInfo info = host.getResourceInfo(false, false); - if (info != null) { - PropertyStore store = (PropertyStore) info.getPropertyStore(); - if (store != null) { - //sync on the store in case of concurrent deletion - synchronized (store) { - if (store.isRunning()) - return store; - } - } - } - return null; - } - - public void handleEvent(LifecycleEvent event) throws CoreException { - if (event.kind == LifecycleEvent.PRE_PROJECT_CLOSE) - closePropertyStore(event.resource); - } - - private PropertyStore openPropertyStore(IResource target, boolean createIfNeeded) { - int type = target.getType(); - Assert.isTrue(type != IResource.FILE && type != IResource.FOLDER); - IPath location = workspace.getMetaArea().getPropertyStoreLocation(target); - java.io.File storeFile = location.toFile(); - if (!createIfNeeded && !storeFile.isFile()) - return null; - storeFile.getParentFile().mkdirs(); - PropertyStore store = new PropertyStore(location); - setPropertyStore(target, store); - return store; - } - - public void setProperty(IResource target, QualifiedName key, String value) throws CoreException { - PropertyStore store = getPropertyStore(target); - synchronized (store) { - assertRunning(target, store); - if (value == null) { - store.remove(getPropertyKey(target), key); - } else { - StoredProperty prop = new StoredProperty(key, value); - store.set(getPropertyKey(target), prop); - } - store.commit(); - } - } - - private void setPropertyStore(IResource target, PropertyStore value) { - // fetch the info but don't bother making it mutable even though we are going - // to modify it. We don't know whether or not the tree is open and it really doesn't - // matter as the change we are doing does not show up in deltas. - ResourceInfo info = getPropertyHost(target).getResourceInfo(false, false); - if (info.getType() == IResource.PROJECT) - ((ProjectInfo) info).setPropertyStore(value); - else - ((RootInfo) info).setPropertyStore(value); - } - - public void shutdown(IProgressMonitor monitor) throws CoreException { - closePropertyStore(workspace.getRoot()); - } - - public void startup(IProgressMonitor monitor) throws CoreException { - workspace.addLifecycleListener(this); - } - - public Map getProperties(IResource resource) throws CoreException { - PropertyStore store = getPropertyStore(resource); - if (store == null) - return Collections.EMPTY_MAP; - // retrieves the properties for the selected resource - IPath path = resource.getProjectRelativePath(); - ResourceName resourceName = new ResourceName("", path); //$NON-NLS-1$ - QueryResults results = store.getAll(resourceName, 1); - List projectProperties = results.getResults(resourceName); - int listSize = projectProperties.size(); - if (listSize == 0) - return Collections.EMPTY_MAP; - Map properties = new HashMap(); - for (int i = 0; i < listSize; i++) { - StoredProperty prop = (StoredProperty) projectProperties.get(i); - properties.put(prop.getName(), prop.getStringValue()); - } - return properties; - } - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/PropertyStore.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/PropertyStore.java deleted file mode 100644 index 82dcc3a27..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/PropertyStore.java +++ /dev/null @@ -1,491 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.properties; - -import java.util.*; -import org.eclipse.core.internal.indexing.IndexCursor; -import org.eclipse.core.internal.indexing.ObjectID; -import org.eclipse.core.internal.resources.CompatibilityMessages; -import org.eclipse.core.internal.resources.ResourceException; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.*; -import org.eclipse.osgi.util.NLS; - -/** - * - */ -public class PropertyStore { - - // The indexed store will maintain the properties - protected IndexedStoreWrapper store = null; - - // Add directives - public static final int CREATE = 0; // must not exist - public static final int UPDATE = 1; // must exist - public static final int SET_UPDATE = 2; // create if doesn't exist, update if exists - public static final int SET_SKIP = 3; // create if doesn't exist, don't update if exists - - // Remove directives - public static final int IGNORE_MISSING = 0; - public static final int FAIL_MISSING = 1; - - public PropertyStore(IPath location) { - store = new IndexedStoreWrapper(location); - } - - protected boolean basicExists(StoreKey searchKey) throws CoreException { - byte[] searchBytes = searchKey.toBytes(); - IndexCursor cursor = store.getCursor(); - try { - cursor.find(searchBytes); - boolean exists = cursor.keyEquals(searchBytes); - cursor.close(); - return exists; - } catch (Exception e) { - String message = NLS.bind(CompatibilityMessages.properties_couldNotReadProp, searchKey.getQualifier(), searchKey.getLocalName()); - throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, searchKey.getResourceName().getPath(), message, e); - } - } - - /** - * The caller is responsible for ensuring that this will not produce - * duplicate keys in the index. - */ - protected void basicInsert(StoreKey key, String value) throws CoreException { - try { - ObjectID valueID = store.createObject(value); - store.getIndex().insert(key.toBytes(), valueID); - } catch (Exception e) { - String message = NLS.bind(CompatibilityMessages.properties_couldNotWriteProp, key.getQualifier(), key.getLocalName()); - throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, key.getResourceName().getPath(), message, e); - } - } - - protected boolean basicRemove(ResourceName resourceName, QualifiedName propertyName) throws CoreException { - StoreKey key = new StoreKey(resourceName, propertyName); - byte[] keyBytes = key.toBytes(); - boolean wasFound = false; - IndexCursor cursor = store.getCursor(); - try { - cursor.find(keyBytes); - if (cursor.keyEquals(keyBytes)) { - wasFound = true; - ObjectID valueID = cursor.getValueAsObjectID(); - store.removeObject(valueID); - cursor.remove(); - } - cursor.close(); - } catch (Exception e) { - String message = NLS.bind(CompatibilityMessages.properties_couldNotDeleteProp, key.getQualifier(), key.getLocalName()); - throw new ResourceException(IResourceStatus.FAILED_DELETE_LOCAL, resourceName.getPath(), message, e); - } - return wasFound; - } - - protected void basicUpdate(StoreKey key, String value) throws CoreException { - byte[] keyBytes = key.toBytes(); - IndexCursor cursor = store.getCursor(); - try { - cursor.find(keyBytes); - if (cursor.keyEquals(keyBytes)) { - ObjectID oldID = cursor.getValueAsObjectID(); - store.removeObject(oldID); - ObjectID newValueId = store.createObject(value); - cursor.updateValue(newValueId); - } - cursor.close(); - } catch (Exception e) { - String message = NLS.bind(CompatibilityMessages.properties_couldNotWriteProp, key.getQualifier(), key.getLocalName()); - throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, key.getResourceName().getPath(), message, e); - } - } - - protected synchronized void commonSet(ResourceName resourceName, StoredProperty[] properties, int depth, int setMode, QueryResults failures) throws CoreException { - if (depth == IResource.DEPTH_ZERO) { - for (int i = 0; i < properties.length; i++) { - StoredProperty property = properties[i]; - StoreKey key = new StoreKey(resourceName, property.getName()); - boolean exists = basicExists(key); - if ((exists && (setMode == CREATE)) || (!exists && (setMode == UPDATE))) - failures.add(resourceName, property); - else if (exists && (setMode != SET_SKIP)) - basicUpdate(key, property.getStringValue()); - else - basicInsert(key, property.getStringValue()); - } - } else { - Enumeration resourceNamesEnum = deepResourceNames(resourceName); - while (resourceNamesEnum.hasMoreElements()) - commonSet((ResourceName) resourceNamesEnum.nextElement(), properties, IResource.DEPTH_ZERO, setMode, failures); - } - } - - /** - * Returns the names of all resources that are rooted at the given resource. - * <p> - * Answers an <code>Enumeration</code> of <code>IResourceName</code>. - * The enumerator will include (at least) <code>resourceName</code> if it - * exists. If <code>resourceName</code> does not exist returns an empty - * enumerator. - * - * @see ResourceName - * @param resourceName the name of the top most resource to match. - * @return an enumeration of matching resource names. - */ - public Enumeration deepResourceNames(ResourceName resourceName) throws CoreException { - final Set resultHolder = new HashSet(10); - IVisitor visitor = new IVisitor() { - public void visit(ResourceName resourceName, StoredProperty property, IndexCursor cursor) { - resultHolder.add(resourceName); - } - - public boolean requiresValue(ResourceName resourceName, QualifiedName propertyName) { - return false; - } - }; - recordsDeepMatching(resourceName, visitor); - return Collections.enumeration(resultHolder); - } - - /** - * Returns the named property for the given resource. - * <p> - * The retieval is performed to depth zero. Returns <code>null</code> - * if there is no such property defined on the resource. - * - * @param resourceName the resource name to match. - * @param propertyName the property name to match. - * @return the matching property, or <code>null</code> if no such property. - */ - public StoredProperty get(ResourceName resourceName, final QualifiedName propertyName) throws CoreException { - final Object[] resultHolder = new Object[1]; - IVisitor simpleVisitor = new IVisitor() { - public void visit(ResourceName resourceName, StoredProperty property, IndexCursor cursor) { - resultHolder[0] = property; - } - - public boolean requiresValue(ResourceName resourceName, QualifiedName propertyName) { - return true; - } - }; - recordsMatching(resourceName, propertyName, simpleVisitor); - return (StoredProperty) resultHolder[0]; - } - - /** - * Returns all the properties for a given resource. - * <p> - * Answer a <code>QueryResults</code> containing <code>StoredProperty</code>. - * If there are no matches returns an empty <code>QueryResults</code></p> - * <p> - * The depth parameter allows searching based on resource name path prefix.</p> - * - * @see QueryResults - * @param resourceName the resource name to match. - * @param depth the scope of the query - * @return a <code>QueryResults</code> with the matching properties. - */ - public QueryResults getAll(ResourceName resourceName, int depth) throws CoreException { - final QueryResults result = new QueryResults(); - IVisitor visitor = new IVisitor() { - public void visit(ResourceName resourceName, StoredProperty property, IndexCursor cursor) { - result.add(resourceName, property); - } - - public boolean requiresValue(ResourceName resourceName, QualifiedName propertyName) { - return true; - } - }; - if (depth == IResource.DEPTH_ZERO) - recordsMatching(resourceName, visitor); - else - recordsDeepMatching(resourceName, visitor); - return result; - } - - /** - * Returns all the property names for a given resource. - * <p> - * The result is a <code>QueryResults</code> containing <code>QualifiedName</code>. - * If the resource has no defined properties, the method returns - * an empty <code>QueryResults</code>.</p> - * <p> - * The depth parameter allows searching based on resource name path prefix.</p> - * - * @param resourceName the resource name to match. - * @param depth the depth to which the query runs. - * @return a <code>QueryResults</code> containing the property names. - */ - public QueryResults getNames(ResourceName resourceName, int depth) throws CoreException { - QueryResults results = new QueryResults(); - if (depth == IResource.DEPTH_ZERO) - recordsMatching(resourceName, propertyNameVisitor(results)); - else - recordsDeepMatching(resourceName, propertyNameVisitor(results)); - return results; - } - - /** - * Returns true if the property store is up and running. Returns false if - * the store has been shutdown. - */ - public boolean isRunning() { - return store != null; - } - - protected IVisitor propertyNameVisitor(final QueryResults results) { - return new IVisitor() { - public void visit(ResourceName resourceName, StoredProperty property, IndexCursor cursor) { - results.add(resourceName, property.getName()); - } - - public boolean requiresValue(ResourceName resourceName, QualifiedName propertyName) { - return false; - } - }; - } - - /** - * Matches all properties for a given resource. - */ - protected void recordsDeepMatching(ResourceName resourceName, IVisitor visitor) throws CoreException { - - // Build the partial 'search' key - StoreKey searchKey = new StoreKey(resourceName, true); - byte[] searchBytes = searchKey.toBytes(); - int probe = searchBytes.length; - // Position a cursor over the first matching key - IndexCursor cursor = store.getCursor(); - try { - cursor.find(searchBytes); - - // While we have a prefix match - while (cursor.keyMatches(searchBytes)) { - // Must check that the prefix is up to a valid path segment - // note that the matching bytes length is > search key length since - // properties MUST have a local name. - byte[] matchingBytes = cursor.getKey(); - if (probe == 1 || //empty path is a valid prefix for all paths - (matchingBytes[probe] == 0) || // a full path match - (matchingBytes[probe] == 47 /*IPath.SEPARATOR*/)) { - // a segment boundary match - visitPropertyAt(cursor, visitor); - } - // else the match is intra-segment and therefore invalid - cursor.next(); - } - cursor.close(); - } catch (Exception e) { - throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, resourceName.getPath(), CompatibilityMessages.properties_storeProblem, e); - } - } - - /** - * Matches all properties for a given resource. - */ - protected void recordsMatching(ResourceName resourceName, IVisitor visitor) throws CoreException { - - // Build the partial 'search' key - StoreKey searchKey = new StoreKey(resourceName, false); - byte[] searchBytes = searchKey.toBytes(); - // Position a cursor over the first matching key - IndexCursor cursor = store.getCursor(); - try { - cursor.find(searchBytes); - - // While we have a prefix match, evaluate the visitor - while (cursor.keyMatches(searchBytes)) { - visitPropertyAt(cursor, visitor); - cursor.next(); - } - cursor.close(); - } catch (Exception e) { - store.reset(); - throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, resourceName.getPath(), CompatibilityMessages.properties_storeProblem, e); - } - } - - /** - * Matches the given property for a given resource. - * Note that there should be only one. - */ - protected void recordsMatching(ResourceName resourceName, QualifiedName propertyName, IVisitor visitor) throws CoreException { - - // Build the full 'search' key - StoreKey searchKey = new StoreKey(resourceName, propertyName); - byte[] searchBytes = searchKey.toBytes(); - // Position a cursor over the first matching key - IndexCursor cursor = store.getCursor(); - try { - cursor.find(searchBytes); - - // If we have an exact match, evaluate the visitor - if (cursor.keyEquals(searchBytes)) - visitPropertyAt(cursor, visitor); - cursor.close(); - } catch (Exception e) { - store.reset(); - throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, resourceName.getPath(), CompatibilityMessages.properties_storeProblem, e); - } - } - - /** - * Remove the given collection of named properties from the given resource. - * <p> - * All of the properties being removed must exist already on the - * resource based on the removeRule parameter. If the rule is - * MISSING_IGNORE then attempts to remove properties that do not exist - * are ignored, if the rule is MISSING_FAIL the method will throw - * a <code>PropertyNotFoundException</code> if the property does not exist. - * <p> - * If an exception is thrown, all properties that did previously - * exist will have been removed from the resource. To determine which - * properties caused the exception see the offenders result in the exception.</p> - * <p> - * The depth parameter allows matching based on resource name path prefix.</p> - * - * @param resourceName the resource containing the properties. - * @param propertyNames the property names to remove. - * @param depth the scope for matching the resource name. - * @param removeRule the behaviour when removing non-existent properties. - * @exception CoreException - */ - public QueryResults remove(ResourceName resourceName, QualifiedName[] propertyNames, int depth, int removeRule) throws CoreException { - QueryResults failures = new QueryResults(); - if (depth == IResource.DEPTH_ZERO) { - for (int i = 0; i < propertyNames.length; i++) { - boolean found = basicRemove(resourceName, propertyNames[i]); - if (!found && (removeRule == FAIL_MISSING)) - failures.add(resourceName, propertyNames[i]); - } - } else { - Enumeration resourceNamesEnum = deepResourceNames(resourceName); - while (resourceNamesEnum.hasMoreElements()) { - ResourceName resName = (ResourceName) resourceNamesEnum.nextElement(); - for (int i = 0; i < propertyNames.length; i++) { - boolean found = basicRemove(resName, propertyNames[i]); - if (!found && (removeRule == FAIL_MISSING)) - failures.add(resName, propertyNames[i]); - } - } - } - return failures; - } - - /** - * Remove the named property from the given resource. - * <p> - * If a matching property does not exist on this resource - * the method has no affect on the store. Removal is performed - * to depth zero.</p> - * <p> - * @param resourceName the resource containing the property. - * @param propertyName the property to remove. - */ - public void remove(ResourceName resourceName, QualifiedName propertyName) throws CoreException { - remove(resourceName, new QualifiedName[] {propertyName}, IResource.DEPTH_ZERO, IGNORE_MISSING); - } - - /** - * Remove all the properties from a given resource. - * <p> - * The depth parameter allows matching based on resource name path prefix.</p> - * - * @param resourceName the resource containing the properties. - * @param depth the scope for matching the resource name. - */ - public void removeAll(ResourceName resourceName, int depth) throws CoreException { - QueryResults namesSearch = getNames(resourceName, depth); - Enumeration resourceNamesEnum = namesSearch.getResourceNames(); - while (resourceNamesEnum.hasMoreElements()) { - ResourceName resName = (ResourceName) resourceNamesEnum.nextElement(); - Enumeration propertyNamesEnum = Collections.enumeration(namesSearch.getResults(resName)); - while (propertyNamesEnum.hasMoreElements()) { - QualifiedName propertyName = (QualifiedName) propertyNamesEnum.nextElement(); - basicRemove(resName, propertyName); - } - } - } - - /** - * Sets the given collection of properties on the given resource. - * <p> - * The addRule determines whether the properties must already exist - * or not, and if they do whether they are updated by subsequent addition. - * Valid addRule values are defined in <code>IPropertyCollectionConstants</code>. - * <p> - * The depth parameter allows matching based on resource name path prefix.</p> - * <p> - * The <code>PropertyExistsException</code> is thrown if the matching resource - * already has a property of the same name, and the rule requires that - * it must not. If the exception is thrown, all successful properties - * will have been set, and the failures are listed in the exception.</p> - * - * @param resourceName the resource to receive the properties. - * @param properties the properties to add. - * @param depth the depth at which to apply the add operation. - * @param mode the behaviour of the add operation. - * @exception CoreException - */ - public QueryResults set(ResourceName resourceName, StoredProperty[] properties, int depth, int mode) throws CoreException { - QueryResults failures = new QueryResults(); - commonSet(resourceName, properties, depth, mode, failures); - return failures; - } - - /** - * Sets the given property to the given resource. - * <p> - * The property is added to depth zero. If the resource already has - * a property with the same name, its value is updated to the given - * value (i.e. SET_UPDATE add rule equivalent.)</p> - * - * @param resourceName the resource to receive the property. - * @param property the property to add. - */ - public void set(ResourceName resourceName, StoredProperty property) throws CoreException { - commonSet(resourceName, new StoredProperty[] {property}, IResource.DEPTH_ZERO, SET_UPDATE, null); - } - - public void shutdown(IProgressMonitor monitor) { - if (store == null) - return; - try { - store.close(); - } finally { - //null the store so other threads with a handle on it cannot use it - store = null; - } - } - - public void startup(IProgressMonitor monitor) { - //do nothing - } - - protected void visitPropertyAt(IndexCursor cursor, IVisitor visitor) throws CoreException { - try { - StoreKey key = new StoreKey(cursor.getKey()); - ResourceName resourceName = key.getResourceName(); - QualifiedName propertyName = key.getPropertyName(); - String propertyValue = null; - if (visitor.requiresValue(resourceName, propertyName)) - propertyValue = store.getObjectAsString(cursor.getValueAsObjectID()); - visitor.visit(resourceName, new StoredProperty(propertyName, propertyValue), cursor); - } catch (Exception e) { - throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, null, CompatibilityMessages.properties_storeProblem, e); - } - } - - public void commit() throws CoreException { - store.commit(); - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/PropertyStoreConverter.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/PropertyStoreConverter.java deleted file mode 100644 index 9f53edf8b..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/PropertyStoreConverter.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.properties; - -import java.io.File; -import org.eclipse.core.internal.indexing.IndexCursor; -import org.eclipse.core.internal.localstore.BucketTree; -import org.eclipse.core.internal.resources.CompatibilityMessages; -import org.eclipse.core.internal.resources.Workspace; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; - -public class PropertyStoreConverter { - class ConversionVisitor implements IVisitor { - private IPath basePath; - private BucketTree target; - private boolean worked; - - public ConversionVisitor(IPath basePath, BucketTree target) { - this.target = target; - this.basePath = basePath; - } - - public boolean hasWorked() { - return worked; - } - - public boolean requiresValue(ResourceName resourceName, QualifiedName propertyName) { - // we need the values so we can convert - return true; - } - - public void visit(ResourceName resourceName, StoredProperty property, IndexCursor cursor) throws CoreException { - IPath fullPath = basePath.append(resourceName.getPath()); - target.loadBucketFor(fullPath); - // copies a single property - ((PropertyBucket) target.getCurrent()).setProperty(fullPath, property.getName(), property.getStringValue()); - worked = true; - } - } - - /** - * Converts existing persistent property data lying on disk to the new - * property store format. - * Returns Status.OK_STATUS if nothing is done, an IStatus.INFO status if - * the conversion happens successfully or an IStatus.ERROR status if an error - * happened during the conversion process. - */ - public IStatus convertProperties(Workspace workspace, final PropertyManager2 destination) { - // Quickly check whether should try converting persistent properties - // We cannot pay the cost of checking every project so, instead, we try to find - // a single file used by the new implementation - File versionFile = destination.getVersionFile(); - if (versionFile.isFile()) - // conversion already done, won't try doing it again - return Status.OK_STATUS; - final boolean[] worked = {false}; - final PropertyManager source = new PropertyManager(workspace); - try { - // convert the property store for the root and every project - workspace.getRoot().accept(new IResourceVisitor() { - public boolean visit(org.eclipse.core.resources.IResource resource) throws CoreException { - ConversionVisitor propertyConverter = new ConversionVisitor(resource.getFullPath(), destination.getTree()); - PropertyStore store = source.getPropertyStore(resource, false); - if (store == null) - return true; - store.recordsDeepMatching(new ResourceName("", resource.getProjectRelativePath()), propertyConverter); //$NON-NLS-1$ - source.closePropertyStore(resource); - worked[0] = worked[0] || propertyConverter.hasWorked(); - return true; - } - }, IResource.DEPTH_ONE, IResource.NONE); - // the last bucket changed will not have been saved - destination.getTree().getCurrent().save(); - } catch (CoreException e) { - // failed while visiting the old data or saving the new data - String conversionFailed = CompatibilityMessages.properties_conversionFailed; - return new MultiStatus(ResourcesPlugin.PI_RESOURCES, IResourceStatus.FAILED_READ_METADATA, new IStatus[] {e.getStatus()}, conversionFailed, null); - } - if (!worked[0]) - // nothing was found to be converted - return Status.OK_STATUS; - // conversion actually happened, and everything went fine - // leave a note to the user so this does not happen silently - String conversionOk = CompatibilityMessages.properties_conversionSucceeded; - return new Status(IStatus.INFO, ResourcesPlugin.PI_RESOURCES, IStatus.OK, conversionOk, null); - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/QueryResults.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/QueryResults.java deleted file mode 100644 index d25719155..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/QueryResults.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.properties; - -/** - * This type acts as a container for the results of - * a query over the property store. - * <p> - * Where the results of a query are potentially spread across - * multiple resources, the results are gathered together in a - * single query results object.</p> - * - */ -import java.util.*; - -// -public class QueryResults { - protected HashMap table = new HashMap(10); - - public QueryResults() { - super(); - } - - protected void add(ResourceName resourceName, Object value) { - List properties = getResults(resourceName); - if (properties.isEmpty()) - table.put(resourceName, properties); - if (properties.indexOf(value) == -1) - properties.add(value); - } - - /** - * Answers with an <code>Enumeration</code> of resources that comprise - * the result. - * - * @return an <code>Enumeration</code> of <code>ResourceName</code>, - * or an empty enumerator if there were no matching resources. - */ - public Enumeration getResourceNames() { - return Collections.enumeration(table.keySet()); - } - - /** - * Returns all the results for a given resource. - * - * @param resourceName the resource for which the results are sought. - * @return a <code>List</code> of the matching results. The <code>List</code> - * will be empty if there are no matching results. - */ - public List getResults(ResourceName resourceName) { - List results = (List) table.get(resourceName); - if (results == null) - results = new ArrayList(10); - return results; - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/ResourceName.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/ResourceName.java deleted file mode 100644 index d9fb98ac8..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/ResourceName.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.properties; - -import org.eclipse.core.runtime.IPath; - -public class ResourceName { - protected String qualifier = null; - protected IPath path = null; - - public ResourceName(String qualifier, IPath path) { - super(); - this.qualifier = qualifier; - this.path = path; - } - - public boolean equals(Object other) { - if (this == other) - return true; - if (!(other instanceof ResourceName)) - return false; - ResourceName otherName = (ResourceName) other; - if (qualifier == null) { - if (otherName.getQualifier() != null) - return false; - } else if (!qualifier.equals(otherName.getQualifier())) - return false; - return path.equals(otherName.getPath()); - } - - public IPath getPath() { - return path; - } - - public String getQualifier() { - return qualifier; - } - - public int hashCode() { - return path.hashCode(); - } - - public String toString() { - return getQualifier() + " " + getPath().toString(); //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/StoreKey.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/StoreKey.java deleted file mode 100644 index c394e2809..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/StoreKey.java +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.properties; - -import java.io.*; -import org.eclipse.core.internal.resources.CompatibilityMessages; -import org.eclipse.core.internal.resources.ResourceException; -import org.eclipse.core.internal.utils.Convert; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.*; -import org.eclipse.osgi.util.NLS; - -/** - * - */ -public class StoreKey { - protected byte[] value = null; - protected boolean matchPrefix = false; - protected ResourceName resourceName = null; - protected String qualifier = null; - protected String localName = null; - - public StoreKey(byte[] bytes) throws CoreException { - super(); - value = bytes; - initializeObjects(); - } - - /* - * The key is a full key - */ - public StoreKey(ResourceName resourceName, QualifiedName propertyName) throws CoreException { - super(); - this.resourceName = resourceName; - qualifier = propertyName.getQualifier(); - localName = propertyName.getLocalName(); - initializeBytes(); - } - - /* - * The key is a resource name -- either a full resource name - * or a resource name prefix (for deep matching) - * (i.e. no property name) - */ - public StoreKey(ResourceName resourceName, boolean matchPrefix) throws CoreException { - super(); - this.resourceName = resourceName; - this.matchPrefix = matchPrefix; - initializeBytes(); - } - - public String getLocalName() { - return localName; - } - - public QualifiedName getPropertyName() { - return new QualifiedName(qualifier, localName); - } - - public String getQualifier() { - return qualifier; - } - - public ResourceName getResourceName() { - return resourceName; - } - - private void initializeBytes() throws CoreException { - try { - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - // Step 0: the resource name prefix -- always considered in full - writeNullTerminated(buffer, resourceName.getQualifier()); - String path = resourceName.getPath().toString(); - // Step 1: the resource path - if (matchPrefix) { - // don't null terminate resource name - writeBytes(buffer, path); - // If prefix matching, cannot allow other fields to be specified - if (qualifier != null || localName != null) { - String message = NLS.bind(CompatibilityMessages.properties_invalidPropName, qualifier, localName); - throw new ResourceException(IResourceStatus.INVALID_VALUE, null, message, null); - } - } else { - // Zero depth requires full path matching including null - writeNullTerminated(buffer, path); - } - // Step 2: the name space (no prefix matching) - if (qualifier != null) { - writeNullTerminated(buffer, qualifier); - // Step 3: the local name (no prefix matching) - if (localName != null) - writeNullTerminated(buffer, localName); - } else if (localName != null) { - // Specifying a local name without a qualifier is illegal - String message = NLS.bind(CompatibilityMessages.properties_invalidPropName, qualifier, localName); - throw new ResourceException(IResourceStatus.INVALID_VALUE, null, message, null); - } - value = buffer.toByteArray(); - } catch (IOException e) { - // should never happen - throw new ResourceException(IResourceStatus.INTERNAL_ERROR, null, CompatibilityMessages.properties_storeProblem, e); - } - } - - /** - * Assumes value bytes are fully defined -- i.e. initializing - * from a stored key. - */ - protected void initializeObjects() throws CoreException { - try { - ByteArrayInputStream stream = new ByteArrayInputStream(value); - String prefix = readNullTerminated(stream); - String path = readNullTerminated(stream); - resourceName = new ResourceName(prefix, new Path(path)); - qualifier = readNullTerminated(stream); - localName = readNullTerminated(stream); - } catch (IOException e) { - // should never happen - throw new ResourceException(IResourceStatus.INTERNAL_ERROR, null, CompatibilityMessages.properties_storeProblem, e); - } - } - - private String readNullTerminated(ByteArrayInputStream stream) throws IOException { - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - int b; - while ((b = stream.read()) > 0) - buffer.write(b); - //should not reach end of stream without first hitting null (0) byte - if (b == -1) - throw new EOFException(); - return Convert.fromUTF8(buffer.toByteArray()); - } - - public byte[] toBytes() { - return value; - } - - //For debugging - public String toString() { - return new String(toBytes()); - } - - private void writeBytes(ByteArrayOutputStream stream, String aValue) throws IOException { - byte[] bytes = Convert.toUTF8(aValue); - stream.write(bytes); - } - - private void writeNullTerminated(ByteArrayOutputStream stream, String aValue) throws IOException { - writeBytes(stream, aValue); - stream.write(0); - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/StoredProperty.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/StoredProperty.java deleted file mode 100644 index ab4d4f5d1..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/properties/StoredProperty.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.properties; - -import org.eclipse.core.runtime.QualifiedName; - -public class StoredProperty { - protected QualifiedName name = null; - protected String value = null; - - public StoredProperty(QualifiedName name, String value) { - super(); - this.name = name; - this.value = value; - } - - public QualifiedName getName() { - return name; - } - - public String getStringValue() { - return value; - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/resources/CompatibilityMessages.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/resources/CompatibilityMessages.java deleted file mode 100644 index 00bdcf280..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/resources/CompatibilityMessages.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.resources; - -import org.eclipse.osgi.util.NLS; - -public class CompatibilityMessages extends NLS { - - private static final String BUNDLE_NAME = "org.eclipse.core.internal.resources.messages"; //$NON-NLS-1$ - - // properties - public static String indexed_couldNotClose; - public static String indexed_couldNotCommit; - public static String indexed_couldNotCreate; - public static String indexed_couldNotCreateCursor; - public static String indexed_couldNotCreateIndex; - public static String indexed_couldNotDelete; - public static String indexed_couldNotGetIndex; - public static String indexed_couldNotOpen; - public static String indexed_couldNotRead; - public static String indexed_couldNotWrite; - // indexing - public static String indexedStore_contextNotAvailable; - public static String indexedStore_entryKeyLengthError; - public static String indexedStore_entryNotRemoved; - public static String indexedStore_entryRemoved; - public static String indexedStore_entryValueLengthError; - public static String indexedStore_entryValueNotUpdated; - public static String indexedStore_genericError; - public static String indexedStore_indexExists; - public static String indexedStore_indexNodeNotCreated; - public static String indexedStore_indexNodeNotRetrieved; - public static String indexedStore_indexNodeNotSplit; - public static String indexedStore_indexNodeNotStored; - public static String indexedStore_indexNotCreated; - public static String indexedStore_indexNotFound; - public static String indexedStore_indexNotRemoved; - public static String indexedStore_metadataRequestError; - public static String indexedStore_objectExists; - public static String indexedStore_objectIDInvalid; - public static String indexedStore_objectNotAcquired; - public static String indexedStore_objectNotCreated; - public static String indexedStore_objectNotFound; - public static String indexedStore_objectNotReleased; - public static String indexedStore_objectNotRemoved; - public static String indexedStore_objectNotStored; - public static String indexedStore_objectNotUpdated; - public static String indexedStore_objectTypeError; - public static String indexedStore_storeEmpty; - public static String indexedStore_storeFormatError; - public static String indexedStore_storeIsOpen; - public static String indexedStore_storeNotClosed; - public static String indexedStore_storeNotCommitted; - public static String indexedStore_storeNotConverted; - public static String indexedStore_storeNotCreated; - public static String indexedStore_storeNotFlushed; - public static String indexedStore_storeNotOpen; - public static String indexedStore_storeNotOpened; - public static String indexedStore_storeNotReadWrite; - public static String indexedStore_storeNotRolledBack; - public static String objectStore_genericFailure; - public static String objectStore_internalFailure; - public static String objectStore_metadataRequestFailure; - public static String objectStore_objectExistenceFailure; - public static String objectStore_objectHeaderFailure; - public static String objectStore_objectInsertFailure; - public static String objectStore_objectIsLocked; - public static String objectStore_objectRemoveFailure; - public static String objectStore_objectSizeFailure; - public static String objectStore_objectTypeFailure; - public static String objectStore_objectUpdateFailure; - public static String objectStore_pageReadFailure; - public static String objectStore_pageVacancyFailure; - public static String objectStore_pageWriteFailure; - public static String objectStore_storeCloseFailure; - public static String objectStore_storeConversionFailure; - public static String objectStore_storeCreateFailure; - public static String objectStore_storeOpenFailure; - public static String pageStore_commitFailure; - public static String pageStore_conversionFailure; - public static String pageStore_createFailure; - public static String pageStore_genericFailure; - public static String pageStore_integrityFailure; - public static String pageStore_lengthFailure; - public static String pageStore_logCreateFailure; - public static String pageStore_logOpenFailure; - public static String pageStore_logReadFailure; - public static String pageStore_logWriteFailure; - public static String pageStore_metadataRequestFailure; - public static String pageStore_openFailure; - public static String pageStore_readFailure; - public static String pageStore_writeFailure; - public static String history_problemsAccessing; - public static String history_tooManySimUpdates; - public static String history_problemsCleaning; - public static String history_notValid; - public static String history_specificProblemsCleaning; - public static String history_corrupt; - public static String history_problemsRemoving; - public static String history_couldNotAdd; - public static String history_interalPathErrors; - public static String history_copyToNull; - public static String history_copyToSelf; - public static String history_problemsPurging; - public static String history_problemCopying; - public static String history_conversionSucceeded; - // history store - public static String history_conversionFailed; - - public static String properties_storeProblem; - public static String properties_invalidPropName; - public static String properties_conversionFailed; - public static String properties_conversionSucceeded; - public static String properties_couldNotWriteProp; - public static String properties_couldNotDeleteProp; - public static String properties_couldNotReadProp; - public static String properties_storeNotAvailable; - - public static String resources_mustExist; - - static { - // initialize resource bundles - NLS.initializeMessages(BUNDLE_NAME, CompatibilityMessages.class); - } - -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/resources/ResourcesCompatibility.java b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/resources/ResourcesCompatibility.java deleted file mode 100644 index 37c391a26..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/resources/ResourcesCompatibility.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.core.internal.resources; - -import org.eclipse.core.filesystem.EFS; -import org.eclipse.core.filesystem.IFileStore; -import org.eclipse.core.internal.localstore.*; -import org.eclipse.core.internal.properties.*; -import org.eclipse.core.internal.utils.Policy; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; - -/** - * This class provides the entry point to the backward compatibility fragment. - * - * @see ResourcesCompatibilityHelper - */ -public class ResourcesCompatibility { - /** - * Creates a new history store. - * - * @param location the base location for the history store - * @param limit the number of buckets in the blob store - * @param newImpl whether should use the new implementation - * @param convert whether should convert the existing state (ignored if newImpl is false) - * @param rename whether should rename the existing index file after converting (ignored if newImpl or convert are false) - * @return a history store - */ - public static IHistoryStore createHistoryStore(IPath location, int limit, boolean newImpl, boolean convert, boolean rename) { - Workspace workspace = (Workspace) ResourcesPlugin.getWorkspace(); - if (!newImpl) - // keep using the old history store - return new HistoryStore(workspace, location, limit); - IFileStore store = EFS.getLocalFileSystem().getStore(location); - HistoryStore2 newHistoryStore = new HistoryStore2(workspace, store, limit); - if (!convert) - // do not try to convert - return as it is - return newHistoryStore; - IStatus result = new HistoryStoreConverter().convertHistory(workspace, location, limit, newHistoryStore, rename); - // if we do anything (either we fail or succeed converting), a non-OK status is returned - if (result.getSeverity() != IStatus.OK) - Policy.log(result); - return newHistoryStore; - } - /** - * Creates a new property manager. - * - * @param newImpl whether should use the new implementation - * @param convert whether should convert the existing state (ignored if newImpl is false) - * @return a history store - */ - public static IPropertyManager createPropertyManager(boolean newImpl, boolean convert) { - Workspace workspace = (Workspace) ResourcesPlugin.getWorkspace(); - if (!newImpl) - // keep using the old history store - return new PropertyManager(workspace); - PropertyManager2 newPropertyManager = new PropertyManager2(workspace); - if (!convert) - // do not try to convert - return as it is - return newPropertyManager; - // try to convert the existing data now - IStatus result = new PropertyStoreConverter().convertProperties(workspace, newPropertyManager); - if (result.getSeverity() != IStatus.OK) - // if we do anything (either we fail or succeed converting), a non-OK status is returned - Policy.log(result); - return newPropertyManager; - } -} diff --git a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/resources/messages.properties b/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/resources/messages.properties deleted file mode 100644 index 52548a760..000000000 --- a/bundles/org.eclipse.core.resources.compatibility/src/org/eclipse/core/internal/resources/messages.properties +++ /dev/null @@ -1,126 +0,0 @@ -############################################################################### -# Copyright (c) 2005 IBM Corporation and others. -# 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: -# IBM Corporation - initial API and implementation -############################################################################### -### Resources compatibility plugin messages. - -### indexing -indexedStore_contextNotAvailable = Error occurred accessing the indexed store context. -indexedStore_entryKeyLengthError = Key length > 1024. -indexedStore_entryNotRemoved = Cannot remove an index entry referenced by other cursors. -indexedStore_entryRemoved = Element at this cursor has been removed. -indexedStore_entryValueLengthError = Value length > 2048. -indexedStore_entryValueNotUpdated = Error occurred updating value in leaf node. -indexedStore_genericError = An error occurred during an indexed store operation. -indexedStore_indexExists = Index already exists. -indexedStore_indexNodeNotCreated = Index node not created. -indexedStore_indexNodeNotRetrieved = Error occurred getting index node. -indexedStore_indexNodeNotSplit = Error occurred splitting an index node. -indexedStore_indexNodeNotStored = Error occurred storing index node. -indexedStore_indexNotCreated = Index was not created. -indexedStore_indexNotFound = Index not found. -indexedStore_indexNotRemoved = Error occurred removing index from the store. -indexedStore_metadataRequestError = Error occurred during metadata request processing. -indexedStore_objectExists = Object already exists. -indexedStore_objectIDInvalid = ObjectID format is invalid. -indexedStore_objectNotAcquired = Object has not been acquired for the intent needed for this operation. -indexedStore_objectNotCreated = Error occurred creating a new object. -indexedStore_objectNotFound = Object not found. -indexedStore_objectNotReleased = Cannot release an object that has not been acquired. -indexedStore_objectNotRemoved = Error occurred removing an object from the store. -indexedStore_objectNotStored = Object was not stored. -indexedStore_objectNotUpdated = Error occurred updating an object. -indexedStore_objectTypeError = Unexpected object type found. -indexedStore_storeEmpty = Could not find root context because store is empty. -indexedStore_storeFormatError = Could not find root context because store has invalid format. -indexedStore_storeIsOpen = The indexed store is already open. -indexedStore_storeNotClosed = Error closing indexed store. -indexedStore_storeNotCommitted = Error committing the indexed store. -indexedStore_storeNotConverted = The indexed store opened is not the current version and no conversion routine exists. -indexedStore_storeNotCreated = Store does not exist and cannot be created. -indexedStore_storeNotFlushed = Error flushing indexed store. -indexedStore_storeNotOpen = Store has not been opened. -indexedStore_storeNotOpened = Error occurred opening indexed store. -indexedStore_storeNotReadWrite = Attempted to set a Modify intent for an object in a read-only store. -indexedStore_storeNotRolledBack = Error occurred rolling back the indexed store. - -### properties -indexed_couldNotClose = Could not close indexed store: {0}. -indexed_couldNotCommit = Indexed store transactions did not commit properly: {0}. -indexed_couldNotCreate = Could not create indexed store: {0}. -indexed_couldNotCreateCursor = Could not create indexed cursor: {0}. -indexed_couldNotCreateIndex = Could not create index for store: {0}. -indexed_couldNotDelete = Could not delete from indexed store: {0}. -indexed_couldNotGetIndex = Could not get index for store: {0}. -indexed_couldNotOpen = Could not open indexed store: {0}. -indexed_couldNotRead = Could not read from indexed store: {0}. -indexed_couldNotWrite = Could not write to indexed store: {0}. - -objectStore_genericFailure = Error occurred in object store operation. -objectStore_internalFailure = Internal error occurred in object store operation. -objectStore_metadataRequestFailure = Error getting or putting metadata. -objectStore_objectExistenceFailure = Object was not found. -objectStore_objectHeaderFailure = Object header format is invalid. -objectStore_objectInsertFailure = Error occurred writing object into page. -objectStore_objectIsLocked = Operation cannot be performed because the object is being used. -objectStore_objectRemoveFailure = Error occurred removing object from page. -objectStore_objectSizeFailure = Object is too large for page. -objectStore_objectTypeFailure = Type check failed. -objectStore_objectUpdateFailure = Error updating object. -objectStore_pageReadFailure = Error reading page from object store. -objectStore_pageVacancyFailure = Object table on page is full. -objectStore_pageWriteFailure = Cannot store page in page store. -objectStore_storeCloseFailure = Error occurred during close of object store. -objectStore_storeConversionFailure = Error converting object store. -objectStore_storeCreateFailure = Error creating object store. -objectStore_storeOpenFailure = Error opening object store. - -pageStore_commitFailure = Error occurred during commit processing. -pageStore_conversionFailure = Error occurred during conversion of the page store file. -pageStore_createFailure = Error occurred creating page store file. -pageStore_genericFailure = Error occurred during a page store file operation. -pageStore_integrityFailure = Error occurred that compromises the integrity of the page store file. -pageStore_lengthFailure = Error occurred determining page store file length. -pageStore_logCreateFailure = Error occurred creating transaction log file. -pageStore_logOpenFailure = Error occurred opening transaction log file. -pageStore_logReadFailure = Error occurred reading transaction log file. -pageStore_logWriteFailure = Error occurred writing transaction log file. -pageStore_metadataRequestFailure = Error occurred during metadata request processing. -pageStore_openFailure = Error occurred opening page store file. -pageStore_readFailure = Error occurred reading page store file. -pageStore_writeFailure = Error occurred writing page store file. - -### history store -history_conversionFailed = Conversion of local history completed with failures. -history_conversionSucceeded = Conversion of local history completed successfully. -history_copyToNull = Unable to copy local history to or from a null location. -history_copyToSelf = Unable to copy local history to and from the same location. -history_corrupt = The history store got corrupted. Local history is lost. A new store is being created. -history_couldNotAdd = Could not add history for {0}. -history_interalPathErrors = Problems copying local history information from {0} which expanded to {1}. -history_notValid = State is not valid or might have expired. -history_problemCopying = Problems copying local history from {0} to {1}. -history_problemsAccessing = Problems accessing history store. -history_problemsCleaning = Problems cleaning up history store. -history_problemsPurging = Problems purging local history information after copying local history from {0} to {1}. -history_problemsRemoving = Problems removing history for {0}. -history_specificProblemsCleaning = Problems cleaning history store for file {0}, modified on {1}, with UUID {2}. -history_tooManySimUpdates = Some local history is missing as there are too many simultaneous updates for file {0} with timestamp {1}. - -properties_conversionFailed = Conversion of persistent properties failed. -properties_conversionSucceeded = Conversion of persistent properties completed successfully. -properties_couldNotDeleteProp = Could not delete property: {0} {1}. -properties_couldNotReadProp = Could not read property: {0} {1}. -properties_couldNotWriteProp = Could not write property: {0} {1}. -properties_invalidPropName = Invalid property name: {0} {1}. -properties_storeNotAvailable = Property store is not available for: {0}. -properties_storeProblem = Problems accessing property store. - -resources_mustExist = Resource {0} does not exist. - |