--- /dev/null
+#Tue Sep 21 12:13:50 CEST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.codeComplete.argumentPrefixes=
+org.eclipse.jdt.core.codeComplete.argumentSuffixes=
+org.eclipse.jdt.core.codeComplete.fieldPrefixes=
+org.eclipse.jdt.core.codeComplete.fieldSuffixes=
+org.eclipse.jdt.core.codeComplete.localPrefixes=
+org.eclipse.jdt.core.codeComplete.localSuffixes=
+org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
+org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
+org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes=
+org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
+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_annotation=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_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_method_declaration=0
+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=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
+org.eclipse.jdt.core.formatter.comment.format_line_comments=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
+org.eclipse.jdt.core.formatter.comment.line_length=80
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
+org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=true
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=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=false
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not 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=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_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.join_lines_in_comments=true
+org.eclipse.jdt.core.formatter.join_wrapped_lines=true
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=true
+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=true
+org.eclipse.jdt.core.formatter.lineSplit=100
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false
+org.eclipse.jdt.core.formatter.tabulation.char=space
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_on_off_tags=false
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
--- /dev/null
+#Tue Sep 21 12:04:01 CEST 2010
+cleanup.add_default_serial_version_id=true
+cleanup.add_generated_serial_version_id=false
+cleanup.add_missing_annotations=true
+cleanup.add_missing_deprecated_annotations=true
+cleanup.add_missing_methods=true
+cleanup.add_missing_nls_tags=false
+cleanup.add_missing_override_annotations=true
+cleanup.add_missing_override_annotations_interface_methods=true
+cleanup.add_serial_version_id=true
+cleanup.always_use_blocks=false
+cleanup.always_use_parentheses_in_expressions=false
+cleanup.always_use_this_for_non_static_field_access=false
+cleanup.always_use_this_for_non_static_method_access=false
+cleanup.convert_to_enhanced_for_loop=false
+cleanup.correct_indentation=true
+cleanup.format_source_code=true
+cleanup.format_source_code_changes_only=false
+cleanup.make_local_variable_final=true
+cleanup.make_parameters_final=false
+cleanup.make_private_fields_final=true
+cleanup.make_type_abstract_if_missing_method=false
+cleanup.make_variable_declarations_final=false
+cleanup.never_use_blocks=true
+cleanup.never_use_parentheses_in_expressions=true
+cleanup.organize_imports=true
+cleanup.qualify_static_field_accesses_with_declaring_class=false
+cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+cleanup.qualify_static_member_accesses_with_declaring_class=true
+cleanup.qualify_static_method_accesses_with_declaring_class=false
+cleanup.remove_private_constructors=true
+cleanup.remove_trailing_whitespaces=true
+cleanup.remove_trailing_whitespaces_all=true
+cleanup.remove_trailing_whitespaces_ignore_empty=false
+cleanup.remove_unnecessary_casts=true
+cleanup.remove_unnecessary_nls_tags=true
+cleanup.remove_unused_imports=true
+cleanup.remove_unused_local_variables=true
+cleanup.remove_unused_private_fields=true
+cleanup.remove_unused_private_members=false
+cleanup.remove_unused_private_methods=true
+cleanup.remove_unused_private_types=true
+cleanup.sort_members=false
+cleanup.sort_members_all=false
+cleanup.use_blocks=true
+cleanup.use_blocks_only_for_return_and_throw=false
+cleanup.use_parentheses_in_expressions=false
+cleanup.use_this_for_non_static_field_access=false
+cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+cleanup.use_this_for_non_static_method_access=false
+cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+cleanup_profile=_Mine
+cleanup_settings_version=2
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=_Mine
+formatter_settings_version=11
+org.eclipse.jdt.ui.exception.name=e
+org.eclipse.jdt.ui.gettersetter.use.is=true
+org.eclipse.jdt.ui.javadoc=false
+org.eclipse.jdt.ui.keywordthis=false
+org.eclipse.jdt.ui.overrideannotation=true
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><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">/**\n * @return the ${bare_field_name}\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">/**\n * @param ${param} the ${bare_field_name} to set\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">/**\n * ${tags}\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">/**\n * \n */</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n *\n * ${tags}\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">/**\n * \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">/**\n * ${tags}\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)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\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">\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">\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">\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">\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">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</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">// ${todo} Auto-generated method stub\n${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}\n// ${todo} Auto-generated constructor stub</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>
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=true
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=true
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=false
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_trailing_whitespaces=false
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
public class FritzBox
{
- String url_;
- String sid_;
-
- public FritzBox(String password, String url)
- throws SAXException, IOException
- {
- url_ = url;
-
- HttpResponse response = null;
- try {
- response = httpGet("cgi-bin/webcm")
- .addParameter("getpage", "../html/login_sid.xml")
- .execute();
- LoginXML loginxml = new LoginXML(response);
- response.close();
- response = null;
-
- if (loginxml.iswriteaccess()) {
- sid_ = loginxml.sid();
- return;
- }
-
- response = httpPost("cgi-bin/webcm")
- .addParameter("getpage", "../html/login_sid.xml")
- .addParameter("var:lang", "de")
- .addParameter("login:command/response",
- loginxml.response(password)).execute();
- loginxml = new LoginXML(response);
- response.close();
- response = null;
-
- if (!loginxml.iswriteaccess())
- throw new RuntimeException("FritzBox login failed");
-
- sid_ = loginxml.sid();
- }
- finally {
- Util.nothrowClose(response);
- }
-
- }
-
- public InputStream exportAddressbook()
- throws IOException
- {
- return httpPostMultipart("cgi-bin/firmwarecfg")
- .addParameter("sid", sid_)
- .addParameter("PhonebookId", "0")
- .addParameter("PhonebookExportName", "Telefonbuch")
- .addParameter("PhonebookExport", "").execute();
- }
-
- public OutputStream importAddressbook()
- throws IOException
- {
- return new ByteArrayOutputStream() {
- public void close()
- throws IOException
- {
- httpPostMultipart("cgi-bin/firmwarecfg")
- .addParameter("sid", sid_)
- .addParameter("PhonebookId", "0")
- .addParameter("PhonebookImportFile", toByteArray(), "iso-8859-1")
- .execute()
- .close();
- }
- };
- }
-
- HttpRequest httpGet(String path)
- {
- return new HttpGETRequest(url_ + "/" + path);
- }
-
- HttpRequest httpPost(String path)
- {
- return new HttpPOSTRequest(url_ + "/" + path);
- }
-
- HttpRequest httpPostMultipart(String path)
- {
- return new HttpPOSTRequest(url_ + "/" + path).setMultipart(true);
- }
+ String url_;
+ String sid_;
+
+ public FritzBox(String password, String url) throws SAXException,
+ IOException
+ {
+ url_ = url;
+
+ HttpResponse response = null;
+ try {
+ response = httpGet("cgi-bin/webcm").addParameter("getpage",
+ "../html/login_sid.xml").execute();
+ LoginXML loginxml = new LoginXML(response);
+ response.close();
+ response = null;
+
+ if (loginxml.iswriteaccess()) {
+ sid_ = loginxml.sid();
+ return;
+ }
+
+ response = httpPost("cgi-bin/webcm")
+ .addParameter("getpage", "../html/login_sid.xml")
+ .addParameter("var:lang", "de")
+ .addParameter("login:command/response",
+ loginxml.response(password)).execute();
+ loginxml = new LoginXML(response);
+ response.close();
+ response = null;
+
+ if (!loginxml.iswriteaccess()) throw new RuntimeException(
+ "FritzBox login failed");
+
+ sid_ = loginxml.sid();
+ }
+ finally {
+ Util.nothrowClose(response);
+ }
+
+ }
+
+ public InputStream exportAddressbook() throws IOException
+ {
+ return httpPostMultipart("cgi-bin/firmwarecfg")
+ .addParameter("sid", sid_).addParameter("PhonebookId", "0")
+ .addParameter("PhonebookExportName", "Telefonbuch")
+ .addParameter("PhonebookExport", "").execute();
+ }
+
+ public OutputStream importAddressbook() throws IOException
+ {
+ return new ByteArrayOutputStream() {
+ public void close() throws IOException
+ {
+ httpPostMultipart("cgi-bin/firmwarecfg")
+ .addParameter("sid", sid_)
+ .addParameter("PhonebookId", "0")
+ .addParameter("PhonebookImportFile", toByteArray(),
+ "iso-8859-1").execute().close();
+ }
+ };
+ }
+
+ HttpRequest httpGet(String path)
+ {
+ return new HttpGETRequest(url_ + "/" + path);
+ }
+
+ HttpRequest httpPost(String path)
+ {
+ return new HttpPOSTRequest(url_ + "/" + path);
+ }
+
+ HttpRequest httpPostMultipart(String path)
+ {
+ return new HttpPOSTRequest(url_ + "/" + path).setMultipart(true);
+ }
}
public class LoginXML
{
- Document xml_;
-
- public LoginXML(InputStream is)
- throws SAXException, IOException
- {
- xml_ = XmlUtil.parse(is);
- }
-
- public boolean iswriteaccess()
- throws SAXException
- {
- try {
- return xml_.getElementsByTagName("iswriteaccess").item(0).getTextContent().equals("1");
- }
- catch (NullPointerException e) {
- throw new SAXException();
- }
- }
-
- public String sid()
- throws SAXException
- {
- try {
- return Util.nonnull(xml_.getElementsByTagName("SID").item(0).getTextContent());
- }
- catch (NullPointerException e) {
- throw new SAXException();
- }
- }
-
- public String challenge()
- throws SAXException
- {
- try {
- return Util.nonnull(xml_.getElementsByTagName("Challenge").item(0).getTextContent());
- }
- catch (NullPointerException e) {
- throw new SAXException();
- }
- }
-
- public String response(String password)
- throws SAXException
- {
- try {
- String c = challenge();
- MessageDigest md = MessageDigest.getInstance("MD5");
- md.update((c + "-" + password).getBytes("UTF-16LE"));
- return c + "-" + new HexBinaryAdapter().marshal(md.digest()).toLowerCase();
- } catch (NoSuchAlgorithmException e) {
- throw new AssertionError("missing MD5 implementation");
- } catch (UnsupportedEncodingException e) {
- throw new AssertionError("missing UTF-16LE encoding");
- }
- }
+ Document xml_;
+
+ public LoginXML(InputStream is) throws SAXException, IOException
+ {
+ xml_ = XmlUtil.parse(is);
+ }
+
+ public boolean iswriteaccess() throws SAXException
+ {
+ try {
+ return xml_.getElementsByTagName("iswriteaccess").item(0)
+ .getTextContent().equals("1");
+ }
+ catch (NullPointerException e) {
+ throw new SAXException();
+ }
+ }
+
+ public String sid() throws SAXException
+ {
+ try {
+ return Util.nonnull(xml_.getElementsByTagName("SID").item(0)
+ .getTextContent());
+ }
+ catch (NullPointerException e) {
+ throw new SAXException();
+ }
+ }
+
+ public String challenge() throws SAXException
+ {
+ try {
+ return Util.nonnull(xml_.getElementsByTagName("Challenge").item(0)
+ .getTextContent());
+ }
+ catch (NullPointerException e) {
+ throw new SAXException();
+ }
+ }
+
+ public String response(String password) throws SAXException
+ {
+ try {
+ String c = challenge();
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ md.update((c + "-" + password).getBytes("UTF-16LE"));
+ return c + "-"
+ + new HexBinaryAdapter().marshal(md.digest()).toLowerCase();
+ }
+ catch (NoSuchAlgorithmException e) {
+ throw new AssertionError("missing MD5 implementation");
+ }
+ catch (UnsupportedEncodingException e) {
+ throw new AssertionError("missing UTF-16LE encoding");
+ }
+ }
}
package de.j32.httplib;
-public class HttpGETRequest
- extends HttpRequest
+public class HttpGETRequest extends HttpRequest
{
- public HttpGETRequest(String url)
- {
- super(url,"GET");
- }
+ public HttpGETRequest(String url)
+ {
+ super(url, "GET");
+ }
- @Override
- public HttpGETRequest addParameter(String name, byte[] value, String encoding)
- {
- appendParameter(query(), query().length() == 0, name, value);
- return this;
- }
+ @Override
+ public HttpGETRequest addParameter(String name, byte[] value,
+ String encoding)
+ {
+ appendParameter(query(), query().length() == 0, name, value);
+ return this;
+ }
}
import java.io.OutputStreamWriter;
import java.io.Writer;
-public class HttpPOSTRequest
- extends HttpRequest
+public class HttpPOSTRequest extends HttpRequest
{
- boolean multipart_ = false;
- static final String separator_ =
- "----MultiPartFormData--MultiPartFormData--MultiPartFormData----";
-
- public HttpPOSTRequest(String url)
- {
- super(url, "POST");
- setContentType("application/x-www-form-urlencoded; charset=utf-8");
- }
-
- public HttpPOSTRequest setMultipart(boolean flag)
- {
- multipart_ = flag;
- if (multipart_) {
- setContentType("multipart/form-data; boundary=" + separator_);
- try {
- OutputStream body = body();
- body.write("--".getBytes());
- body.write(separator_.getBytes());
- body.write("\r\n".getBytes());
- }
- catch (IOException e) {
- throw new AssertionError("ByteArrayOutputStream throwing IOExcpetion");
- }
- }
- return this;
- }
-
- @Override
- public HttpRequest addParameter(String name, byte[] value, String encoding)
- {
- try {
- if (multipart_) {
- OutputStream body = body();
- body.write("Content-Disposition: form-data; name=\"".getBytes());
- body.write(name.getBytes());
- body.write("\"\r\n".getBytes());
- body.write("Content-Type: text/plain; charset=".getBytes());
- body.write(encoding.getBytes());
- body.write("\r\n".getBytes());
- body.write(("Content-Length: " + value.length).getBytes());
- body.write("\r\n\r\n".getBytes());
- body.write(value);
- body.write("\r\n--".getBytes());
- body.write(separator_.getBytes());
- body.write("\r\n".getBytes());
- }
- else {
- // Encoding not really relevant here since url-encoding is plain ASCII
- Writer writer = new OutputStreamWriter(body(),"ascii");
- appendParameter(writer, body().size() == 0, name, value);
- writer.flush();
- }
- }
- catch (IOException e) {
- throw new AssertionError("ByteArrayOutputStream throwing IOExcpetion");
- }
- return this;
- }
+ boolean multipart_ = false;
+ static final String separator_ = "----MultiPartFormData--MultiPartFormData--MultiPartFormData----";
+
+ public HttpPOSTRequest(String url)
+ {
+ super(url, "POST");
+ setContentType("application/x-www-form-urlencoded; charset=utf-8");
+ }
+
+ public HttpPOSTRequest setMultipart(boolean flag)
+ {
+ multipart_ = flag;
+ if (multipart_) {
+ setContentType("multipart/form-data; boundary=" + separator_);
+ try {
+ OutputStream body = body();
+ body.write("--".getBytes());
+ body.write(separator_.getBytes());
+ body.write("\r\n".getBytes());
+ }
+ catch (IOException e) {
+ throw new AssertionError(
+ "ByteArrayOutputStream throwing IOExcpetion");
+ }
+ }
+ return this;
+ }
+
+ @Override
+ public HttpRequest addParameter(String name, byte[] value, String encoding)
+ {
+ try {
+ if (multipart_) {
+ OutputStream body = body();
+ body.write("Content-Disposition: form-data; name=\"".getBytes());
+ body.write(name.getBytes());
+ body.write("\"\r\n".getBytes());
+ body.write("Content-Type: text/plain; charset=".getBytes());
+ body.write(encoding.getBytes());
+ body.write("\r\n".getBytes());
+ body.write(("Content-Length: " + value.length).getBytes());
+ body.write("\r\n\r\n".getBytes());
+ body.write(value);
+ body.write("\r\n--".getBytes());
+ body.write(separator_.getBytes());
+ body.write("\r\n".getBytes());
+ }
+ else {
+ // Encoding not really relevant here since url-encoding is plain
+ // ASCII
+ Writer writer = new OutputStreamWriter(body(), "ascii");
+ appendParameter(writer, body().size() == 0, name, value);
+ writer.flush();
+ }
+ }
+ catch (IOException e) {
+ throw new AssertionError(
+ "ByteArrayOutputStream throwing IOExcpetion");
+ }
+ return this;
+ }
}
public abstract class HttpRequest
{
- StringBuffer url_;
- StringBuffer query_ = new StringBuffer();
- String method_;
- ByteArrayOutputStream body_ = new ByteArrayOutputStream();
- String contentType_;
-
- public HttpRequest(String url, String method)
- {
- url_ = new StringBuffer(url);
- method_ = method;
- }
+ StringBuffer url_;
+ StringBuffer query_ = new StringBuffer();
+ String method_;
+ ByteArrayOutputStream body_ = new ByteArrayOutputStream();
+ String contentType_;
- protected StringBuffer query()
- {
- return query_;
- }
-
- protected ByteArrayOutputStream body()
- {
- return body_;
- }
-
- protected void setContentType(String c)
- {
- contentType_ = c;
- }
-
- protected static void appendParameter(Appendable buffer, boolean first, String name, byte[] value)
- {
- try {
- if (! first)
- buffer.append("&");
- buffer.append(URLEncoder.encode(name,"utf-8"));
- buffer.append("=");
- // We really would need a URLEncoder for byte[] (pre-encoded or raw date)
- buffer.append(URLEncoder.encode(new String(value,"ascii"),"ascii"));
- }
- catch (UnsupportedEncodingException e)
- {
- throw new AssertionError("Missing encoding");
- }
- catch (IOException e)
- {
- throw new AssertionError("IOException on buffer-based Appendable");
- }
- }
-
- public HttpResponse execute()
- throws MalformedURLException, IOException
- {
- if (query_.length() > 0)
- url_.append("?");
- url_.append(query_);
- HttpURLConnection connection =
- (HttpURLConnection) new URL(new String(url_)).openConnection();
- connection.setRequestMethod(method_);
- if (contentType_ != null) {
- connection.setRequestProperty("Content-Type", contentType_);
- connection.setDoOutput(true);
- connection.setFixedLengthStreamingMode(body_.size());
- connection.getOutputStream().write(body_.toByteArray());
- }
- if (connection.getResponseCode() != HttpURLConnection.HTTP_OK)
- throw new IOException("HTTP request failed: "
- + connection.getResponseCode() + " " + connection.getResponseMessage());
- return new HttpResponse(connection);
- }
-
- public HttpRequest addParameter(String name, String value)
- throws UnsupportedEncodingException
- {
- return addParameter(name, value, "utf-8");
- }
-
- public HttpRequest addParameter(String name, String value, String encoding)
- throws UnsupportedEncodingException
- {
- return addParameter(name, value.getBytes(encoding), encoding);
- }
-
- abstract public HttpRequest addParameter(String name, byte[] value, String encoding);
+ public HttpRequest(String url, String method)
+ {
+ url_ = new StringBuffer(url);
+ method_ = method;
+ }
+
+ protected StringBuffer query()
+ {
+ return query_;
+ }
+
+ protected ByteArrayOutputStream body()
+ {
+ return body_;
+ }
+
+ protected void setContentType(String c)
+ {
+ contentType_ = c;
+ }
+
+ protected static void appendParameter(Appendable buffer, boolean first,
+ String name, byte[] value)
+ {
+ try {
+ if (!first) buffer.append("&");
+ buffer.append(URLEncoder.encode(name, "utf-8"));
+ buffer.append("=");
+ // We really would need a URLEncoder for byte[] (pre-encoded or raw
+ // date)
+ buffer.append(URLEncoder
+ .encode(new String(value, "ascii"), "ascii"));
+ }
+ catch (UnsupportedEncodingException e) {
+ throw new AssertionError("Missing encoding");
+ }
+ catch (IOException e) {
+ throw new AssertionError("IOException on buffer-based Appendable");
+ }
+ }
+
+ public HttpResponse execute() throws MalformedURLException, IOException
+ {
+ if (query_.length() > 0) url_.append("?");
+ url_.append(query_);
+ HttpURLConnection connection = (HttpURLConnection) new URL(new String(
+ url_)).openConnection();
+ connection.setRequestMethod(method_);
+ if (contentType_ != null) {
+ connection.setRequestProperty("Content-Type", contentType_);
+ connection.setDoOutput(true);
+ connection.setFixedLengthStreamingMode(body_.size());
+ connection.getOutputStream().write(body_.toByteArray());
+ }
+ if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) throw new IOException(
+ "HTTP request failed: " + connection.getResponseCode() + " "
+ + connection.getResponseMessage());
+ return new HttpResponse(connection);
+ }
+
+ public HttpRequest addParameter(String name, String value)
+ throws UnsupportedEncodingException
+ {
+ return addParameter(name, value, "utf-8");
+ }
+
+ public HttpRequest addParameter(String name, String value, String encoding)
+ throws UnsupportedEncodingException
+ {
+ return addParameter(name, value.getBytes(encoding), encoding);
+ }
+
+ abstract public HttpRequest addParameter(String name, byte[] value,
+ String encoding);
}
import java.io.InputStream;
import java.net.HttpURLConnection;
-public class HttpResponse
- extends InputStream
+public class HttpResponse extends InputStream
{
- HttpURLConnection connection_;
- InputStream stream_;
-
- public HttpResponse(HttpURLConnection connection)
- throws IOException
- {
- connection_ = connection;
- stream_ = connection_.getInputStream();
- }
-
- @Override
- public int read()
- throws IOException
- {
- return stream_.read();
- }
+ HttpURLConnection connection_;
+ InputStream stream_;
+
+ public HttpResponse(HttpURLConnection connection) throws IOException
+ {
+ connection_ = connection;
+ stream_ = connection_.getInputStream();
+ }
+
+ @Override
+ public int read() throws IOException
+ {
+ return stream_.read();
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ stream_.close();
+ }
- @Override
- public void close()
- throws IOException
- {
- stream_.close();
- }
-
}
import de.j32.pimstuff.data.Addressbook;
import de.j32.util.Util;
-public class Main {
+public class Main
+{
- public static void main(String[] args)
- {
- try {
- Addressbook ab = new Addressbook();
- Conduit conduit = Registry.get("fritzbox");
+ public static void main(String[] args)
+ {
+ try {
+ Addressbook ab = new Addressbook();
+ Conduit conduit = Registry.get("fritzbox");
- Importer i = null;
- try {
- i = conduit.importer();
- i.sendTo(ab);
- i.close();
- i = null;
- }
- finally {
- Util.nothrowClose(i);
- }
-
- Exporter e = null;
- try {
- e = conduit.exporter();
- ab.sendTo(e);
- e.close();
- e = null;
- }
- finally {
- Util.nothrowClose(e);
- }
- }
- catch (ConduitException e) {
- e.printStackTrace();
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- }
+ Importer i = null;
+ try {
+ i = conduit.importer();
+ i.sendTo(ab);
+ i.close();
+ i = null;
+ }
+ finally {
+ Util.nothrowClose(i);
+ }
+
+ Exporter e = null;
+ try {
+ e = conduit.exporter();
+ ab.sendTo(e);
+ e.close();
+ e = null;
+ }
+ finally {
+ Util.nothrowClose(e);
+ }
+ }
+ catch (ConduitException e) {
+ e.printStackTrace();
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}
public interface Conduit
{
- public Exporter exporter() throws ConduitException;
- public Importer importer() throws ConduitException;
+ public Exporter exporter() throws ConduitException;
+
+ public Importer importer() throws ConduitException;
}
package de.j32.pimstuff.conduit;
-public class ConduitException
- extends Exception
+public class ConduitException extends Exception
{
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- public ConduitException()
- {}
-
- public ConduitException(String message)
- {
- super(message);
- }
-
- public ConduitException(Exception e)
- {
- super(e);
- }
+ public ConduitException()
+ {}
+
+ public ConduitException(String message)
+ {
+ super(message);
+ }
+
+ public ConduitException(Exception e)
+ {
+ super(e);
+ }
}
public class Config
{
- static Config instance;
- Properties config = new Properties();
-
- public static String get(String key, String defaultValue)
- {
- load();
-
- if (instance == null)
- return defaultValue;
- else {
- String rv = instance.config.getProperty(key);
- if (rv == null)
- return defaultValue;
- return rv;
- }
- }
-
- public static String get(String key)
- {
- String rv = get(key, null);
- if (rv == null)
- throw new ConfigurationException("missing configuration parameter: " + key);
- return rv;
- }
-
- static void load()
- {
- if (instance == null)
- try {
- instance = new Config();
- }
- catch (InvalidPropertiesFormatException e) {}
- catch (FileNotFoundException e) {}
- catch (IOException e) {}
- }
-
- Config()
- throws InvalidPropertiesFormatException, FileNotFoundException, IOException
- {
- config.loadFromXML(new FileInputStream("config.xml"));
- }
-
+ static Config instance;
+ Properties config = new Properties();
+
+ public static String get(String key, String defaultValue)
+ {
+ load();
+
+ if (instance == null) return defaultValue;
+ else {
+ String rv = instance.config.getProperty(key);
+ if (rv == null) return defaultValue;
+ return rv;
+ }
+ }
+
+ public static String get(String key)
+ {
+ String rv = get(key, null);
+ if (rv == null) throw new ConfigurationException(
+ "missing configuration parameter: " + key);
+ return rv;
+ }
+
+ static void load()
+ {
+ if (instance == null) try {
+ instance = new Config();
+ }
+ catch (InvalidPropertiesFormatException e) {}
+ catch (FileNotFoundException e) {}
+ catch (IOException e) {}
+ }
+
+ Config() throws InvalidPropertiesFormatException, FileNotFoundException,
+ IOException
+ {
+ config.loadFromXML(new FileInputStream("config.xml"));
+ }
+
}
package de.j32.pimstuff.conduit;
-public class ConfigurationException
- extends RuntimeException
+public class ConfigurationException extends RuntimeException
{
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- public ConfigurationException(String msg)
- {
- super(msg);
- }
+ public ConfigurationException(String msg)
+ {
+ super(msg);
+ }
}
import de.j32.pimstuff.data.EntryConsumer;
-public interface Exporter
- extends Closeable, EntryConsumer
+public interface Exporter extends Closeable, EntryConsumer
{}
package de.j32.pimstuff.conduit;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import org.xml.sax.SAXException;
import de.j32.avmfritz.FritzBox;
+import de.j32.util.Util;
-public class FritzAddressbookConduit
- implements Conduit
+public class FritzAddressbookConduit implements Conduit
{
- FritzBox fb_;
-
- public FritzAddressbookConduit()
- throws ConduitException
- {
- try {
- fb_ = new FritzBox(
- Config.get("fritzbox-password"),
- Config.get("fritzbox-url","http://fritz.box"));
- } catch (SAXException e) {
- throw new ConduitException(e);
- } catch (IOException e) {
- throw new ConduitException(e);
- }
- }
+ FritzBox fb_;
- @Override
- public Exporter exporter()
- throws ConduitException
- {
- try {
- return new FritzAddressbookExporter(fb_.importAddressbook());
- }
- catch (IOException e) {
- throw new ConduitException(e);
- }
- }
+ public FritzAddressbookConduit() throws ConduitException
+ {
+ try {
+ fb_ = new FritzBox(Config.get("fritzbox-password"), Config.get(
+ "fritzbox-url", "http://fritz.box"));
+ }
+ catch (SAXException e) {
+ throw new ConduitException(e);
+ }
+ catch (IOException e) {
+ throw new ConduitException(e);
+ }
+ }
- @Override
- public Importer importer()
- throws ConduitException
- {
- try {
- return new FritzAddressbookImporter(fb_.exportAddressbook());
- }
- catch (IOException e) {
- throw new ConduitException(e);
- } catch (SAXException e) {
- throw new ConduitException(e);
- }
- }
+ @Override
+ public Exporter exporter() throws ConduitException
+ {
+ OutputStream os = null;
+ FritzAddressbookExporter exporter = null;
+ try {
+ os = fb_.importAddressbook();
+ exporter = new FritzAddressbookExporter(os);
+ }
+ catch (IOException e) {
+ throw new ConduitException(e);
+ }
+ finally {
+ if (exporter == null) Util.nothrowClose(os);
+ }
+ return exporter;
+ }
+
+ @Override
+ public Importer importer() throws ConduitException
+ {
+ InputStream is = null;
+ FritzAddressbookImporter importer = null;
+ try {
+ is = fb_.exportAddressbook();
+ importer = new FritzAddressbookImporter(is);
+ }
+ catch (IOException e) {
+ throw new ConduitException(e);
+ }
+ catch (SAXException e) {
+ throw new ConduitException(e);
+ }
+ finally {
+ if (importer == null) Util.nothrowClose(is);
+ }
+ return importer;
+ }
}
import de.j32.util.SimpleXmlGenerator;
import de.j32.util.Util;
-public class FritzAddressbookExporter
- implements Exporter
+public class FritzAddressbookExporter implements Exporter
{
- OutputStream os_;
- SimpleXmlGenerator gen_;
-
- public FritzAddressbookExporter(OutputStream os)
- {
- try {
- os_ = os;
- gen_ = new SimpleXmlGenerator(os_, "iso-8859-1");
- gen_.startDocument(); gen_.nl();
- gen_.start("phonebooks"); gen_.nl();
- gen_.start("phonebook"); gen_.nl();
- }
- catch (SAXException e) {
- throw new AssertionError("Invalid XML/SAX document generated.");
- }
- catch (UnsupportedEncodingException e) {
- throw new AssertionError("Unsopported encoding iso-8859-1 ??");
- }
- finally {
- Util.nothrowClose(os);
- }
- }
+ OutputStream os_;
+ SimpleXmlGenerator gen_;
- @Override
- public void consume(Entry entry)
- {
- try {
- gen_.start("contact"); gen_.nl();
+ /**
+ * Write Addressbook to Fritzbox XML stream
+ *
+ * @param os
+ * OutputStrea to which the XML data is sent.
+ * <em>After successful</em> construction, the class takes
+ * responsibility for closing the streanm.
+ */
+ public FritzAddressbookExporter(OutputStream os)
+ {
+ try {
+ os_ = os;
+ gen_ = new SimpleXmlGenerator(os_, "iso-8859-1");
+ gen_.startDocument();
+ gen_.nl();
+ gen_.start("phonebooks");
+ gen_.nl();
+ gen_.start("phonebook");
+ gen_.nl();
+ }
+ catch (SAXException e) {
+ throw new AssertionError("Invalid XML/SAX document generated.");
+ }
+ catch (UnsupportedEncodingException e) {
+ throw new AssertionError("Unsopported encoding iso-8859-1 ??");
+ }
+ }
- gen_.start("category"); gen_.text("0"); gen_.end(); gen_.nl();
-
- gen_.start("person"); gen_.nl();
- gen_.start("realName"); gen_.text(entry.name()); gen_.end(); gen_.nl();
- gen_.empty("imageURL"); gen_.nl();
- gen_.end(); gen_.nl();
-
- gen_.start("telephony"); gen_.nl();
- for (Attribute number : entry.attributes("phone")) {
- gen_.start("number",
- gen_.attribute("prio", number.index > 0 ? "0" : "1")
- .attribute("type", number.rel)
- .attribute("vanity", ""));
- gen_.text(number.value); gen_.end(); gen_.nl();
- }
- gen_.end(); gen_.nl();
-
- Attribute email = Util.first(entry.attributes("email"));
- if (email != null) {
- gen_.start("services"); gen_.nl();
- gen_.start("email", gen_.attribute("classifier","private"));
- gen_.text(email.value); gen_.end(); gen_.nl();
- gen_.end(); gen_.nl();
- }
- else {
- gen_.empty("services"); gen_.nl();
- }
-
- gen_.end(); gen_.nl();
- }
- catch (SAXException e)
- {
- throw new AssertionError("Invalid XML/SAX document generated.");
- }
- }
+ @Override
+ public void consume(Entry entry)
+ {
+ try {
+ gen_.start("contact");
+ gen_.nl();
+
+ gen_.start("category");
+ gen_.text("0");
+ gen_.end();
+ gen_.nl();
+
+ gen_.start("person");
+ gen_.nl();
+ gen_.start("realName");
+ gen_.text(entry.name());
+ gen_.end();
+ gen_.nl();
+ gen_.empty("imageURL");
+ gen_.nl();
+ gen_.end();
+ gen_.nl();
+
+ gen_.start("telephony");
+ gen_.nl();
+ for (Attribute number : entry.attributes("phone")) {
+ gen_.start(
+ "number",
+ gen_.attribute("prio", number.index > 0 ? "0" : "1")
+ .attribute("type", number.rel)
+ .attribute("vanity", ""));
+ gen_.text(number.value);
+ gen_.end();
+ gen_.nl();
+ }
+ gen_.end();
+ gen_.nl();
+
+ Attribute email = Util.first(entry.attributes("email"));
+ if (email != null) {
+ gen_.start("services");
+ gen_.nl();
+ gen_.start("email", gen_.attribute("classifier", "private"));
+ gen_.text(email.value);
+ gen_.end();
+ gen_.nl();
+ gen_.end();
+ gen_.nl();
+ }
+ else {
+ gen_.empty("services");
+ gen_.nl();
+ }
+
+ gen_.end();
+ gen_.nl();
+ }
+ catch (SAXException e) {
+ throw new AssertionError("Invalid XML/SAX document generated.");
+ }
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ try {
+ gen_.end();
+ gen_.nl();
+ gen_.end();
+ gen_.endDocument();
+ os_.close();
+ os_ = null;
+ }
+ catch (SAXException e) {
+ throw new AssertionError("Invalid XML/SAX document generated.");
+ }
+ finally {
+ Util.nothrowClose(os_);
+ }
+ }
- @Override
- public void close()
- throws IOException
- {
- try {
- gen_.end(); gen_.nl();
- gen_.end();
- gen_.endDocument();
- os_.close();
- os_ = null;
- }
- catch (SAXException e)
- {
- throw new AssertionError("Invalid XML/SAX document generated.");
- }
- finally
- {
- Util.nothrowClose(os_);
- }
- }
-
}
import de.j32.pimstuff.data.Entry;
import de.j32.pimstuff.data.EntryConsumer;
-import de.j32.util.Util;
import de.j32.util.XmlUtil;
-public class FritzAddressbookImporter
- implements Importer
+public class FritzAddressbookImporter implements Importer
{
- Document xml_;
-
- public FritzAddressbookImporter(InputStream is)
- throws SAXException, IOException
- {
- try {
- xml_ = XmlUtil.parse(is);
- is.close();
- is = null;
- }
- finally {
- Util.nothrowClose(is);
- }
- }
-
- @Override
- public void sendTo(EntryConsumer consumer)
- {
- for (Element node : XmlUtil.iterate(xml_.getElementsByTagName("contact"),Element.class)) {
- /* subnodes:
- * category (unused, always 0)
- * person/realName
- * person/imageURL
- * telephony/number (@prio, @type, @vanity)
- * services/email
- * mod_time
- */
- Entry entry = new Entry();
+ Document xml_;
- try {
- entry.name(node.getElementsByTagName("realName").item(0).getTextContent());
+ /**
+ * Importer reading Addressbook from Fritzbox XML file
+ *
+ * @param is InputStream providing the XML data. <em>After successful</em>
+ * construction, the class takes responsibility for closing the
+ * stream.
+ * @throws SAXException
+ * @throws IOException
+ */
+ public FritzAddressbookImporter(InputStream is) throws SAXException,
+ IOException
+ {
+ // It does not make sens to try / finally here, at least conceptually:
+ // Since
+ // the base-class constructor might throw we would never get a chance to
+ // properly close is. Thus I deem it safer to only take responsibility
+ // for is
+ // when the constructor does NOT throw and place the try / finally into
+ // the
+ // callers code.
+ xml_ = XmlUtil.parse(is);
+ is.close();
+ }
- for (Element phone : XmlUtil.iterate(node.getElementsByTagName("number"),Element.class)) {
- entry.attribute("phone", phone.getAttribute("type"), phone.getTextContent());
- }
-
- try {
- entry.attribute("email", "",
- node.getElementsByTagName("email").item(0).getTextContent());
- }
- catch (NullPointerException e) {} // ignore missing optional email
- }
- catch (NullPointerException e) {
- // Ignore incomplete entries
- entry = null;
- }
+ @Override
+ public void sendTo(EntryConsumer consumer)
+ {
+ for (Element node : XmlUtil.iterate(
+ xml_.getElementsByTagName("contact"), Element.class)) {
+ /*
+ * subnodes: category (unused, always 0) person/realName
+ * person/imageURL telephony/number (@prio, @type, @vanity)
+ * services/email mod_time
+ */
+ Entry entry = new Entry();
- if (entry != null)
- consumer.consume(entry);
- }
- }
+ try {
+ entry.name(node.getElementsByTagName("realName").item(0)
+ .getTextContent());
+
+ for (Element phone : XmlUtil.iterate(
+ node.getElementsByTagName("number"), Element.class)) {
+ entry.attribute("phone", phone.getAttribute("type"),
+ phone.getTextContent());
+ }
+
+ try {
+ entry.attribute("email", "",
+ node.getElementsByTagName("email").item(0)
+ .getTextContent());
+ }
+ catch (NullPointerException e) {} // ignore missing optional
+ // email
+ }
+ catch (NullPointerException e) {
+ // Ignore incomplete entries
+ entry = null;
+ }
+
+ if (entry != null) consumer.consume(entry);
+ }
+ }
+
+ @Override
+ public void close() throws IOException
+ {}
- @Override
- public void close()
- throws IOException
- {}
-
}
import de.j32.pimstuff.data.EntryProducer;
-public interface Importer
- extends Closeable, EntryProducer
+public interface Importer extends Closeable, EntryProducer
{}
public class Registry
{
- static ApplicationContext context_ = new FileSystemXmlApplicationContext("conduits.xml");
-
- public static Conduit get(String k)
- {
- return context_.getBean(k, Conduit.class);
- }
-
+ static ApplicationContext context_ = new FileSystemXmlApplicationContext(
+ "conduits.xml");
+
+ public static Conduit get(String k)
+ {
+ return context_.getBean(k, Conduit.class);
+ }
+
}
import java.util.Iterator;
import java.util.LinkedList;
-public class Addressbook
- implements EntryConsumer, EntryProducer
+public class Addressbook implements EntryConsumer, EntryProducer
{
- LinkedList<Entry> data_ = new LinkedList<Entry>();
-
- public void add(Entry entry)
- {
- data_.add(entry);
- }
-
- public Iterator<Entry> entries()
- {
- return data_.iterator();
- }
-
- public void consume(Entry entry)
- {
- add(entry);
- }
-
- public void sendTo(EntryConsumer consumer)
- {
- for (Entry entry : data_)
- consumer.consume(entry);
- }
+ LinkedList<Entry> data_ = new LinkedList<Entry>();
+
+ public void add(Entry entry)
+ {
+ data_.add(entry);
+ }
+
+ public Iterator<Entry> entries()
+ {
+ return data_.iterator();
+ }
+
+ public void consume(Entry entry)
+ {
+ add(entry);
+ }
+
+ public void sendTo(EntryConsumer consumer)
+ {
+ for (Entry entry : data_)
+ consumer.consume(entry);
+ }
}
public class Attribute
{
- public String type;
- public String rel;
- public String value;
- public int index;
-
- public Attribute(String type_, String rel_, String value_, int index_)
- {
- type = type_;
- rel = rel_;
- value = value_;
- index = index_;
- }
+ public String type;
+ public String rel;
+ public String value;
+ public int index;
+
+ public Attribute(String type_, String rel_, String value_, int index_)
+ {
+ type = type_;
+ rel = rel_;
+ value = value_;
+ index = index_;
+ }
}
public class Entry
{
- long id_ = 0;
- String name_ = "";
- ArrayList<Attribute> attributes_ = new ArrayList<Attribute>();
+ long id_ = 0;
+ String name_ = "";
+ ArrayList<Attribute> attributes_ = new ArrayList<Attribute>();
- public void name(String name)
- {
- name_ = name;
- }
-
- public String name()
- {
- return name_;
- }
-
- public void id(long id)
- {
- id_ = id;
- }
-
- public long id()
- {
- return id_;
- }
-
- public void attribute(String type, String rel, String value)
- {
- attributes_.add(new Attribute(type, rel, value,attributes_.size()));
- }
+ public void name(String name)
+ {
+ name_ = name;
+ }
- public Iterable<Attribute> attributes()
- {
- return attributes_;
- }
-
- public Iterable<Attribute> attributes(final String type)
- {
- return new Iterable<Attribute>() {
- public Iterator<Attribute> iterator() {
- return new FilteredIterator<Attribute>(
- attributes_.iterator(),
- new Filter<Attribute>() {
- public boolean match(Attribute element) {
- return element.type == type;
- }
- });
- }
- };
- }
-
- public Iterable<Attribute> attributes(final String type, final String rel)
- {
- return new Iterable<Attribute>() {
- public Iterator<Attribute> iterator() {
- return new FilteredIterator<Attribute>(
- attributes_.iterator(),
- new Filter<Attribute>() {
- public boolean match(Attribute element) {
- return element.type == type && element.rel == rel;
- }
- });
- }
- };
- }
+ public String name()
+ {
+ return name_;
+ }
+
+ public void id(long id)
+ {
+ id_ = id;
+ }
+
+ public long id()
+ {
+ return id_;
+ }
+
+ public void attribute(String type, String rel, String value)
+ {
+ attributes_.add(new Attribute(type, rel, value, attributes_.size()));
+ }
+
+ public Iterable<Attribute> attributes()
+ {
+ return attributes_;
+ }
+
+ public Iterable<Attribute> attributes(final String type)
+ {
+ return new Iterable<Attribute>() {
+ public Iterator<Attribute> iterator()
+ {
+ return new FilteredIterator<Attribute>(attributes_.iterator(),
+ new Filter<Attribute>() {
+ public boolean match(Attribute element)
+ {
+ return element.type == type;
+ }
+ });
+ }
+ };
+ }
+
+ public Iterable<Attribute> attributes(final String type, final String rel)
+ {
+ return new Iterable<Attribute>() {
+ public Iterator<Attribute> iterator()
+ {
+ return new FilteredIterator<Attribute>(attributes_.iterator(),
+ new Filter<Attribute>() {
+ public boolean match(Attribute element)
+ {
+ return element.type == type
+ && element.rel == rel;
+ }
+ });
+ }
+ };
+ }
}
public interface EntryConsumer
{
- public void consume(Entry entry);
+ public void consume(Entry entry);
}
public interface EntryProducer
{
- public void sendTo(EntryConsumer consumer);
+ public void sendTo(EntryConsumer consumer);
}
public interface Filter<E>
{
- public boolean match(E element);
+ public boolean match(E element);
}
import java.util.Iterator;
import java.util.NoSuchElementException;
-
-public class FilteredIterator<E>
- implements Iterator<E>
+public class FilteredIterator<E> implements Iterator<E>
{
- Iterator<E> base_;
- Filter<E> filter_;
- E next_;
- boolean hasNext_ = true;
-
- public FilteredIterator(Iterator<E> base, Filter<E> filter)
- {
- base_ = base;
- filter_ = filter;
- advance();
- }
-
- public E next()
- {
- if (hasNext_) {
- E rv = next_;
- advance();
- return rv;
- }
- else
- throw new NoSuchElementException();
- }
-
- public boolean hasNext()
- {
- return hasNext_;
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
-
- void advance()
- {
- while (base_.hasNext()) {
- next_ = base_.next();
- if (filter_.match(next_))
- return;
- }
- hasNext_ = false;
- next_ = null;
- }
+ Iterator<E> base_;
+ Filter<E> filter_;
+ E next_;
+ boolean hasNext_ = true;
+
+ public FilteredIterator(Iterator<E> base, Filter<E> filter)
+ {
+ base_ = base;
+ filter_ = filter;
+ advance();
+ }
+
+ public E next()
+ {
+ if (hasNext_) {
+ E rv = next_;
+ advance();
+ return rv;
+ }
+ else throw new NoSuchElementException();
+ }
+
+ public boolean hasNext()
+ {
+ return hasNext_;
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ void advance()
+ {
+ while (base_.hasNext()) {
+ next_ = base_.next();
+ if (filter_.match(next_)) return;
+ }
+ hasNext_ = false;
+ next_ = null;
+ }
}
public class SimpleXmlGenerator
{
- TransformerHandler handler_;
- Stack<String> openElements_ = new Stack<String>();
-
- public SimpleXmlGenerator(OutputStream os, String encoding)
- throws UnsupportedEncodingException
- {
- SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
- // factory.setAttribute("indent-number", new Integer(2));
- try {
- handler_ = factory.newTransformerHandler();
- }
- catch (TransformerConfigurationException e) {
- throw new AssertionError("XML/SAX transformer configuration error");
- }
- catch (TransformerFactoryConfigurationError e) {
- throw new AssertionError("XML/SAX transformer factory configuration error");
- }
- Transformer tf = handler_.getTransformer();
- tf.setOutputProperty(OutputKeys.ENCODING,encoding);
- // if (doctype != null)
- // tf.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,doctype);
- // tf.setOutputProperty(OutputKeys.INDENT,indent ? "yes" : "no");
- handler_.setResult(new StreamResult(new OutputStreamWriter(os, encoding)));
- }
-
- public void startDocument()
- throws SAXException
- {
- handler_.startDocument();
- }
-
- public void start(String name)
- throws SAXException
- {
- handler_.startElement("","",name,null);
- openElements_.add(name);
- }
-
- public static class Attributes
- {
- AttributesImpl attributes_ = new AttributesImpl();
-
- public Attributes attribute(String name, String value)
- {
- attributes_.addAttribute("","",name,"CDATA",value);
- return this;
- }
-
- AttributesImpl getAttributes()
- {
- return attributes_;
- }
-
- Attributes() {}
- }
-
- public Attributes attribute(String name, String value)
- {
- Attributes a = new Attributes();
- return a.attribute(name, value);
- }
-
- public void start(String name, Attributes attrs)
- throws SAXException
- {
- handler_.startElement("","",name, attrs.getAttributes());
- openElements_.push(name);
- }
-
- public void end()
- throws SAXException
- {
- handler_.endElement("","",openElements_.pop());
- }
-
- public void empty(String name)
- throws SAXException
- {
- start(name);
- end();
- }
-
- public void empty(String name, Attributes attrs)
- throws SAXException
- {
- start(name, attrs);
- end();
- }
-
- public void text(String text)
- throws SAXException
- {
- handler_.characters(text.toCharArray(), 0, text.length());
- }
-
- public void nl()
- throws SAXException
- {
- text("\n");
- }
-
- public void endDocument()
- throws SAXException
- {
- handler_.endDocument();
- }
+ TransformerHandler handler_;
+ Stack<String> openElements_ = new Stack<String>();
+
+ public SimpleXmlGenerator(OutputStream os, String encoding)
+ throws UnsupportedEncodingException
+ {
+ SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory
+ .newInstance();
+ // factory.setAttribute("indent-number", new Integer(2));
+ try {
+ handler_ = factory.newTransformerHandler();
+ }
+ catch (TransformerConfigurationException e) {
+ throw new AssertionError("XML/SAX transformer configuration error");
+ }
+ catch (TransformerFactoryConfigurationError e) {
+ throw new AssertionError(
+ "XML/SAX transformer factory configuration error");
+ }
+ Transformer tf = handler_.getTransformer();
+ tf.setOutputProperty(OutputKeys.ENCODING, encoding);
+ // if (doctype != null)
+ // tf.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,doctype);
+ // tf.setOutputProperty(OutputKeys.INDENT,indent ? "yes" : "no");
+ handler_.setResult(new StreamResult(
+ new OutputStreamWriter(os, encoding)));
+ }
+
+ public void startDocument() throws SAXException
+ {
+ handler_.startDocument();
+ }
+
+ public void start(String name) throws SAXException
+ {
+ handler_.startElement("", "", name, null);
+ openElements_.add(name);
+ }
+
+ public static class Attributes
+ {
+ AttributesImpl attributes_ = new AttributesImpl();
+
+ public Attributes attribute(String name, String value)
+ {
+ attributes_.addAttribute("", "", name, "CDATA", value);
+ return this;
+ }
+
+ AttributesImpl getAttributes()
+ {
+ return attributes_;
+ }
+
+ Attributes()
+ {}
+ }
+
+ public Attributes attribute(String name, String value)
+ {
+ Attributes a = new Attributes();
+ return a.attribute(name, value);
+ }
+
+ public void start(String name, Attributes attrs) throws SAXException
+ {
+ handler_.startElement("", "", name, attrs.getAttributes());
+ openElements_.push(name);
+ }
+
+ public void end() throws SAXException
+ {
+ handler_.endElement("", "", openElements_.pop());
+ }
+
+ public void empty(String name) throws SAXException
+ {
+ start(name);
+ end();
+ }
+
+ public void empty(String name, Attributes attrs) throws SAXException
+ {
+ start(name, attrs);
+ end();
+ }
+
+ public void text(String text) throws SAXException
+ {
+ handler_.characters(text.toCharArray(), 0, text.length());
+ }
+
+ public void nl() throws SAXException
+ {
+ text("\n");
+ }
+
+ public void endDocument() throws SAXException
+ {
+ handler_.endDocument();
+ }
}
import java.io.OutputStream;
import java.util.Iterator;
-public class Util {
+public class Util
+{
- public static <E> E nonnull(E ob)
- {
- if (ob == null)
- throw new NullPointerException();
- return ob;
- }
+ public static <E> E nonnull(E ob)
+ {
+ if (ob == null) throw new NullPointerException();
+ return ob;
+ }
- public static void transfer(InputStream is, OutputStream os)
- throws IOException
- {
- byte[] buffer = new byte[16384];
- int len = -1;
- while ((len = is.read(buffer)) != -1)
- os.write(buffer, 0, len);
- }
+ public static void transfer(InputStream is, OutputStream os)
+ throws IOException
+ {
+ byte[] buffer = new byte[16384];
+ int len = -1;
+ while ((len = is.read(buffer)) != -1)
+ os.write(buffer, 0, len);
+ }
- public static void nothrowClose(Closeable c)
- {
- if (c != null) {
- try {
- c.close();
- }
- catch (IOException e) {}
- }
- }
-
- public static <E> E first(Iterable<E> i)
- {
- Iterator<E> it = i.iterator();
- if (it.hasNext())
- return it.next();
- return null;
- }
+ public static void nothrowClose(Closeable c)
+ {
+ if (c != null) {
+ try {
+ c.close();
+ }
+ catch (IOException e) {}
+ }
+ }
+
+ public static <E> E first(Iterable<E> i)
+ {
+ Iterator<E> it = i.iterator();
+ if (it.hasNext()) return it.next();
+ return null;
+ }
}
public class XmlUtil
{
- public static Document parse(InputStream is)
- throws SAXException, IOException
- {
- try {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setValidating(false);
- factory.setExpandEntityReferences(false);
- DocumentBuilder builder = factory.newDocumentBuilder();
- builder.setEntityResolver(new EntityResolver() {
- public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException, IOException
- {
- return new InputSource(new StringReader(""));
- }});
- return builder.parse(is);
- }
- catch (ParserConfigurationException e) {
- throw new AssertionError("SAX/DOM parser configuration error");
- }
- }
-
- public static <E extends Node> Iterable<E> iterate(final NodeList nodes, final Class<E> type)
- {
- return new Iterable<E>() {
- public Iterator<E> iterator() {
- return new NodeListIterator<E>(nodes, type);
- }
- };
- }
-
- static class NodeListIterator<E extends Node>
- implements Iterator<E>
- {
- Class<E> nodeType_;
- NodeList nodes_;
- int i_ = 0;
- E next_;
-
- public NodeListIterator(NodeList nodes, Class<E> nodeType)
- {
- nodes_ = nodes;
- nodeType_ = nodeType;
- advance();
- }
-
- @Override
- public boolean hasNext()
- {
- return next_ != null;
- }
+ public static Document parse(InputStream is) throws SAXException, IOException
+ {
+ try {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setValidating(false);
+ factory.setExpandEntityReferences(false);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ builder.setEntityResolver(new EntityResolver() {
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException
+ {
+ return new InputSource(new StringReader(""));
+ }
+ });
+ return builder.parse(is);
+ }
+ catch (ParserConfigurationException e) {
+ throw new AssertionError("SAX/DOM parser configuration error");
+ }
+ }
- @Override
- public E next()
- {
- E rv = next_;
- advance();
- return rv;
- }
+ public static <E extends Node> Iterable<E> iterate(final NodeList nodes, final Class<E> type)
+ {
+ return new Iterable<E>() {
+ public Iterator<E> iterator()
+ {
+ return new NodeListIterator<E>(nodes, type);
+ }
+ };
+ }
- @Override
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
-
- @SuppressWarnings("unchecked")
- void advance()
- {
- while (i_ < nodes_.getLength()) {
- Node n = nodes_.item(i_);
- ++ i_;
- if (nodeType_.isInstance(n)) {
- next_ = (E) n;
- return;
- }
- }
- next_ = null;
- }
- }
+ static class NodeListIterator<E extends Node> implements Iterator<E>
+ {
+ Class<E> nodeType_;
+ NodeList nodes_;
+ int i_ = 0;
+ E next_;
+
+ public NodeListIterator(NodeList nodes, Class<E> nodeType)
+ {
+ nodes_ = nodes;
+ nodeType_ = nodeType;
+ advance();
+ }
+
+ @Override
+ public boolean hasNext()
+ {
+ return next_ != null;
+ }
+
+ @Override
+ public E next()
+ {
+ E rv = next_;
+ advance();
+ return rv;
+ }
+
+ @Override
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("unchecked")
+ void advance()
+ {
+ while (i_ < nodes_.getLength()) {
+ Node n = nodes_.item(i_);
+ ++i_;
+ if (nodeType_.isInstance(n)) {
+ next_ = (E) n;
+ return;
+ }
+ }
+ next_ = null;
+ }
+ }
}