Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Thienel2012-08-11 12:27:21 -0400
committerFlorian Thienel2012-08-11 12:27:21 -0400
commit331829ed0be9b15ad9a51c4647e5247ca1d28b7a (patch)
tree566387f92e2abe1cdc68051b4f66fc3697dea797
parentf9c4ec56202398307aa40ec0cbdc981d54d3a3b4 (diff)
downloadorg.eclipse.mylyn.docs.vex-331829ed0be9b15ad9a51c4647e5247ca1d28b7a.tar.gz
org.eclipse.mylyn.docs.vex-331829ed0be9b15ad9a51c4647e5247ca1d28b7a.tar.xz
org.eclipse.mylyn.docs.vex-331829ed0be9b15ad9a51c4647e5247ca1d28b7a.zip
apply project specific formatting and "clean code" conventions
Signed-off-by: Florian Thienel <florian@thienel.org>
-rw-r--r--org.eclipse.vex.core.tests/.settings/org.eclipse.jdt.core.prefs285
-rw-r--r--org.eclipse.vex.core.tests/.settings/org.eclipse.jdt.ui.prefs56
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/BatikBehaviorTest.java6
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/CssTest.java81
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/MockDisplayDevice.java12
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/MockLU.java58
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/PropertyTest.java10
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/RuleTest.java3
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/BlockElementBoxTest.java55
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DTDValidatorTest.java22
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentContentModelTest.java4
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentReaderTest.java22
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentWriterTest.java14
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/GapContentTest.java36
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/NamespaceStackTest.java9
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/NamespaceTest.java24
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/SchemaValidatorTest.java18
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/SpaceNormalizerTest.java43
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/TextWrapperTest.java41
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/FakeGraphics.java50
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/FakeImage.java4
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/ImageBoxTest.java11
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/LayoutTestSuite.java55
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/MockBoxFactory.java10
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TableLayoutTest.java461
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestBlockElementBox.java30
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestBlocksInInlines.java36
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestDocumentTextBox.java58
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestParagraphBox.java37
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestStaticTextBox.java46
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/MockHostComponent.java9
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/VexWidgetTest.java32
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/ListenerListTest.java203
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/TestResources.java6
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/VEXCoreTestPlugin.java14
-rw-r--r--org.eclipse.vex.core/.settings/org.eclipse.jdt.core.prefs303
-rw-r--r--org.eclipse.vex.core/.settings/org.eclipse.jdt.ui.prefs56
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/VEXCorePlugin.java9
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Caret.java11
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Color.java42
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/ColorResource.java5
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/DisplayDevice.java10
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/ElementName.java50
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/FontResource.java5
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/FontSpec.java21
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Graphics.java10
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Image.java1
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Insets.java21
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/IntRange.java49
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/ListenerList.java154
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Point.java13
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/QualifiedNameComparator.java2
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Rectangle.java37
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/AbstractProperty.java47
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BackgroundImageProperty.java10
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BorderSpacingProperty.java24
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BorderStyleProperty.java17
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BorderWidthProperty.java46
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/ColorProperty.java41
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/DisplayProperty.java22
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontFamilyProperty.java17
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontSizeProperty.java48
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontStyleProperty.java9
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontVariantProperty.java6
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontWeightProperty.java16
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/IProperty.java11
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/LengthProperty.java13
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/LineHeightProperty.java14
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/ListStyleTypeProperty.java21
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/PropertyDecl.java15
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/PseudoElement.java15
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/RelativeLength.java29
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/Rule.java95
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/StyleSheet.java161
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/StyleSheetReader.java357
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/Styles.java127
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/TextAlignProperty.java4
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/TextDecorationProperty.java10
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/WhiteSpaceProperty.java9
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Attribute.java15
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/CommentElement.java6
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Content.java13
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Document.java179
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentBuilder.java69
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentContentModel.java45
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentEvent.java40
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentFragment.java45
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentListener.java2
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentReader.java47
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentValidationException.java2
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentWriter.java94
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Element.java262
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/GapContent.java150
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/IWhitespacePolicy.java12
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/IWhitespacePolicyFactory.java10
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Namespace.java8
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/NamespaceStack.java17
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Node.java8
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Position.java10
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/RootElement.java15
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Text.java13
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/TextWrapper.java39
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Validator.java43
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AbstractBlockBox.java608
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AbstractBox.java206
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AbstractInlineBox.java2
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AnonymousBlockBox.java9
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BlockBox.java39
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BlockElementBox.java177
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BlockPseudoElementBox.java80
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/Box.java50
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BoxFactory.java6
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/CommentBlockElementBox.java6
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/CompositeInlineBox.java82
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/CssBoxFactory.java12
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/DocumentTextBox.java119
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/DrawableBox.java78
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/HCaret.java16
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/ImageBox.java32
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/InlineBox.java41
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/InlineElementBox.java77
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/LayoutContext.java51
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/LayoutUtils.java178
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/LineBox.java60
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/ParagraphBox.java146
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/PlaceholderBox.java72
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/RootBox.java109
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/SpaceBox.java11
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/StaticTextBox.java83
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/TableBodyBox.java45
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/TableBox.java160
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/TableCellBox.java29
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/TableRowBox.java142
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/TableRowGroupBox.java62
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/TextBox.java155
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/TextCaret.java16
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/undo/CannotRedoException.java8
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/undo/CannotUndoException.java8
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/undo/CompoundEdit.java17
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/undo/IUndoableEdit.java13
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/validator/AttributeDefinition.java49
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/validator/UnknownCMDocument.java28
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/validator/WTPVEXValidator.java169
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/CssWhitespacePolicy.java13
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/HostComponent.java13
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/IBoxFilter.java3
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/IVexWidget.java190
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/VexWidgetImpl.java354
-rw-r--r--org.eclipse.vex.docbook/.settings/org.eclipse.jdt.core.prefs303
-rw-r--r--org.eclipse.vex.docbook/.settings/org.eclipse.jdt.ui.prefs60
-rw-r--r--org.eclipse.vex.docbook/src/org/eclipse/vex/docbook/DocBookOutlineProvider.java431
-rw-r--r--org.eclipse.vex.projectplan/.settings/org.eclipse.jdt.core.prefs281
-rw-r--r--org.eclipse.vex.projectplan/.settings/org.eclipse.jdt.ui.prefs56
-rw-r--r--org.eclipse.vex.tests/.settings/org.eclipse.jdt.core.prefs293
-rw-r--r--org.eclipse.vex.tests/.settings/org.eclipse.jdt.ui.prefs56
-rw-r--r--org.eclipse.vex.tests/src/org/eclipse/vex/tests/AllTestsSuite.java5
-rw-r--r--org.eclipse.vex.ui.tests/.settings/org.eclipse.jdt.core.prefs293
-rw-r--r--org.eclipse.vex.ui.tests/.settings/org.eclipse.jdt.ui.prefs56
-rw-r--r--org.eclipse.vex.ui.tests/src/org/eclipse/vex/ui/internal/config/tests/ConfigLoaderJobTest.java17
-rw-r--r--org.eclipse.vex.ui.tests/src/org/eclipse/vex/ui/internal/config/tests/ConfigurationRegistryTest.java10
-rw-r--r--org.eclipse.vex.ui.tests/src/org/eclipse/vex/ui/internal/config/tests/PluginProjectTest.java3
-rw-r--r--org.eclipse.vex.ui.tests/src/org/eclipse/vex/ui/internal/editor/tests/FindReplaceTargetTest.java105
-rw-r--r--org.eclipse.vex.ui.tests/src/org/eclipse/vex/ui/internal/namespace/tests/EditNamespacesControllerTest.java6
-rw-r--r--org.eclipse.vex.ui.tests/src/org/eclipse/vex/ui/internal/tests/ResourceTrackerTest.java4
-rw-r--r--org.eclipse.vex.ui.tests/src/org/eclipse/vex/ui/tests/IconTest.java6
-rw-r--r--org.eclipse.vex.ui/.settings/org.eclipse.jdt.core.prefs303
-rw-r--r--org.eclipse.vex.ui/.settings/org.eclipse.jdt.ui.prefs60
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/Icon.java75
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/VexPlugin.java166
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/VexPreferences.java22
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/BuildProblem.java23
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/BuildProblemDecorator.java40
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/ConfigEvent.java4
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/ConfigItem.java62
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/ConfigLoaderJob.java15
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/ConfigPlugin.java22
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/ConfigSource.java91
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/ConfigurationElement.java52
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/ConfigurationElementWrapper.java28
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/ConfigurationRegistry.java26
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/ConfigurationRegistryImpl.java56
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/ConfigurationView.java25
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/DoctypeFactory.java12
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/DoctypePropertyPage.java47
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/DocumentType.java27
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/DomConfigurationElement.java34
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/IBuildProblemHandler.java3
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/IConfigElement.java7
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/IConfigItemFactory.java40
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/IConfigListener.java15
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/Messages.java15
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/NewPluginProjectWizard.java30
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/PluginProject.java26
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/PluginProjectBuilder.java18
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/PluginProjectDecorator.java23
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/PluginProjectNature.java18
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/Style.java10
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/StyleFactory.java10
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/config/StylePropertyPage.java25
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/AbstractRegExFindReplaceTarget.java109
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/DocumentContextSourceProvider.java179
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/DocumentFileCreationPage.java18
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/DocumentTypeSelectionDialog.java91
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/DocumentTypeSelectionPage.java121
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/IVexEditorListener.java5
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/Messages.java15
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/NoRegisteredDoctypeException.java5
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/NoStyleForDoctypeException.java4
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/PageInitializationData.java7
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/SelectionProvider.java37
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/TextInputListener.java13
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/VexActionBarContributor.java98
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/VexDocumentContentModel.java41
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/VexEditor.java98
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/VexEditorEvent.java6
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractAddColumnHandler.java95
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractAddRowHandler.java205
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractMoveColumnHandler.java183
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractMoveRowHandler.java73
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractNavigateTableCellHandler.java57
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractRemoveTableCellsHandler.java70
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AbstractVexWidgetHandler.java73
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AddColumnLeftHandler.java10
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AddColumnRightHandler.java12
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AddCommentHandler.java2
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AddElementHandler.java8
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AddRowAboveHandler.java14
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/AddRowBelowHandler.java14
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/ConvertElementHandler.java22
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/DuplicateSelectionHandler.java44
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/ITableCellCallback.java56
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/IVexWidgetHandler.java16
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/MoveColumnLeftHandler.java18
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/MoveColumnRightHandler.java18
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/MoveRowDownHandler.java20
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/MoveRowUpHandler.java22
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/MoveSelectionUpHandler.java96
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/NextTableCellHandler.java58
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/PreviousTableCellHandler.java52
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/RemoveColumnHandler.java28
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/RemoveRowHandler.java8
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/RemoveTagHandler.java83
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/SplitBlockElementHandler.java152
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/SplitItemHandler.java53
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/StyleMenu.java42
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/TableCellCallbackAdapter.java23
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/handlers/VexHandlerUtil.java1052
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/namespace/EditNamespacesController.java23
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/namespace/EditNamespacesDialog.java14
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/namespace/EditableNamespaceDefinition.java20
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/outline/DefaultOutlineProvider.java54
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/outline/DocumentOutlinePage.java181
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/outline/IOutlineProvider.java12
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/perspective/DocumentPerspective.java20
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/preferences/PreferenceInitializer.java2
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/preferences/RootPreferencePage.java10
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/property/ElementPropertySource.java100
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/swt/ContentAssist.java45
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/swt/DocumentFragmentTransfer.java39
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/swt/KeyStroke.java28
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/swt/SwtColor.java8
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/swt/SwtDisplayDevice.java22
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/swt/SwtFont.java8
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/swt/SwtFontMetrics.java12
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/swt/SwtGraphics.java43
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/swt/Timer.java31
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/swt/VexWidget.java52
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/views/DebugView.java34
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/views/DebugViewPage.java174
-rw-r--r--org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/wizards/NewDocumentWizard.java47
-rw-r--r--org.eclipse.vex.xhtml/.settings/org.eclipse.jdt.core.prefs281
-rw-r--r--org.eclipse.vex.xhtml/.settings/org.eclipse.jdt.ui.prefs56
-rw-r--r--org.eclipse.vex.xhtml/src/org/eclipse/vex/xhtml/XhtmlOutlineProvider.java48
273 files changed, 9756 insertions, 7361 deletions
diff --git a/org.eclipse.vex.core.tests/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.vex.core.tests/.settings/org.eclipse.jdt.core.prefs
index 500f4b85..89d4b848 100644
--- a/org.eclipse.vex.core.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.vex.core.tests/.settings/org.eclipse.jdt.core.prefs
@@ -1,8 +1,291 @@
-#Sun Jan 23 11:15:13 CET 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5
+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_resources_in_try=80
+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.alignment_for_union_type_in_multicatch=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=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=false
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=120
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
+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=false
+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_field=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=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_annotation_on_type=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_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=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=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_semicolon_in_try_resources=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_try=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_try=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_semicolon_in_try_resources=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=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=200
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.tabulation.char=tab
+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_before_or_operator_multicatch=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
diff --git a/org.eclipse.vex.core.tests/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.vex.core.tests/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 00000000..b8381b1e
--- /dev/null
+++ b/org.eclipse.vex.core.tests/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,56 @@
+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=true
+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=true
+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=true
+cleanup.make_private_fields_final=true
+cleanup.make_type_abstract_if_missing_method=false
+cleanup.make_variable_declarations_final=true
+cleanup.never_use_blocks=false
+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=false
+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=true
+cleanup.use_this_for_non_static_field_access=true
+cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+cleanup.use_this_for_non_static_method_access=true
+cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+cleanup_profile=_Vex
+cleanup_settings_version=2
+eclipse.preferences.version=1
+formatter_profile=_Vex
+formatter_settings_version=12
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/BatikBehaviorTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/BatikBehaviorTest.java
index 1d5c93e9..7046b5e1 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/BatikBehaviorTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/BatikBehaviorTest.java
@@ -22,7 +22,7 @@ import org.junit.Test;
* @author Florian Thienel
*/
public class BatikBehaviorTest {
-
+
@Test
public void pseudoElements() throws Exception {
final StyleSheetReader reader = new StyleSheetReader();
@@ -30,8 +30,8 @@ public class BatikBehaviorTest {
final List<Rule> rules = styleSheet.getRules();
assertEquals(1, rules.size());
final Rule rule = rules.get(0);
- Element element = new Element("plan");
- PseudoElement beforeElement = new PseudoElement(element, "before");
+ final Element element = new Element("plan");
+ final PseudoElement beforeElement = new PseudoElement(element, "before");
assertTrue(rule.matches(beforeElement));
}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/CssTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/CssTest.java
index fdd3a129..b483199d 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/CssTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/CssTest.java
@@ -32,12 +32,12 @@ public class CssTest {
@Test
public void testBorderColor() throws Exception {
- StyleSheet ss = parseStyleSheetResource("test2.css");
+ final StyleSheet ss = parseStyleSheetResource("test2.css");
Styles styles;
- Color red = new Color(255, 0, 0);
- Color green = new Color(0, 128, 0);
- Color blue = new Color(0, 0, 255);
- Color white = new Color(255, 255, 255);
+ final Color red = new Color(255, 0, 0);
+ final Color green = new Color(0, 128, 0);
+ final Color blue = new Color(0, 0, 255);
+ final Color white = new Color(255, 255, 255);
styles = ss.getStyles(new Element("borderColor1"));
assertEquals(red, styles.getBorderTopColor());
@@ -67,7 +67,7 @@ public class CssTest {
@Test
public void testBorderStyle() throws Exception {
- StyleSheet ss = parseStyleSheetResource("test2.css");
+ final StyleSheet ss = parseStyleSheetResource("test2.css");
Styles styles;
styles = ss.getStyles(new Element("borderStyle1"));
@@ -98,7 +98,7 @@ public class CssTest {
@Test
public void testBorderWidth() throws Exception {
- StyleSheet ss = parseStyleSheetResource("test2.css");
+ final StyleSheet ss = parseStyleSheetResource("test2.css");
Styles styles;
styles = ss.getStyles(new Element("borderWidth1"));
@@ -129,8 +129,8 @@ public class CssTest {
@Test
public void testDefaults() throws Exception {
- StyleSheet ss = parseStyleSheetResource("test2.css");
- Styles styles = ss.getStyles(new Element("defaults"));
+ final StyleSheet ss = parseStyleSheetResource("test2.css");
+ final Styles styles = ss.getStyles(new Element("defaults"));
assertEquals(15.0f, styles.getFontSize(), 0.1);
@@ -168,13 +168,13 @@ public class CssTest {
@Test
public void testDefaultInheritance() throws Exception {
- RootElement simple = new RootElement("simple");
- Element defaults = new Element("defaults");
- Document doc = new Document(simple);
+ final RootElement simple = new RootElement("simple");
+ final Element defaults = new Element("defaults");
+ final Document doc = new Document(simple);
doc.insertElement(1, defaults);
- StyleSheet ss = parseStyleSheetResource("test2.css");
- Styles styles = ss.getStyles(defaults);
+ final StyleSheet ss = parseStyleSheetResource("test2.css");
+ final Styles styles = ss.getStyles(defaults);
assertEquals(12.5f, styles.getFontSize(), 0.1);
@@ -212,7 +212,7 @@ public class CssTest {
@Test
public void testExpandBorder() throws Exception {
- StyleSheet ss = parseStyleSheetResource("test2.css");
+ final StyleSheet ss = parseStyleSheetResource("test2.css");
Styles styles;
styles = ss.getStyles(new Element("expandBorder"));
@@ -319,7 +319,7 @@ public class CssTest {
@Test
public void testExpandMargins() throws Exception {
- StyleSheet ss = parseStyleSheetResource("test2.css");
+ final StyleSheet ss = parseStyleSheetResource("test2.css");
Styles styles = ss.getStyles(new Element("margin1"));
assertEquals(10, styles.getMarginTop().get(67));
@@ -348,8 +348,8 @@ public class CssTest {
@Test
public void testExtras() throws Exception {
- StyleSheet ss = parseStyleSheetResource("test2.css");
- Styles styles = ss.getStyles(new Element("extras"));
+ final StyleSheet ss = parseStyleSheetResource("test2.css");
+ final Styles styles = ss.getStyles(new Element("extras"));
assertEquals(new Color(0, 255, 0), styles.getBackgroundColor());
@@ -371,8 +371,8 @@ public class CssTest {
@Test
public void testExtras2() throws Exception {
- StyleSheet ss = parseStyleSheetResource("test2.css");
- Styles styles = ss.getStyles(new Element("extras2"));
+ final StyleSheet ss = parseStyleSheetResource("test2.css");
+ final Styles styles = ss.getStyles(new Element("extras2"));
assertEquals(new Color(192, 192, 192), styles.getBackgroundColor());
@@ -391,7 +391,7 @@ public class CssTest {
@Test
public void testFontSize() throws Exception {
- StyleSheet ss = parseStyleSheetResource("test2.css");
+ final StyleSheet ss = parseStyleSheetResource("test2.css");
Styles styles;
styles = ss.getStyles(new Element("medium"));
@@ -431,13 +431,13 @@ public class CssTest {
@Test
public void testForcedInheritance() throws Exception {
- RootElement simple = new RootElement("simple");
- Element inherit = new Element("inherit");
- Document doc = new Document(simple);
+ final RootElement simple = new RootElement("simple");
+ final Element inherit = new Element("inherit");
+ final Document doc = new Document(simple);
doc.insertElement(1, inherit);
- StyleSheet ss = parseStyleSheetResource("test2.css");
- Styles styles = ss.getStyles(inherit);
+ final StyleSheet ss = parseStyleSheetResource("test2.css");
+ final Styles styles = ss.getStyles(inherit);
assertEquals(12.5f, styles.getFontSize(), 0.1);
@@ -475,14 +475,14 @@ public class CssTest {
@Test
public void testImportant() throws Exception {
- StyleSheet ss = parseStyleSheetResource("testImportant.css");
- Element a = new Element("a");
- Styles styles = ss.getStyles(a);
+ final StyleSheet ss = parseStyleSheetResource("testImportant.css");
+ final Element a = new Element("a");
+ final Styles styles = ss.getStyles(a);
- Color black = new Color(0, 0, 0);
+ final Color black = new Color(0, 0, 0);
// Color white = new Color(255, 255, 255);
// Color red = new Color(255, 0, 0);
- Color blue = new Color(0, 0, 255);
+ final Color blue = new Color(0, 0, 255);
assertEquals(black, styles.getBackgroundColor());
assertEquals(black, styles.getColor());
@@ -492,11 +492,11 @@ public class CssTest {
@Test
public void testMarginInheritance() throws Exception {
- StyleSheet ss = parseStyleSheetResource("test2.css");
- Element root = new Element("margin1");
- Element child = new Element("defaults");
+ final StyleSheet ss = parseStyleSheetResource("test2.css");
+ final Element root = new Element("margin1");
+ final Element child = new Element("defaults");
child.setParent(root);
- Styles styles = ss.getStyles(child);
+ final Styles styles = ss.getStyles(child);
assertEquals(0, styles.getMarginTop().get(67));
assertEquals(0, styles.getMarginLeft().get(67));
@@ -506,8 +506,8 @@ public class CssTest {
@Test
public void testSimple() throws Exception {
- StyleSheet ss = parseStyleSheetResource("test2.css");
- Styles styles = ss.getStyles(new Element("simple"));
+ final StyleSheet ss = parseStyleSheetResource("test2.css");
+ final Styles styles = ss.getStyles(new Element("simple"));
assertEquals(12.5f, styles.getFontSize(), 0.1);
@@ -544,11 +544,10 @@ public class CssTest {
}
- private StyleSheet parseStyleSheetResource(String resource)
- throws java.io.IOException {
+ private StyleSheet parseStyleSheetResource(final String resource) throws java.io.IOException {
- URL url = this.getClass().getResource(resource);
- StyleSheetReader reader = new StyleSheetReader();
+ final URL url = this.getClass().getResource(resource);
+ final StyleSheetReader reader = new StyleSheetReader();
return reader.read(url);
}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/MockDisplayDevice.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/MockDisplayDevice.java
index 515c687f..75afe0d9 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/MockDisplayDevice.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/MockDisplayDevice.java
@@ -14,24 +14,26 @@ import org.eclipse.vex.core.internal.core.DisplayDevice;
public class MockDisplayDevice extends DisplayDevice {
- private int horizontalPPI;
- private int verticalPPI;
+ private final int horizontalPPI;
+ private final int verticalPPI;
- public MockDisplayDevice(int horizontalPPI, int verticalPPI) {
+ public MockDisplayDevice(final int horizontalPPI, final int verticalPPI) {
this.horizontalPPI = horizontalPPI;
this.verticalPPI = verticalPPI;
}
+ @Override
public int getHorizontalPPI() {
- return this.horizontalPPI;
+ return horizontalPPI;
}
/**
*
*/
+ @Override
public int getVerticalPPI() {
- return this.verticalPPI;
+ return verticalPPI;
}
}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/MockLU.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/MockLU.java
index e0f6e8b7..04b9cb76 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/MockLU.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/MockLU.java
@@ -17,30 +17,30 @@ import org.w3c.css.sac.LexicalUnit;
*/
public class MockLU implements LexicalUnit {
- public MockLU(short type) {
- this.lexicalUnitType = type;
+ public MockLU(final short type) {
+ lexicalUnitType = type;
}
public static LexicalUnit INHERIT = new MockLU(LexicalUnit.SAC_INHERIT);
- public static LexicalUnit createFloat(short units, float value) {
- MockLU lu = new MockLU(units);
+ public static LexicalUnit createFloat(final short units, final float value) {
+ final MockLU lu = new MockLU(units);
lu.setFloatValue(value);
return lu;
}
- public static LexicalUnit createIdent(String s) {
- MockLU lu = new MockLU(LexicalUnit.SAC_IDENT);
+ public static LexicalUnit createIdent(final String s) {
+ final MockLU lu = new MockLU(LexicalUnit.SAC_IDENT);
lu.setStringValue(s);
return lu;
}
- public static LexicalUnit createString(String s) {
- MockLU lu = new MockLU(LexicalUnit.SAC_STRING_VALUE);
+ public static LexicalUnit createString(final String s) {
+ final MockLU lu = new MockLU(LexicalUnit.SAC_STRING_VALUE);
lu.setStringValue(s);
return lu;
}
-
+
public static LexicalUnit createAttr(final String attributeName) {
final MockLU result = new MockLU(LexicalUnit.SAC_ATTR);
result.setStringValue(attributeName);
@@ -48,82 +48,82 @@ public class MockLU implements LexicalUnit {
}
public String getDimensionUnitText() {
- return this.dimensionUnitText;
+ return dimensionUnitText;
}
public float getFloatValue() {
- return this.floatValue;
+ return floatValue;
}
public String getFunctionName() {
- return this.functionName;
+ return functionName;
}
public int getIntegerValue() {
- return this.integerValue;
+ return integerValue;
}
public short getLexicalUnitType() {
- return this.lexicalUnitType;
+ return lexicalUnitType;
}
public LexicalUnit getNextLexicalUnit() {
- return this.nextLexicalUnit;
+ return nextLexicalUnit;
}
public LexicalUnit getParameters() {
- return this.parameters;
+ return parameters;
}
public LexicalUnit getPreviousLexicalUnit() {
- return this.previousLexicalUnit;
+ return previousLexicalUnit;
}
public String getStringValue() {
- return this.stringValue;
+ return stringValue;
}
public LexicalUnit getSubValues() {
- return this.subValues;
+ return subValues;
}
- public void setDimensionUnitText(String dimensionUnitText) {
+ public void setDimensionUnitText(final String dimensionUnitText) {
this.dimensionUnitText = dimensionUnitText;
}
- public void setFloatValue(float floatValue) {
+ public void setFloatValue(final float floatValue) {
this.floatValue = floatValue;
}
- public void setFunctionName(String functionName) {
+ public void setFunctionName(final String functionName) {
this.functionName = functionName;
}
- public void setIntegerValue(int integerValue) {
+ public void setIntegerValue(final int integerValue) {
this.integerValue = integerValue;
}
- public void setLexicalUnitType(short lexicalUnitType) {
+ public void setLexicalUnitType(final short lexicalUnitType) {
this.lexicalUnitType = lexicalUnitType;
}
- public void setNextLexicalUnit(LexicalUnit nextLexicalUnit) {
+ public void setNextLexicalUnit(final LexicalUnit nextLexicalUnit) {
this.nextLexicalUnit = nextLexicalUnit;
}
- public void setParameters(LexicalUnit parameters) {
+ public void setParameters(final LexicalUnit parameters) {
this.parameters = parameters;
}
- public void setPreviousLexicalUnit(LexicalUnit previousLexicalUnit) {
+ public void setPreviousLexicalUnit(final LexicalUnit previousLexicalUnit) {
this.previousLexicalUnit = previousLexicalUnit;
}
- public void setStringValue(String stringValue) {
+ public void setStringValue(final String stringValue) {
this.stringValue = stringValue;
}
- public void setSubValues(LexicalUnit subValues) {
+ public void setSubValues(final LexicalUnit subValues) {
this.subValues = subValues;
}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/PropertyTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/PropertyTest.java
index b00426b1..83a4d581 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/PropertyTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/PropertyTest.java
@@ -15,13 +15,6 @@ import java.io.StringReader;
import junit.framework.TestCase;
import org.eclipse.vex.core.internal.core.DisplayDevice;
-import org.eclipse.vex.core.internal.css.BackgroundImageProperty;
-import org.eclipse.vex.core.internal.css.BorderStyleProperty;
-import org.eclipse.vex.core.internal.css.BorderWidthProperty;
-import org.eclipse.vex.core.internal.css.CSS;
-import org.eclipse.vex.core.internal.css.IProperty;
-import org.eclipse.vex.core.internal.css.StyleSheetReader;
-import org.eclipse.vex.core.internal.css.Styles;
import org.eclipse.vex.core.internal.dom.Document;
import org.eclipse.vex.core.internal.dom.DocumentReader;
import org.eclipse.vex.core.internal.dom.Element;
@@ -103,8 +96,7 @@ public class PropertyTest extends TestCase {
}
/**
- * From CSS2.1 section 8.5.2 (border-XXX-color), section 14.1 (color), and
- * section 14.2.1 (background-color)
+ * From CSS2.1 section 8.5.2 (border-XXX-color), section 14.1 (color), and section 14.2.1 (background-color)
*/
public void testColorProperty() throws Exception {
}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/RuleTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/RuleTest.java
index 968feb06..40ff84e2 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/RuleTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/css/RuleTest.java
@@ -16,9 +16,6 @@ import java.util.List;
import junit.framework.TestCase;
import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.vex.core.internal.css.Rule;
-import org.eclipse.vex.core.internal.css.StyleSheet;
-import org.eclipse.vex.core.internal.css.StyleSheetReader;
import org.eclipse.vex.core.internal.dom.Document;
import org.eclipse.vex.core.internal.dom.Element;
import org.eclipse.vex.core.internal.dom.RootElement;
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/BlockElementBoxTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/BlockElementBoxTest.java
index 5c321dec..a7e9cebb 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/BlockElementBoxTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/BlockElementBoxTest.java
@@ -14,11 +14,11 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
+import junit.framework.TestCase;
+
import org.eclipse.vex.core.internal.core.Graphics;
import org.eclipse.vex.core.internal.css.StyleSheet;
import org.eclipse.vex.core.internal.css.StyleSheetReader;
-import org.eclipse.vex.core.internal.dom.Document;
-import org.eclipse.vex.core.internal.dom.DocumentReader;
import org.eclipse.vex.core.internal.layout.BlockElementBox;
import org.eclipse.vex.core.internal.layout.Box;
import org.eclipse.vex.core.internal.layout.CssBoxFactory;
@@ -27,53 +27,46 @@ import org.eclipse.vex.core.internal.layout.LayoutContext;
import org.eclipse.vex.core.internal.layout.RootBox;
import org.eclipse.vex.core.tests.TestResources;
-import junit.framework.TestCase;
-
public class BlockElementBoxTest extends TestCase {
- private Graphics g;
- private LayoutContext context;
+ private final Graphics g;
+ private final LayoutContext context;
public BlockElementBoxTest() throws Exception {
- StyleSheetReader ssReader = new StyleSheetReader();
- StyleSheet ss = ssReader.read(TestResources.get("test.css"));
+ final StyleSheetReader ssReader = new StyleSheetReader();
+ final StyleSheet ss = ssReader.read(TestResources.get("test.css"));
- this.g = new FakeGraphics();
+ g = new FakeGraphics();
- this.context = new LayoutContext();
- this.context.setBoxFactory(new CssBoxFactory());
- this.context.setGraphics(this.g);
- this.context.setStyleSheet(ss);
+ context = new LayoutContext();
+ context.setBoxFactory(new CssBoxFactory());
+ context.setGraphics(g);
+ context.setStyleSheet(ss);
}
public void testPositioning() throws Exception {
- String docString = "<root><small/><medium/><large/></root>";
- DocumentReader docReader = new DocumentReader();
+ final String docString = "<root><small/><medium/><large/></root>";
+ final DocumentReader docReader = new DocumentReader();
docReader.setDebugging(true);
- Document doc = docReader.read(docString);
+ final Document doc = docReader.read(docString);
context.setDocument(doc);
-
- RootBox parentBox = new RootBox(context, doc.getRootElement(), 500);
-
- BlockElementBox box = new BlockElementBox(context, parentBox, doc
- .getRootElement());
-
- List<Box> childrenList = box.createChildren(context);
- Box[] children = childrenList.toArray(new Box[childrenList.size()]);
+
+ final RootBox parentBox = new RootBox(context, doc.getRootElement(), 500);
+
+ final BlockElementBox box = new BlockElementBox(context, parentBox, doc.getRootElement());
+
+ final List<Box> childrenList = box.createChildren(context);
+ final Box[] children = childrenList.toArray(new Box[childrenList.size()]);
assertNotNull("No Children created.", children);
assertEquals(3, children.length);
}
- public int getGap(BlockElementBox box, int n) throws SecurityException,
- NoSuchMethodException, IllegalArgumentException,
- IllegalAccessException, InvocationTargetException {
- Method getGap = BlockElementBox.class.getDeclaredMethod("getGap",
- new Class[] { Integer.TYPE });
+ public int getGap(final BlockElementBox box, final int n) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+ final Method getGap = BlockElementBox.class.getDeclaredMethod("getGap", new Class[] { Integer.TYPE });
getGap.setAccessible(true);
- return ((Integer) getGap.invoke(box, new Object[] { Integer.valueOf(n) }))
- .intValue();
+ return ((Integer) getGap.invoke(box, new Object[] { Integer.valueOf(n) })).intValue();
}
}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DTDValidatorTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DTDValidatorTest.java
index 5a00ae28..d86f22cb 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DTDValidatorTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DTDValidatorTest.java
@@ -47,7 +47,7 @@ public class DTDValidatorTest extends TestCase {
assertSame(adType, adType2);
}
-
+
public void testEnumAttribute() throws Exception {
final Document doc = new Document(new RootElement("section"));
doc.setValidator(validator);
@@ -112,8 +112,9 @@ public class DTDValidatorTest extends TestCase {
private static void assertValidItemsAt(final Document doc, final int offset, final String... expectedItems) {
final Set<QualifiedName> expected = new HashSet<QualifiedName>(expectedItems.length);
- for (final String expectedItem : expectedItems)
+ for (final String expectedItem : expectedItems) {
expected.add(new QualifiedName(null, expectedItem));
+ }
final Set<QualifiedName> validItems = doc.getValidator().getValidItems(doc.getElementAt(offset));
assertEquals(expected, validItems);
@@ -154,7 +155,7 @@ public class DTDValidatorTest extends TestCase {
doc.insertElement(1, new Element("title"));
doc.insertText(2, "ab");
doc.insertElement(5, new Element("para"));
-
+
validator.getAttributeDefinitions(doc.getRootElement());
}
@@ -176,32 +177,35 @@ public class DTDValidatorTest extends TestCase {
assertValidSequence(false, element, true, true, sequence);
}
- private void assertValidSequence(final boolean expected, final String element, final boolean validateFully, final boolean validatePartially,
- final String... sequence) {
+ private void assertValidSequence(final boolean expected, final String element, final boolean validateFully, final boolean validatePartially, final String... sequence) {
final QualifiedName elementName = new QualifiedName(null, element);
for (int i = 0; i < sequence.length; i++) {
final List<QualifiedName> prefix = createPrefix(i, sequence);
final List<QualifiedName> toInsert = Collections.singletonList(new QualifiedName(null, sequence[i]));
final List<QualifiedName> suffix = createSuffix(i, sequence);
- if (validateFully)
+ if (validateFully) {
assertEquals(expected, validator.isValidSequence(elementName, prefix, toInsert, suffix, false));
- if (validatePartially)
+ }
+ if (validatePartially) {
assertEquals(expected, validator.isValidSequence(elementName, prefix, toInsert, suffix, true));
+ }
}
}
private static List<QualifiedName> createPrefix(final int index, final String... sequence) {
final List<QualifiedName> prefix = new ArrayList<QualifiedName>();
- for (int i = 0; i < index; i++)
+ for (int i = 0; i < index; i++) {
prefix.add(new QualifiedName(null, sequence[i]));
+ }
return prefix;
}
private static List<QualifiedName> createSuffix(final int index, final String... sequence) {
final List<QualifiedName> suffix = new ArrayList<QualifiedName>();
- for (int i = index + 1; i < sequence.length; i++)
+ for (int i = index + 1; i < sequence.length; i++) {
suffix.add(new QualifiedName(null, sequence[i]));
+ }
return suffix;
}
}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentContentModelTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentContentModelTest.java
index ff7dbf06..eb3ee0c0 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentContentModelTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentContentModelTest.java
@@ -107,14 +107,14 @@ public class DocumentContentModelTest {
assertNotNull(resolvedUrl);
assertTrue(resolvedUrl.toString().contains(VEXCoreTestPlugin.PLUGIN_ID));
}
-
+
@Test
public void onlySystemId() throws Exception {
model.initialize(null, null, TestResources.get("test1.dtd").toString(), null);
assertTrue(model.isDtdAssigned());
assertNotNull(model.getDTD());
}
-
+
@Test
public void onlyRelativeSystemId() throws Exception {
final String baseUri = TestResources.get("test.css").toString();
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentReaderTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentReaderTest.java
index ac2f657e..3f231c18 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentReaderTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentReaderTest.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.dom;
-import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -64,8 +63,9 @@ public class DocumentReaderTest {
reader.setDocumentContentModel(new DocumentContentModel() {
@Override
public InputSource resolveEntity(final String publicId, final String systemId) throws SAXException, IOException {
- if (TestResources.TEST_DTD.equals(publicId))
+ if (TestResources.TEST_DTD.equals(publicId)) {
called[0] = true;
+ }
return super.resolveEntity(publicId, systemId);
}
});
@@ -81,15 +81,17 @@ public class DocumentReaderTest {
reader.setDocumentContentModel(new DocumentContentModel() {
@Override
public InputSource resolveEntity(final String publicId, final String systemId) throws SAXException, IOException {
- if (TestResources.TEST_DTD.equals(publicId))
+ if (TestResources.TEST_DTD.equals(publicId)) {
documentContentModelCalled[0] = true;
+ }
return super.resolveEntity(publicId, systemId);
}
});
reader.setEntityResolver(new EntityResolver() {
public InputSource resolveEntity(final String publicId, final String systemId) throws SAXException, IOException {
- if (TestResources.TEST_DTD.equals(publicId))
+ if (TestResources.TEST_DTD.equals(publicId)) {
entityResolverCalled[0] = true;
+ }
return new InputSource(TestResources.get("test1.dtd").toString());
}
});
@@ -107,15 +109,17 @@ public class DocumentReaderTest {
reader.setDocumentContentModel(new DocumentContentModel() {
@Override
public InputSource resolveEntity(final String publicId, final String systemId) throws SAXException, IOException {
- if (TestResources.TEST_DTD.equals(publicId))
+ if (TestResources.TEST_DTD.equals(publicId)) {
documentContentModelPosition[0] = ++callPosition[0];
+ }
return super.resolveEntity(publicId, systemId);
}
});
reader.setEntityResolver(new EntityResolver() {
public InputSource resolveEntity(final String publicId, final String systemId) throws SAXException, IOException {
- if (TestResources.TEST_DTD.equals(publicId))
+ if (TestResources.TEST_DTD.equals(publicId)) {
entityResolverPosition[0] = ++callPosition[0];
+ }
return null;
}
});
@@ -123,7 +127,7 @@ public class DocumentReaderTest {
assertEquals(2, documentContentModelPosition[0]);
assertEquals(1, entityResolverPosition[0]);
}
-
+
@Test
public void readDocumentWithComments() throws Exception {
final DocumentReader reader = new DocumentReader();
@@ -131,10 +135,10 @@ public class DocumentReaderTest {
final Element rootElement = document.getRootElement();
final List<Node> rootChildNodes = rootElement.getChildNodes();
assertEquals(4, rootChildNodes.size());
-
+
final CommentElement comment1 = (CommentElement) rootChildNodes.get(0);
assertEquals("A comment within the root element.", comment1.getText());
-
+
final CommentElement comment2 = (CommentElement) ((Element) rootChildNodes.get(1)).getChildNodes().get(1);
assertEquals("A comment within text.", comment2.getText());
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentWriterTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentWriterTest.java
index 5b1f6a47..c8c641ce 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentWriterTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentWriterTest.java
@@ -36,7 +36,7 @@ public class DocumentWriterTest {
public void testHtmlWithAttributes() throws Exception {
assertWriteReadCycleWorks(TestResources.get("DocumentWriterTest1.xml"));
}
-
+
@Test
public void testDocumentWithDtdPublic() throws Exception {
assertWriteReadCycleWorks(TestResources.get("documentWithDtdPublic.xml"));
@@ -46,12 +46,12 @@ public class DocumentWriterTest {
public void testDocumentWithDtdSystem() throws Exception {
assertWriteReadCycleWorks(TestResources.get("documentWithDtdSystem.xml"));
}
-
+
@Test
public void testDocumentWithSchema() throws Exception {
assertWriteReadCycleWorks(TestResources.get("document.xml"));
}
-
+
@Test
public void testDocumentWithComments() throws Exception {
assertWriteReadCycleWorks(TestResources.get("documentWithComments.xml"));
@@ -93,8 +93,9 @@ public class DocumentWriterTest {
final List<QualifiedName> actualAttrs = actual.getAttributeNames();
assertEquals(expectedAttrs.size(), actualAttrs.size());
- for (int i = 0; i < expectedAttrs.size(); i++)
+ for (int i = 0; i < expectedAttrs.size(); i++) {
assertEquals(expectedAttrs.get(i), actualAttrs.get(i));
+ }
}
private static void assertContentEqual(final Element expected, final Element actual) {
@@ -103,10 +104,11 @@ public class DocumentWriterTest {
assertEquals(expectedContent.size(), actualContent.size());
for (int i = 0; i < expectedContent.size(); i++) {
assertEquals(expectedContent.get(i).getClass(), actualContent.get(i).getClass());
- if (expectedContent.get(i) instanceof Element)
+ if (expectedContent.get(i) instanceof Element) {
assertElementsEqual((Element) expectedContent.get(i), (Element) actualContent.get(i));
- else
+ } else {
assertEquals(expectedContent.get(i).getText(), actualContent.get(i).getText());
+ }
}
}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/GapContentTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/GapContentTest.java
index 03802953..ccddd844 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/GapContentTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/GapContentTest.java
@@ -28,20 +28,20 @@ public class GapContentTest {
assertEquals(1, content.getLength());
assertTrue(content.isElementMarker(content.getString(0, content.getLength()).charAt(0)));
}
-
+
@Test
public void insertMultipleElementMarkers() throws Exception {
final GapContent elementMarkerContent = new GapContent(4);
elementMarkerContent.insertElementMarker(0);
elementMarkerContent.insertElementMarker(0);
-
+
final GapContent stringContent = new GapContent(4);
stringContent.insertString(0, "\0\0");
-
+
assertEquals(stringContent.getLength(), elementMarkerContent.getLength());
assertEquals(stringContent.getString(0, stringContent.getLength()), elementMarkerContent.getString(0, elementMarkerContent.getLength()));
}
-
+
@Test
public void testGapContent() throws Exception {
//
@@ -50,7 +50,7 @@ public class GapContentTest {
// 0 1 2 3 4
//
- GapContent content = new GapContent(2);
+ final GapContent content = new GapContent(2);
assertEquals(0, content.getLength());
content.insertString(0, "a");
assertEquals(1, content.getLength());
@@ -61,46 +61,46 @@ public class GapContentTest {
content.insertString(1, "b");
assertEquals(4, content.getLength());
- Position pa = content.createPosition(0);
- Position pb = content.createPosition(1);
- Position pc = content.createPosition(2);
- Position pd = content.createPosition(3);
- Position pe = content.createPosition(4);
+ final Position pa = content.createPosition(0);
+ final Position pb = content.createPosition(1);
+ final Position pc = content.createPosition(2);
+ final Position pd = content.createPosition(3);
+ final Position pe = content.createPosition(4);
try {
content.getString(-1, 1);
fail("expected exception");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
try {
content.getString(4, 1);
fail("expected exception");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
try {
content.getString(0, -1);
fail("expected exception");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
try {
content.getString(0, 5);
fail("expected exception");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
try {
content.createPosition(-1);
fail("expected exception");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
try {
content.createPosition(5);
fail("expected exception");
- } catch (IllegalArgumentException ex) {
+ } catch (final IllegalArgumentException ex) {
}
assertEquals("a", content.getString(0, 1));
@@ -133,8 +133,8 @@ public class GapContentTest {
assertEquals(5, pd.getOffset());
assertEquals(6, pe.getOffset());
- Position px = content.createPosition(2);
- Position py = content.createPosition(3);
+ final Position px = content.createPosition(2);
+ final Position py = content.createPosition(3);
content.remove(2, 2);
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/NamespaceStackTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/NamespaceStackTest.java
index 94ada882..d41b76cf 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/NamespaceStackTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/NamespaceStackTest.java
@@ -14,7 +14,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import org.eclipse.vex.core.internal.dom.NamespaceStack;
import org.junit.Test;
/**
@@ -73,7 +72,7 @@ public class NamespaceStackTest {
assertNull(stack.peek("ns1"));
assertNull(stack.peek("ns2"));
}
-
+
@Test
public void getPrefixes() throws Exception {
final NamespaceStack stack = new NamespaceStack();
@@ -81,16 +80,16 @@ public class NamespaceStackTest {
stack.pushDefault("http://namespace/default");
assertTrue(stack.getPrefixes().isEmpty());
-
+
stack.push("ns1", "http://namespace/uri/1");
assertEquals(1, stack.getPrefixes().size());
assertTrue(stack.getPrefixes().contains("ns1"));
-
+
stack.push("ns2", "http://namespace/uri/2");
assertEquals(2, stack.getPrefixes().size());
assertTrue(stack.getPrefixes().contains("ns1"));
assertTrue(stack.getPrefixes().contains("ns2"));
-
+
stack.clear();
assertTrue(stack.getPrefixes().isEmpty());
}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/NamespaceTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/NamespaceTest.java
index ed546d5f..f35e6954 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/NamespaceTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/NamespaceTest.java
@@ -229,7 +229,7 @@ public class NamespaceTest {
element.declareNamespace("ns1", "http://namespace/uri/1");
element.declareNamespace("ns2", "http://namespace/uri/2");
- final Element clone = (Element) element.clone();
+ final Element clone = element.clone();
assertEquals("http://namespace/uri/default", clone.getDeclaredDefaultNamespaceURI());
}
@@ -249,8 +249,8 @@ public class NamespaceTest {
@Test
public void readNestedNamespaceDeclarations() throws Exception {
- final Document document = readDocumentFromString("<ns1:a xmlns=\"http://namespace/default\" xmlns:ns1=\"http://namespace/uri/1\">"
- + "<ns2:b xmlns:ns2=\"http://namespace/uri/2\"/>" + "</ns1:a>");
+ final Document document = readDocumentFromString("<ns1:a xmlns=\"http://namespace/default\" xmlns:ns1=\"http://namespace/uri/1\">" + "<ns2:b xmlns:ns2=\"http://namespace/uri/2\"/>"
+ + "</ns1:a>");
final Element rootElement = document.getRootElement();
final Element nestedElement = rootElement.getChildElements().get(0);
assertEquals("http://namespace/default", nestedElement.getDefaultNamespaceURI());
@@ -261,8 +261,8 @@ public class NamespaceTest {
@Test
public void evaluateElementPrefix() throws Exception {
- final Document document = readDocumentFromString("<ns1:a xmlns=\"http://namespace/default\" xmlns:ns1=\"http://namespace/uri/1\">"
- + "<ns2:b xmlns:ns2=\"http://namespace/uri/2\"/>" + "<c />" + "</ns1:a>");
+ final Document document = readDocumentFromString("<ns1:a xmlns=\"http://namespace/default\" xmlns:ns1=\"http://namespace/uri/1\">" + "<ns2:b xmlns:ns2=\"http://namespace/uri/2\"/>" + "<c />"
+ + "</ns1:a>");
final Element rootElement = document.getRootElement();
assertEquals("http://namespace/uri/1", rootElement.getQualifiedName().getQualifier());
assertEquals("a", rootElement.getLocalName());
@@ -282,8 +282,7 @@ public class NamespaceTest {
@Test
public void evaluateAttributePrefix() throws Exception {
final Document document = readDocumentFromString("<ns1:a xmlns=\"http://namespace/default\" xmlns:ns1=\"http://namespace/uri/1\" attr1=\"value1\">"
- + "<ns2:b xmlns:ns2=\"http://namespace/uri/2\" ns1:attr2=\"value2\" ns2:attr3=\"value3\" attr4=\"value4\" />"
- + "<c ns1:attr5=\"value5\" attr6=\"value6\" />" + "</ns1:a>");
+ + "<ns2:b xmlns:ns2=\"http://namespace/uri/2\" ns1:attr2=\"value2\" ns2:attr3=\"value3\" attr4=\"value4\" />" + "<c ns1:attr5=\"value5\" attr6=\"value6\" />" + "</ns1:a>");
final Element rootElement = document.getRootElement();
assertTrue(rootElement.getAttributeNames().contains(new QualifiedName("http://namespace/uri/1", "attr1")));
assertFalse(rootElement.getAttributeNames().contains(new QualifiedName("http://namespace/default", "attr1")));
@@ -303,8 +302,7 @@ public class NamespaceTest {
@Test
public void readWriteCycle() throws Exception {
final String inputContent = "<?xml version='1.0'?> <ns1:a xmlns=\"http://namespace/default\" xmlns:ns1=\"http://namespace/uri/1\" attr1=\"value1\"> "
- + "<ns2:b xmlns:ns2=\"http://namespace/uri/2\" ns1:attr2=\"value2\" attr3=\"value3\"/> " + "<c attr4=\"value4\" ns1:attr5=\"value5\"/>"
- + "</ns1:a> ";
+ + "<ns2:b xmlns:ns2=\"http://namespace/uri/2\" ns1:attr2=\"value2\" attr3=\"value3\"/> " + "<c attr4=\"value4\" ns1:attr5=\"value5\"/>" + "</ns1:a> ";
final Document document = readDocumentFromString(inputContent);
final DocumentWriter documentWriter = new DocumentWriter();
@@ -314,7 +312,7 @@ public class NamespaceTest {
assertEquals(inputContent, outputContent);
}
-
+
@Test
public void allVisibleNamespacePrefixes() throws Exception {
final Element parent = new Element("parent");
@@ -328,16 +326,16 @@ public class NamespaceTest {
element.declareNamespace("ns3", "http://namespace/uri/3");
element.declareNamespace("ns1", "http://namespace/uri/1a");
child.declareDefaultNamespace("http://namespace/uri/child/default");
-
+
assertEquals(2, parent.getNamespacePrefixes().size());
assertTrue(parent.getNamespacePrefixes().contains("ns1"));
assertTrue(parent.getNamespacePrefixes().contains("ns2"));
-
+
assertEquals(3, element.getNamespacePrefixes().size());
assertTrue(element.getNamespacePrefixes().contains("ns1"));
assertTrue(element.getNamespacePrefixes().contains("ns2"));
assertTrue(element.getNamespacePrefixes().contains("ns3"));
-
+
assertEquals(3, child.getNamespacePrefixes().size());
assertTrue(child.getNamespacePrefixes().contains("ns1"));
assertTrue(child.getNamespacePrefixes().contains("ns2"));
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/SchemaValidatorTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/SchemaValidatorTest.java
index 12265c47..b4628ca9 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/SchemaValidatorTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/SchemaValidatorTest.java
@@ -158,9 +158,8 @@ public class SchemaValidatorTest {
@Test
public void validItemsFromComplexSchema() throws Exception {
/*
- * We have to check this using a document, because B and I are not
- * defined as standalone elements. The Validator needs their parent to
- * find the definition of their content model.
+ * We have to check this using a document, because B and I are not defined as standalone elements. The Validator
+ * needs their parent to find the definition of their content model.
*/
final Validator validator = new WTPVEXValidator();
final Document doc = new Document(new RootElement(CHAPTER));
@@ -183,7 +182,7 @@ public class SchemaValidatorTest {
final Set<String> requiredNamespaces = validator.getRequiredNamespaces();
assertEquals(1, requiredNamespaces.size());
}
-
+
@Test
public void getAllRequiredNamespacesForComplexSchema() throws Exception {
final Validator validator = new WTPVEXValidator(new DocumentContentModel(null, null, null, new RootElement(CHAPTER)));
@@ -192,7 +191,7 @@ public class SchemaValidatorTest {
assertTrue(requiredNamespaces.contains(CONTENT_NS));
assertTrue(requiredNamespaces.contains(STRUCTURE_NS));
}
-
+
private void assertIsValidSequence(final Validator validator, final QualifiedName parentElement, final QualifiedName... sequence) {
for (int i = 0; i < sequence.length; i++) {
final List<QualifiedName> prefix = createPrefix(i, sequence);
@@ -205,22 +204,25 @@ public class SchemaValidatorTest {
private static List<QualifiedName> createPrefix(final int index, final QualifiedName... sequence) {
final List<QualifiedName> prefix = new ArrayList<QualifiedName>();
- for (int i = 0; i < index; i++)
+ for (int i = 0; i < index; i++) {
prefix.add(sequence[i]);
+ }
return prefix;
}
private static List<QualifiedName> createSuffix(final int index, final QualifiedName... sequence) {
final List<QualifiedName> suffix = new ArrayList<QualifiedName>();
- for (int i = index + 1; i < sequence.length; i++)
+ for (int i = index + 1; i < sequence.length; i++) {
suffix.add(sequence[i]);
+ }
return suffix;
}
private static void assertValidItems(final Validator validator, final Element element, final QualifiedName... expectedItems) {
final Set<QualifiedName> expected = new HashSet<QualifiedName>(expectedItems.length);
- for (final QualifiedName expectedItem : expectedItems)
+ for (final QualifiedName expectedItem : expectedItems) {
expected.add(expectedItem);
+ }
final Set<QualifiedName> candidateItems = validator.getValidItems(element);
assertEquals(expected, candidateItems);
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/SpaceNormalizerTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/SpaceNormalizerTest.java
index 8f548ac9..42d78a9b 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/SpaceNormalizerTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/SpaceNormalizerTest.java
@@ -59,9 +59,10 @@ public class SpaceNormalizerTest extends TestCase {
protected void setUp() throws Exception {
super.setUp();
DisplayDevice.setCurrent(new MockDisplayDevice(90, 90));
- if (fTestProjectInitialized)
+ if (fTestProjectInitialized) {
return;
-
+ }
+
getAndCreateProject();
final Bundle coreTestBundle = Platform.getBundle(VEXCoreTestPlugin.PLUGIN_ID);
@SuppressWarnings("unchecked")
@@ -77,27 +78,29 @@ public class SpaceNormalizerTest extends TestCase {
System.out.println(destFile.getLocation() + " --> " + resolvedUrl.toExternalForm());
if (isFromJarFile(resolvedUrl)) {
copyTestFileToProject(coreTestBundle, absolutePath, destFile);
- } else
+ } else {
//if resource is not compressed, link
destFile.createLink(resolvedUrl.toURI(), IResource.REPLACE, new NullProgressMonitor());
+ }
}
}
fTestProject.refreshLocal(IResource.DEPTH_INFINITE, null);
fTestProjectInitialized = true;
}
- private static boolean isFileUrl(URL url) {
+ private static boolean isFileUrl(final URL url) {
return !url.getFile().endsWith("/");
}
-
+
private boolean isFromJarFile(final URL resolvedUrl) {
return resolvedUrl.toExternalForm().startsWith("jar:file");
}
-
+
private void copyTestFileToProject(final Bundle coreTestBundle, final String sourcePath, final IFile destinationFile) throws IOException, CoreException {
final InputStream source = FileLocator.openStream(coreTestBundle, new Path(sourcePath), false);
- if (destinationFile.exists())
+ if (destinationFile.exists()) {
destinationFile.delete(true, new NullProgressMonitor());
+ }
destinationFile.create(source, true, new NullProgressMonitor());
}
@@ -116,15 +119,17 @@ public class SpaceNormalizerTest extends TestCase {
}
private static void createProject(final IProject project, IPath locationPath, IProgressMonitor monitor) throws CoreException {
- if (monitor == null)
+ if (monitor == null) {
monitor = new NullProgressMonitor();
+ }
monitor.beginTask("creating test project", 10);
// create the project
try {
if (!project.exists()) {
final IProjectDescription desc = project.getWorkspace().newProjectDescription(project.getName());
- if (Platform.getLocation().equals(locationPath))
+ if (Platform.getLocation().equals(locationPath)) {
locationPath = null;
+ }
desc.setLocation(locationPath);
project.create(desc, monitor);
monitor = null;
@@ -134,8 +139,9 @@ public class SpaceNormalizerTest extends TestCase {
monitor = null;
}
} finally {
- if (monitor != null)
+ if (monitor != null) {
monitor.done();
+ }
}
}
@@ -153,8 +159,7 @@ public class SpaceNormalizerTest extends TestCase {
* <li>leading w/s trimmed</li>
* <li>trailing w/s trimmed</li>
* <li>internal w/s collapsed to a single space</li>
- * <li>internal w/s before and after an inline child element collapsed to a
- * single space.</li>
+ * <li>internal w/s before and after an inline child element collapsed to a single space.</li>
* <li>internal w/s before and after a block child element removed.</li>
* <li>spaces between blocks eliminated.</li>
* <li>no extraneous spaces before or after elements added</li>
@@ -162,9 +167,8 @@ public class SpaceNormalizerTest extends TestCase {
*/
public void testNormalize() throws Exception {
- final String input = "<doc>\n\t " + "<block>\n\t foo\n\t <inline>foo\n\t bar</inline>\n\t baz\n\t </block>\n\t "
- + "<block>\n\t foo\n\t <block>bar</block>\n\t baz</block>" + "<block>\n\t foo<inline> foo bar </inline>baz \n\t </block>"
- + "<block>\n\t foo<block>bar</block>baz \n\t</block>" + "\n\t </doc>";
+ final String input = "<doc>\n\t " + "<block>\n\t foo\n\t <inline>foo\n\t bar</inline>\n\t baz\n\t </block>\n\t " + "<block>\n\t foo\n\t <block>bar</block>\n\t baz</block>"
+ + "<block>\n\t foo<inline> foo bar </inline>baz \n\t </block>" + "<block>\n\t foo<block>bar</block>baz \n\t</block>" + "\n\t </doc>";
final StyleSheet ss = getStyleSheet();
@@ -258,14 +262,13 @@ public class SpaceNormalizerTest extends TestCase {
// private static final String DTD = "<!ELEMENT doc ANY>";
/**
- * Asserts the content of the given element matches the given list. If a
- * string in content is enclosed in angle brackets, it's assume to refer to
- * the name of an element; otherwise, it represents text content.
+ * Asserts the content of the given element matches the given list. If a string in content is enclosed in angle
+ * brackets, it's assume to refer to the name of an element; otherwise, it represents text content.
*/
private void assertContent(final Element element, final String... strings) {
final List<Node> content = element.getChildNodes();
assertEquals(strings.length, content.size());
- for (int i = 0; i < strings.length; i++)
+ for (int i = 0; i < strings.length; i++) {
if (strings[i].startsWith("<")) {
final String name = strings[i].substring(1, strings[i].length() - 1);
assertTrue(content.get(i) instanceof Element);
@@ -275,6 +278,7 @@ public class SpaceNormalizerTest extends TestCase {
final String contentText = content.get(i).getText();
assertEquals(strings[i], contentText);
}
+ }
}
private Document createDocument(final String s, final StyleSheet ss) throws ParserConfigurationException, SAXException, IOException {
@@ -283,6 +287,7 @@ public class SpaceNormalizerTest extends TestCase {
final StyleSheet mySS = ss;
final CssWhitespacePolicy policy = new CssWhitespacePolicy(mySS);
final DocumentBuilder builder = new DocumentBuilder(null, new DocumentContentModel() {
+ @Override
public IWhitespacePolicy getWhitespacePolicy() {
return policy;
}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/TextWrapperTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/TextWrapperTest.java
index c723f7d9..16dd7bd0 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/TextWrapperTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/TextWrapperTest.java
@@ -11,8 +11,6 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.dom;
-import org.eclipse.vex.core.internal.dom.TextWrapper;
-
import junit.framework.TestCase;
/**
@@ -23,20 +21,14 @@ public class TextWrapperTest extends TestCase {
public void testWrap() {
String[] results;
String[] inputs;
- TextWrapper wrapper = new TextWrapper();
+ final TextWrapper wrapper = new TextWrapper();
results = wrapper.wrap(40);
assertEquals(0, results.length);
- inputs = new String[] {
- "Here ",
- "are ",
- "some ",
- "short ",
- "words ",
- "and here are some long ones. We make sure we have some short stuff and some long stuff, just to make sure it all wraps." };
+ inputs = new String[] { "Here ", "are ", "some ", "short ", "words ", "and here are some long ones. We make sure we have some short stuff and some long stuff, just to make sure it all wraps." };
- for (String input : inputs) {
+ for (final String input : inputs) {
wrapper.add(input);
}
results = wrapper.wrap(40);
@@ -47,8 +39,8 @@ public class TextWrapperTest extends TestCase {
results = wrapper.wrap(40);
assertEquals(0, results.length);
- String s1 = "yabba ";
- String s3 = "yabba yabba yabba ";
+ final String s1 = "yabba ";
+ final String s3 = "yabba yabba yabba ";
wrapper.add(s1);
wrapper.addNoSplit(s3);
wrapper.addNoSplit(s3);
@@ -62,32 +54,29 @@ public class TextWrapperTest extends TestCase {
}
/**
- * Ensure the two string arrays represent the same run of text after all
- * elements are concatenated.
+ * Ensure the two string arrays represent the same run of text after all elements are concatenated.
*/
- private void assertPreserved(String[] inputs, String[] results) {
- StringBuffer inputSB = new StringBuffer();
- StringBuffer resultSB = new StringBuffer();
- for (String input : inputs) {
+ private void assertPreserved(final String[] inputs, final String[] results) {
+ final StringBuffer inputSB = new StringBuffer();
+ final StringBuffer resultSB = new StringBuffer();
+ for (final String input : inputs) {
inputSB.append(input);
}
- for (String result : results) {
+ for (final String result : results) {
resultSB.append(result);
}
assertEquals(inputSB.toString(), resultSB.toString());
}
/**
- * Ensure all lines fit within the given width, and that adding an extra
- * token from the next line would blow it.
+ * Ensure all lines fit within the given width, and that adding an extra token from the next line would blow it.
*/
- private void assertWidth(String[] results, int width) {
+ private void assertWidth(final String[] results, final int width) {
for (int i = 0; i < results.length; i++) {
assertTrue(results[i].length() > 0);
assertTrue(results[i].length() <= width);
if (i < results.length - 1) {
- assertTrue(results[i].length()
- + getToken(results[i + 1]).length() > width);
+ assertTrue(results[i].length() + getToken(results[i + 1]).length() > width);
}
}
}
@@ -95,7 +84,7 @@ public class TextWrapperTest extends TestCase {
/**
* Get a token from a string.
*/
- private String getToken(String s) {
+ private String getToken(final String s) {
int i = 0;
while (i < s.length() && !Character.isWhitespace(s.charAt(i))) {
i++;
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/FakeGraphics.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/FakeGraphics.java
index 448aeb56..d790c2e1 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/FakeGraphics.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/FakeGraphics.java
@@ -29,23 +29,25 @@ import org.eclipse.vex.core.internal.core.Rectangle;
*/
public class FakeGraphics implements Graphics {
- private int charWidth = 6;
+ private final int charWidth = 6;
private URL lastDrawnImageUrl = null;
public FakeGraphics() {
DisplayDevice.setCurrent(new DisplayDevice() {
+ @Override
public int getHorizontalPPI() {
return 72;
}
+ @Override
public int getVerticalPPI() {
return 72;
}
});
}
- private FontMetrics fontMetrics = new FontMetrics() {
+ private final FontMetrics fontMetrics = new FontMetrics() {
public int getAscent() {
return 10;
}
@@ -63,18 +65,18 @@ public class FakeGraphics implements Graphics {
}
};
- public int charsWidth(char[] data, int offset, int length) {
+ public int charsWidth(final char[] data, final int offset, final int length) {
return length * charWidth;
}
- public ColorResource createColor(Color rgb) {
+ public ColorResource createColor(final Color rgb) {
return new ColorResource() {
public void dispose() {
}
};
}
- public FontResource createFont(FontSpec fontSpec) {
+ public FontResource createFont(final FontSpec fontSpec) {
return new FontResource() {
public void dispose() {
}
@@ -84,19 +86,19 @@ public class FakeGraphics implements Graphics {
public void dispose() {
}
- public void drawChars(char[] chars, int offset, int length, int x, int y) {
+ public void drawChars(final char[] chars, final int offset, final int length, final int x, final int y) {
}
- public void drawLine(int x1, int y1, int x2, int y2) {
+ public void drawLine(final int x1, final int y1, final int x2, final int y2) {
}
- public void drawString(String s, int x, int y) {
+ public void drawString(final String s, final int x, final int y) {
}
- public void drawOval(int x, int y, int width, int height) {
+ public void drawOval(final int x, final int y, final int width, final int height) {
}
- public void drawRect(int x, int y, int width, int height) {
+ public void drawRect(final int x, final int y, final int width, final int height) {
}
public void drawImage(final Image image, final int x, final int y, final int width, final int height) {
@@ -108,10 +110,10 @@ public class FakeGraphics implements Graphics {
return lastDrawnImageUrl;
}
- public void fillOval(int x, int y, int width, int height) {
+ public void fillOval(final int x, final int y, final int width, final int height) {
}
- public void fillRect(int x, int y, int width, int height) {
+ public void fillRect(final int x, final int y, final int width, final int height) {
}
public Rectangle getClipBounds() {
@@ -138,15 +140,15 @@ public class FakeGraphics implements Graphics {
return 0;
}
- public ColorResource getSystemColor(int id) {
+ public ColorResource getSystemColor(final int id) {
return null;
}
public FontMetrics getFontMetrics() {
- return this.fontMetrics;
+ return fontMetrics;
}
- public Image getImage(URL url) {
+ public Image getImage(final URL url) {
return new FakeImage(url);
}
@@ -154,35 +156,35 @@ public class FakeGraphics implements Graphics {
return false;
}
- public void setAntiAliased(boolean antiAliased) {
+ public void setAntiAliased(final boolean antiAliased) {
}
- public ColorResource setBackgroundColor(ColorResource color) {
+ public ColorResource setBackgroundColor(final ColorResource color) {
return null;
}
- public ColorResource setColor(ColorResource color) {
+ public ColorResource setColor(final ColorResource color) {
return null;
}
- public FontResource setFont(FontResource font) {
+ public FontResource setFont(final FontResource font) {
return null;
}
- public void setLineStyle(int style) {
+ public void setLineStyle(final int style) {
}
- public void setLineWidth(int width) {
+ public void setLineWidth(final int width) {
}
- public int stringWidth(String s) {
+ public int stringWidth(final String s) {
return charWidth * s.length();
}
public int getCharWidth() {
- return this.charWidth;
+ return charWidth;
}
- public void setXORMode(boolean xorMode) {
+ public void setXORMode(final boolean xorMode) {
}
}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/FakeImage.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/FakeImage.java
index 358d7176..b04c86ed 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/FakeImage.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/FakeImage.java
@@ -6,8 +6,8 @@ import org.eclipse.vex.core.internal.core.Image;
public class FakeImage implements Image {
public final URL url;
- private int height;
- private int width;
+ private final int height;
+ private final int width;
public FakeImage(final URL url) {
this(url, 0, 0);
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/ImageBoxTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/ImageBoxTest.java
index f3e0e5fa..2990e118 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/ImageBoxTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/ImageBoxTest.java
@@ -6,12 +6,10 @@ import static org.junit.Assert.assertSame;
import java.net.URL;
import org.eclipse.vex.core.internal.core.Image;
-import org.eclipse.vex.core.internal.layout.ImageBox;
-import org.eclipse.vex.core.internal.layout.LayoutContext;
import org.junit.Test;
public class ImageBoxTest {
-
+
@Test
public void createImageBox() throws Exception {
final FakeImage image = new FakeImage(new URL("file://image.jpg"), 123, 456);
@@ -19,7 +17,7 @@ public class ImageBoxTest {
assertEquals(image.getWidth(), imageBox.getWidth());
assertEquals(image.getHeight(), imageBox.getHeight());
}
-
+
@Test
public void paintImageBox() throws Exception {
final FakeImage image = new FakeImage(new URL("file://image.jpg"), 123, 456);
@@ -30,13 +28,14 @@ public class ImageBoxTest {
imageBox.paint(context, 0, 0);
assertSame(image.url, graphics.getLastDrawnImageUrl());
}
-
+
@Test
public void scaleImage() throws Exception {
final FakeImage image = new FakeImage(new URL("file://image.jpg"), 123, 456);
final int[] drawnImageSize = new int[2];
final FakeGraphics graphics = new FakeGraphics() {
- public void drawImage(Image image, int x, int y, int width, int height) {
+ @Override
+ public void drawImage(final Image image, final int x, final int y, final int width, final int height) {
super.drawImage(image, x, y, width, height);
drawnImageSize[0] = width;
drawnImageSize[1] = height;
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/LayoutTestSuite.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/LayoutTestSuite.java
index ebd7d6b3..18f84434 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/LayoutTestSuite.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/LayoutTestSuite.java
@@ -39,8 +39,8 @@ import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
/**
- * Runs several suites of layout tests. Each suite is defined in an XML file.
- * The XML files to run are registered in the suite() method.
+ * Runs several suites of layout tests. Each suite is defined in an XML file. The XML files to run are registered in the
+ * suite() method.
*/
public class LayoutTestSuite extends TestCase {
@@ -68,8 +68,9 @@ public class LayoutTestSuite extends TestCase {
xmlReader.parse(new InputSource(url.toString()));
final TestSuite suite = new TestSuite(filename);
- for (final TestCase test : builder.testCases)
+ for (final TestCase test : builder.testCases) {
suite.addTest(test);
+ }
return suite;
}
@@ -132,29 +133,34 @@ public class LayoutTestSuite extends TestCase {
assertEquals(boxSpec.element, box.getElement().getPrefixedName());
}
- if (boxSpec.text != null && box instanceof TextBox)
+ if (boxSpec.text != null && box instanceof TextBox) {
assertEquals(boxSpec.text, ((TextBox) box).getText());
+ }
- if (!boxSpec.children.isEmpty() && box.getChildren() == null)
+ if (!boxSpec.children.isEmpty() && box.getChildren() == null) {
fail("Expected " + boxSpec.children.size() + " children, but " + boxSpec.className + "'s children is null");
+ }
if (boxSpec.children.size() != box.getChildren().length) {
System.out.println("Wrong number of child boxes");
System.out.println(" Expected:");
for (final BoxSpec childSpec : boxSpec.children) {
System.out.print(" " + childSpec.className);
- if (childSpec.text != null)
+ if (childSpec.text != null) {
System.out.print(" '" + childSpec.text + "'");
+ }
System.out.println();
}
System.out.println(" Actual:");
- for (final Box childBox : box.getChildren())
+ for (final Box childBox : box.getChildren()) {
System.out.println(" " + childBox.getClass() + ": " + childBox);
+ }
fail("Wrong number of child boxes.");
}
- for (int i = 0; i < boxSpec.children.size(); i++)
+ for (int i = 0; i < boxSpec.children.size(); i++) {
assertBox(boxSpec.children.get(i), box.getChildren()[i], indent + " ");
+ }
}
@@ -171,22 +177,26 @@ public class LayoutTestSuite extends TestCase {
public void characters(final char[] ch, final int start, final int length) throws SAXException {
final String s = new String(ch, start, length).trim();
- if (s.length() > 0)
- if (inDoc)
+ if (s.length() > 0) {
+ if (inDoc) {
testCase.doc = new String(ch, start, length);
- else
+ } else {
throw new IllegalStateException();
+ }
+ }
}
@Override
public void endElement(final String uri, final String localName, final String qName) throws SAXException {
if (qName.equals("box")) {
- if (boxSpecs.isEmpty())
+ if (boxSpecs.isEmpty()) {
boxSpec = null;
- else
+ } else {
boxSpec = boxSpecs.pop();
- } else if (qName.equals("doc"))
+ }
+ } else if (qName.equals("doc")) {
inDoc = false;
+ }
}
@Override
@@ -195,8 +205,9 @@ public class LayoutTestSuite extends TestCase {
if (qName.equals("testcases")) {
testCases = new ArrayList<TestCase>();
css = attributes.getValue("css");
- if (css == null)
+ if (css == null) {
css = "test.css";
+ }
testCase = null;
boxSpecs = new Stack<BoxSpec>();
} else if (qName.equals("test")) {
@@ -204,26 +215,28 @@ public class LayoutTestSuite extends TestCase {
testCase.id = attributes.getValue("id");
testCase.css = css;
final String layoutWidth = attributes.getValue("layoutWidth");
- if (layoutWidth != null)
+ if (layoutWidth != null) {
testCase.layoutWidth = Integer.parseInt(layoutWidth);
+ }
testCases.add(testCase);
- } else if (qName.equals("doc"))
+ } else if (qName.equals("doc")) {
inDoc = true;
- else if (qName.equals("result")) {
+ } else if (qName.equals("result")) {
} else if (qName.equals("box")) {
final BoxSpec parent = boxSpec;
boxSpec = new BoxSpec();
boxSpec.className = attributes.getValue("class");
boxSpec.element = attributes.getValue("element");
boxSpec.text = attributes.getValue("text");
- if (parent == null)
+ if (parent == null) {
testCase.result = boxSpec;
- else {
+ } else {
boxSpecs.push(parent);
parent.children.add(boxSpec);
}
- } else
+ } else {
throw new SAXException("Unrecognized element: " + qName);
+ }
}
}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/MockBoxFactory.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/MockBoxFactory.java
index bc6c571b..b92585ef 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/MockBoxFactory.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/MockBoxFactory.java
@@ -11,16 +11,10 @@
package org.eclipse.vex.core.internal.layout;
import org.eclipse.vex.core.internal.dom.Element;
-import org.eclipse.vex.core.internal.layout.BlockElementBox;
-import org.eclipse.vex.core.internal.layout.Box;
-import org.eclipse.vex.core.internal.layout.CssBoxFactory;
-import org.eclipse.vex.core.internal.layout.LayoutContext;
-import org.eclipse.vex.core.internal.layout.SpaceBox;
/**
- * A box factory that, for an element named &lt;space&gt;, returns a SpaceBox
- * with height and width given by attributes of those names, e.g. &lt;space
- * height="100" width="200"/&gt;
+ * A box factory that, for an element named &lt;space&gt;, returns a SpaceBox with height and width given by attributes
+ * of those names, e.g. &lt;space height="100" width="200"/&gt;
*/
public class MockBoxFactory extends CssBoxFactory {
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TableLayoutTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TableLayoutTest.java
index 045ad886..43ed6b9b 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TableLayoutTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TableLayoutTest.java
@@ -23,228 +23,253 @@ import org.eclipse.vex.core.internal.css.StyleSheetReader;
import org.eclipse.vex.core.internal.dom.Document;
import org.eclipse.vex.core.internal.dom.Element;
import org.eclipse.vex.core.internal.dom.RootElement;
-import org.eclipse.vex.core.internal.layout.Box;
-import org.eclipse.vex.core.internal.layout.DocumentTextBox;
-import org.eclipse.vex.core.internal.layout.LayoutContext;
-import org.eclipse.vex.core.internal.layout.RootBox;
-import org.eclipse.vex.core.internal.layout.TableBox;
-import org.eclipse.vex.core.internal.layout.TableCellBox;
-import org.eclipse.vex.core.internal.layout.TableRowBox;
public class TableLayoutTest extends TestCase {
- private static interface StackVisitor {
- void visit(StackElement element);
- }
-
- private static class StackElement {
- public final int indent;
- public final Box box;
- public StackElement(int indent, Box box) {
- this.indent = indent;
- this.box = box;
- }
- }
-
- private LayoutContext context;
- private Document document;
- private RootBox rootBox;
- private int caretPosition;
-
- @Override
- protected void setUp() throws Exception {
-
- // display dummy
- DisplayDevice.setCurrent(new MockDisplayDevice(90, 90));
-
- // context dummy
- context = new LayoutContext();
- context.setBoxFactory(new MockBoxFactory());
- context.setGraphics(new FakeGraphics());
-
- // set CSS
- String css = "root {display:block}"
- + "inline {display:inline}"
- + "table {display:table}"
- + "tcap {display:table-caption}"
- + "td {display:table-cell}"
- + "tc {display:table-column}"
- + "tcg {display:table-column-group}"
- + "tfg {display:table-footer-group}"
- + "thg {display:table-header-group}"
- + "tr {display:table-row}"
- + "trg {display:table-row-group}";
- StyleSheet styleSheet = new StyleSheetReader().read(css);
- context.setStyleSheet(styleSheet);
-
- resetDocument();
- }
-
- @Override
- protected void tearDown() throws Exception {
- rootBox = null;
- document = null;
- context = null;
- }
-
- private void resetDocument() {
- document = new Document(new RootElement("root"));
- context.setDocument(document);
- caretPosition = 1;
- rootBox = new RootBox(this.context, document.getRootElement(), 500);
- }
-
- private void insertElement(String elementName) {
- document.insertElement(caretPosition, new Element(elementName));
- caretPosition++;
- }
-
- private void insertText(String text) {
- document.insertText(caretPosition, text);;
- caretPosition += text.length();
- }
-
- public void testValidTable() throws Exception {
-
- // single cell Table
- insertElement("table");
- insertElement("tr");
- insertElement("td");
- insertText("a");
- assertCount(1, TableBox.class);
- assertCount(1, TableRowBox.class);
- assertCount(1, TableCellBox.class);
- assertCount(1, DocumentTextBox.class);
- assertEquals("a", contentAsText());
-
- // 2x2 table plus text
- resetDocument();
- insertText("_");
- insertElement("table");
- insertElement("tr");
- insertElement("td");
- insertText("a");
- caretPosition++;
- insertElement("td");
- insertText("b");
- caretPosition+=2;
- insertElement("tr");
- insertElement("td");
- insertText("c");
- caretPosition++;
- insertElement("td");
- insertText("d");
- assertCount(1, TableBox.class);
- assertCount(2, TableRowBox.class);
- assertCount(4, TableCellBox.class);
- assertCount(5, DocumentTextBox.class);
- assertEquals("_abcd", contentAsText());
- }
-
- // table elements outside table (separately tested to improve tracing if
- // StackOverflowError will be thrown)
- public void testCaptionOutsideTable() { test("tcap"); }
- public void testCellOutsideTable() { test("td"); }
- public void testColumnOutsideTable() { test("tc"); }
- public void testColumnGroupOutsideTable() { test("tcg"); }
- public void testFooterGroupOutsideTable() { test("tfg"); }
- public void testHeaderGroupOutsideTable() { test("thg"); }
- public void testRowOutsideTable() { test("tr"); }
- public void testRowGroupOutsideTable() { test("trg"); }
-
- // invalid nested table elements (separately tested to improve tracing if
- // StackOverflowError will be thrown)
- public void testInvalidNesting1() { test("inline", "tcap"); }
- public void testInvalidNesting2() { test("table", "td"); }
- public void testInvalidNesting3() { test("td", "tr"); }
- public void testInvalidNesting4() { test("trg", "trg"); }
- public void testInvalidNesting5() { test("tr", "tfg"); }
- public void testInvalidNesting6() { test("td", "thg"); }
- public void testInvalidNesting7() { test("table", "tc"); }
- public void testInvalidNesting8() { test("thg", "tcg"); }
-
- public void test(String ... elements) {
- resetDocument();
- insertElement("inline");
- for (String element : elements) {
- insertElement(element);
+ private static interface StackVisitor {
+ void visit(StackElement element);
+ }
+
+ private static class StackElement {
+ public final int indent;
+ public final Box box;
+
+ public StackElement(final int indent, final Box box) {
+ this.indent = indent;
+ this.box = box;
+ }
+ }
+
+ private LayoutContext context;
+ private Document document;
+ private RootBox rootBox;
+ private int caretPosition;
+
+ @Override
+ protected void setUp() throws Exception {
+
+ // display dummy
+ DisplayDevice.setCurrent(new MockDisplayDevice(90, 90));
+
+ // context dummy
+ context = new LayoutContext();
+ context.setBoxFactory(new MockBoxFactory());
+ context.setGraphics(new FakeGraphics());
+
+ // set CSS
+ final String css = "root {display:block}" + "inline {display:inline}" + "table {display:table}" + "tcap {display:table-caption}" + "td {display:table-cell}"
+ + "tc {display:table-column}" + "tcg {display:table-column-group}" + "tfg {display:table-footer-group}" + "thg {display:table-header-group}"
+ + "tr {display:table-row}" + "trg {display:table-row-group}";
+ final StyleSheet styleSheet = new StyleSheetReader().read(css);
+ context.setStyleSheet(styleSheet);
+
+ resetDocument();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ rootBox = null;
+ document = null;
+ context = null;
+ }
+
+ private void resetDocument() {
+ document = new Document(new RootElement("root"));
+ context.setDocument(document);
+ caretPosition = 1;
+ rootBox = new RootBox(context, document.getRootElement(), 500);
+ }
+
+ private void insertElement(final String elementName) {
+ document.insertElement(caretPosition, new Element(elementName));
+ caretPosition++;
+ }
+
+ private void insertText(final String text) {
+ document.insertText(caretPosition, text);
+ ;
+ caretPosition += text.length();
+ }
+
+ public void testValidTable() throws Exception {
+
+ // single cell Table
+ insertElement("table");
+ insertElement("tr");
+ insertElement("td");
+ insertText("a");
+ assertCount(1, TableBox.class);
+ assertCount(1, TableRowBox.class);
+ assertCount(1, TableCellBox.class);
+ assertCount(1, DocumentTextBox.class);
+ assertEquals("a", contentAsText());
+
+ // 2x2 table plus text
+ resetDocument();
+ insertText("_");
+ insertElement("table");
+ insertElement("tr");
+ insertElement("td");
+ insertText("a");
+ caretPosition++;
+ insertElement("td");
+ insertText("b");
+ caretPosition += 2;
+ insertElement("tr");
+ insertElement("td");
+ insertText("c");
+ caretPosition++;
+ insertElement("td");
+ insertText("d");
+ assertCount(1, TableBox.class);
+ assertCount(2, TableRowBox.class);
+ assertCount(4, TableCellBox.class);
+ assertCount(5, DocumentTextBox.class);
+ assertEquals("_abcd", contentAsText());
+ }
+
+ // table elements outside table (separately tested to improve tracing if
+ // StackOverflowError will be thrown)
+ public void testCaptionOutsideTable() {
+ test("tcap");
+ }
+
+ public void testCellOutsideTable() {
+ test("td");
+ }
+
+ public void testColumnOutsideTable() {
+ test("tc");
+ }
+
+ public void testColumnGroupOutsideTable() {
+ test("tcg");
+ }
+
+ public void testFooterGroupOutsideTable() {
+ test("tfg");
+ }
+
+ public void testHeaderGroupOutsideTable() {
+ test("thg");
+ }
+
+ public void testRowOutsideTable() {
+ test("tr");
+ }
+
+ public void testRowGroupOutsideTable() {
+ test("trg");
+ }
+
+ // invalid nested table elements (separately tested to improve tracing if
+ // StackOverflowError will be thrown)
+ public void testInvalidNesting1() {
+ test("inline", "tcap");
+ }
+
+ public void testInvalidNesting2() {
+ test("table", "td");
+ }
+
+ public void testInvalidNesting3() {
+ test("td", "tr");
+ }
+
+ public void testInvalidNesting4() {
+ test("trg", "trg");
+ }
+
+ public void testInvalidNesting5() {
+ test("tr", "tfg");
+ }
+
+ public void testInvalidNesting6() {
+ test("td", "thg");
+ }
+
+ public void testInvalidNesting7() {
+ test("table", "tc");
+ }
+
+ public void testInvalidNesting8() {
+ test("thg", "tcg");
+ }
+
+ public void test(final String... elements) {
+ resetDocument();
+ insertElement("inline");
+ for (final String element : elements) {
+ insertElement(element);
+ }
+ insertText("x");
+ assertCount(1, DocumentTextBox.class);
+ assertEquals("x", contentAsText());
+ }
+
+ private String contentAsText() {
+ return document.getText(0, document.getLength());
+ }
+
+ private void assertCount(final int expected, final Class<? extends Box> blockClass) {
+ final int count = count(blockClass);
+ final String message = "expected count of <" + blockClass.getSimpleName() + ">: <" + expected + "> but was: <" + count + ">\n" + "Actual layout stack trace:\n" + layoutStackToString();
+ assertEquals(message, expected, count);
+ }
+
+ private int count(final Class<? extends Box> blockClass) {
+ final int[] mutableInteger = new int[1];
+ mutableInteger[0] = 0;
+ travelLayoutStack(new StackVisitor() {
+
+ public void visit(final StackElement element) {
+ if (element.box.getClass().equals(blockClass)) {
+ mutableInteger[0]++;
+ }
+ }
+
+ });
+ return mutableInteger[0];
+ }
+
+ private String layoutStackToString() {
+ final StringBuilder result = new StringBuilder();
+ travelLayoutStack(new StackVisitor() {
+
+ public void visit(final StackElement element) {
+ if (element.indent > 0) {
+ final char[] indentChars = new char[element.indent * 2];
+ Arrays.fill(indentChars, ' ');
+ result.append(indentChars);
+ }
+ result.append(element.box.getClass().getSimpleName());
+ result.append('\n');
+
+ }
+
+ });
+ return result.toString();
+ }
+
+ private void travelLayoutStack(final StackVisitor visitor) {
+
+ // already layouted?
+ final Box[] rootElementChildren = rootBox.getChildren()[0].getChildren();
+ if (rootElementChildren == null || rootElementChildren.length == 0) {
+ rootBox.layout(context, 0, Integer.MAX_VALUE);
}
- insertText("x");
- assertCount(1, DocumentTextBox.class);
- assertEquals("x", contentAsText());
- }
-
- private String contentAsText() {
- return document.getText(0, document.getLength());
- }
-
- private void assertCount(int expected, Class<? extends Box> blockClass) {
- int count = count(blockClass);
- String message = "expected count of <"
- + blockClass.getSimpleName()
- + ">: <"
- + expected
- + "> but was: <"
- + count
- + ">\n"
- + "Actual layout stack trace:\n"
- + layoutStackToString();
- assertEquals(message, expected, count);
- }
-
- private int count(final Class<? extends Box> blockClass) {
- final int[] mutableInteger = new int[1];
- mutableInteger[0] = 0;
- travelLayoutStack(new StackVisitor() {
-
- public void visit(StackElement element) {
- if (element.box.getClass().equals(blockClass)) {
- mutableInteger[0]++;
- }
- }
-
- });
- return mutableInteger[0];
- }
-
- private String layoutStackToString() {
- final StringBuilder result = new StringBuilder();
- travelLayoutStack(new StackVisitor() {
-
- public void visit(StackElement element) {
- if (element.indent > 0) {
- char[] indentChars = new char[element.indent * 2];
- Arrays.fill(indentChars, ' ');
- result.append(indentChars);
- }
- result.append(element.box.getClass().getSimpleName());
- result.append('\n');
-
- }
-
- });
- return result.toString();
- }
-
- private void travelLayoutStack(StackVisitor visitor) {
-
- // already layouted?
- Box[] rootElementChildren = rootBox.getChildren()[0].getChildren();
- if (rootElementChildren == null || rootElementChildren.length == 0) {
- rootBox.layout(this.context, 0, Integer.MAX_VALUE);
- }
-
- Stack<StackElement> stack = new Stack<StackElement>();
- stack.push(new StackElement(0, rootBox));
- while (!stack.isEmpty()) {
- StackElement current = stack.pop();
- visitor.visit(current);
-
- // iterate deep-first
- for (Box child : current.box.getChildren()) {
- stack.push(new StackElement(current.indent + 1, child));
+
+ final Stack<StackElement> stack = new Stack<StackElement>();
+ stack.push(new StackElement(0, rootBox));
+ while (!stack.isEmpty()) {
+ final StackElement current = stack.pop();
+ visitor.visit(current);
+
+ // iterate deep-first
+ for (final Box child : current.box.getChildren()) {
+ stack.push(new StackElement(current.indent + 1, child));
}
- }
- }
+ }
+ }
} \ No newline at end of file
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestBlockElementBox.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestBlockElementBox.java
index 592567b3..c040cbe2 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestBlockElementBox.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestBlockElementBox.java
@@ -19,10 +19,6 @@ import org.eclipse.vex.core.internal.css.StyleSheetReader;
import org.eclipse.vex.core.internal.dom.Document;
import org.eclipse.vex.core.internal.dom.Element;
import org.eclipse.vex.core.internal.dom.RootElement;
-import org.eclipse.vex.core.internal.layout.BlockElementBox;
-import org.eclipse.vex.core.internal.layout.Box;
-import org.eclipse.vex.core.internal.layout.LayoutContext;
-import org.eclipse.vex.core.internal.layout.RootBox;
public class TestBlockElementBox extends TestCase {
@@ -30,26 +26,26 @@ public class TestBlockElementBox extends TestCase {
LayoutContext context;
public TestBlockElementBox() throws Exception {
- URL url = this.getClass().getResource("test.css");
- StyleSheetReader reader = new StyleSheetReader();
- StyleSheet ss = reader.read(url);
+ final URL url = this.getClass().getResource("test.css");
+ final StyleSheetReader reader = new StyleSheetReader();
+ final StyleSheet ss = reader.read(url);
- this.g = new FakeGraphics();
+ g = new FakeGraphics();
- this.context = new LayoutContext();
- this.context.setBoxFactory(new MockBoxFactory());
- this.context.setGraphics(this.g);
- this.context.setStyleSheet(ss);
+ context = new LayoutContext();
+ context.setBoxFactory(new MockBoxFactory());
+ context.setGraphics(g);
+ context.setStyleSheet(ss);
}
-
+
public void testBeforeAfter() throws Exception {
- RootElement root = new RootElement("root");
- Document doc = new Document(root);
+ final RootElement root = new RootElement("root");
+ final Document doc = new Document(root);
doc.insertElement(1, new Element("beforeBlock"));
context.setDocument(doc);
- RootBox rootBox = new RootBox(this.context, root, 500);
- rootBox.layout(this.context, 0, Integer.MAX_VALUE);
+ final RootBox rootBox = new RootBox(context, root, 500);
+ rootBox.layout(context, 0, Integer.MAX_VALUE);
Box[] children;
BlockElementBox beb;
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestBlocksInInlines.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestBlocksInInlines.java
index 54c38f81..30197211 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestBlocksInInlines.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestBlocksInInlines.java
@@ -12,6 +12,8 @@ package org.eclipse.vex.core.internal.layout;
import java.net.URL;
+import junit.framework.TestCase;
+
import org.eclipse.vex.core.internal.core.DisplayDevice;
import org.eclipse.vex.core.internal.css.MockDisplayDevice;
import org.eclipse.vex.core.internal.css.StyleSheet;
@@ -19,14 +21,10 @@ import org.eclipse.vex.core.internal.css.StyleSheetReader;
import org.eclipse.vex.core.internal.dom.Document;
import org.eclipse.vex.core.internal.dom.Element;
import org.eclipse.vex.core.internal.dom.RootElement;
-import org.eclipse.vex.core.internal.layout.LayoutContext;
-import org.eclipse.vex.core.internal.layout.RootBox;
-
-import junit.framework.TestCase;
/**
- * Tests proper function of a block-level element within an inline element.
- * These must be layed out as a block child of the containing block element.
+ * Tests proper function of a block-level element within an inline element. These must be layed out as a block child of
+ * the containing block element.
*/
public class TestBlocksInInlines extends TestCase {
@@ -38,23 +36,23 @@ public class TestBlocksInInlines extends TestCase {
super.setUp();
DisplayDevice.setCurrent(new MockDisplayDevice(90, 90));
}
-
+
public TestBlocksInInlines() throws Exception {
- URL url = this.getClass().getResource("test.css");
- StyleSheetReader reader = new StyleSheetReader();
- StyleSheet ss = reader.read(url);
+ final URL url = this.getClass().getResource("test.css");
+ final StyleSheetReader reader = new StyleSheetReader();
+ final StyleSheet ss = reader.read(url);
- this.g = new FakeGraphics();
+ g = new FakeGraphics();
- this.context = new LayoutContext();
- this.context.setBoxFactory(new MockBoxFactory());
- this.context.setGraphics(this.g);
- this.context.setStyleSheet(ss);
+ context = new LayoutContext();
+ context.setBoxFactory(new MockBoxFactory());
+ context.setGraphics(g);
+ context.setStyleSheet(ss);
}
public void testBlockInInline() throws Exception {
- RootElement root = new RootElement("root");
- Document doc = new Document(root);
+ final RootElement root = new RootElement("root");
+ final Document doc = new Document(root);
context.setDocument(doc);
doc.insertText(1, "one five");
@@ -63,8 +61,8 @@ public class TestBlocksInInlines extends TestCase {
doc.insertElement(10, new Element("p"));
doc.insertText(11, "three");
- RootBox rootBox = new RootBox(this.context, root, 500);
- rootBox.layout(this.context, 0, Integer.MAX_VALUE);
+ final RootBox rootBox = new RootBox(context, root, 500);
+ rootBox.layout(context, 0, Integer.MAX_VALUE);
}
}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestDocumentTextBox.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestDocumentTextBox.java
index 08bbf85d..7e8d8ca9 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestDocumentTextBox.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestDocumentTextBox.java
@@ -12,21 +12,17 @@ package org.eclipse.vex.core.internal.layout;
import java.net.URL;
+import junit.framework.TestCase;
+
import org.eclipse.vex.core.internal.css.StyleSheet;
import org.eclipse.vex.core.internal.css.StyleSheetReader;
import org.eclipse.vex.core.internal.css.Styles;
import org.eclipse.vex.core.internal.dom.Document;
import org.eclipse.vex.core.internal.dom.RootElement;
-import org.eclipse.vex.core.internal.layout.CssBoxFactory;
-import org.eclipse.vex.core.internal.layout.DocumentTextBox;
-import org.eclipse.vex.core.internal.layout.InlineBox;
-import org.eclipse.vex.core.internal.layout.LayoutContext;
-
-import junit.framework.TestCase;
/**
- * Tests the DocumentTestBox class. We focus here on proper offsets, since text
- * splitting is tested thoroughly in TestStaticTextBox.
+ * Tests the DocumentTestBox class. We focus here on proper offsets, since text splitting is tested thoroughly in
+ * TestStaticTextBox.
*/
public class TestDocumentTextBox extends TestCase {
@@ -35,32 +31,32 @@ public class TestDocumentTextBox extends TestCase {
public TestDocumentTextBox() throws Exception {
- URL url = this.getClass().getResource("test.css");
- StyleSheetReader reader = new StyleSheetReader();
- StyleSheet ss = reader.read(url);
+ final URL url = this.getClass().getResource("test.css");
+ final StyleSheetReader reader = new StyleSheetReader();
+ final StyleSheet ss = reader.read(url);
- this.g = new FakeGraphics();
+ g = new FakeGraphics();
- this.context = new LayoutContext();
- this.context.setBoxFactory(new CssBoxFactory());
- this.context.setGraphics(this.g);
- this.context.setStyleSheet(ss);
+ context = new LayoutContext();
+ context.setBoxFactory(new CssBoxFactory());
+ context.setGraphics(g);
+ context.setStyleSheet(ss);
}
public void testSplit() throws Exception {
- RootElement root = new RootElement("root");
- Document doc = new Document(root);
+ final RootElement root = new RootElement("root");
+ final Document doc = new Document(root);
- Styles styles = this.context.getStyleSheet().getStyles(root);
+ final Styles styles = context.getStyleSheet().getStyles(root);
- int width = g.getCharWidth();
+ final int width = g.getCharWidth();
// 0 6 13 21
// / / / /
// baggy orange trousers
doc.insertText(1, "baggy orange trousers");
- DocumentTextBox box = new DocumentTextBox(this.context, root, 1, 22);
+ final DocumentTextBox box = new DocumentTextBox(context, root, 1, 22);
assertEquals(box.getText().length() * width, box.getWidth());
assertEquals(styles.getLineHeight(), box.getHeight());
assertSplit(box, 22, false, "baggy orange ", "trousers");
@@ -91,22 +87,20 @@ public class TestDocumentTextBox extends TestCase {
doc.delete(1, 22);
}
- private void assertSplit(DocumentTextBox box, int splitPos, boolean force,
- String left, String right) {
+ private void assertSplit(final DocumentTextBox box, final int splitPos, final boolean force, final String left, final String right) {
- Styles styles = this.context.getStyleSheet()
- .getStyles(box.getElement());
+ final Styles styles = context.getStyleSheet().getStyles(box.getElement());
- int width = g.getCharWidth();
+ final int width = g.getCharWidth();
- InlineBox.Pair pair = box.split(context, splitPos * width, force);
+ final InlineBox.Pair pair = box.split(context, splitPos * width, force);
- DocumentTextBox leftBox = (DocumentTextBox) pair.getLeft();
- DocumentTextBox rightBox = (DocumentTextBox) pair.getRight();
+ final DocumentTextBox leftBox = (DocumentTextBox) pair.getLeft();
+ final DocumentTextBox rightBox = (DocumentTextBox) pair.getRight();
- int leftOffset = 1;
- int midOffset = leftOffset + (left == null ? 0 : left.length());
- int rightOffset = leftOffset + box.getText().length();
+ final int leftOffset = 1;
+ final int midOffset = leftOffset + (left == null ? 0 : left.length());
+ final int rightOffset = leftOffset + box.getText().length();
if (left == null) {
assertNull(leftBox);
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestParagraphBox.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestParagraphBox.java
index e9e5f663..b641aae1 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestParagraphBox.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestParagraphBox.java
@@ -12,12 +12,10 @@ package org.eclipse.vex.core.internal.layout;
import java.net.URL;
+import junit.framework.TestCase;
+
import org.eclipse.vex.core.internal.css.StyleSheet;
import org.eclipse.vex.core.internal.css.StyleSheetReader;
-import org.eclipse.vex.core.internal.layout.CssBoxFactory;
-import org.eclipse.vex.core.internal.layout.LayoutContext;
-
-import junit.framework.TestCase;
public class TestParagraphBox extends TestCase {
@@ -26,33 +24,30 @@ public class TestParagraphBox extends TestCase {
public TestParagraphBox() throws Exception {
- URL url = this.getClass().getResource("test.css");
- StyleSheetReader reader = new StyleSheetReader();
- StyleSheet ss = reader.read(url);
+ final URL url = this.getClass().getResource("test.css");
+ final StyleSheetReader reader = new StyleSheetReader();
+ final StyleSheet ss = reader.read(url);
- this.g = new FakeGraphics();
+ g = new FakeGraphics();
- this.context = new LayoutContext();
- this.context.setBoxFactory(new CssBoxFactory());
- this.context.setGraphics(this.g);
- this.context.setStyleSheet(ss);
+ context = new LayoutContext();
+ context.setBoxFactory(new CssBoxFactory());
+ context.setGraphics(g);
+ context.setStyleSheet(ss);
}
/*
- * public void testWordWrap() throws Exception { RootElement root = new
- * RootElement("root"); Document doc = new Document(root);
+ * public void testWordWrap() throws Exception { RootElement root = new RootElement("root"); Document doc = new
+ * Document(root);
*
* Styles styles = this.context.getStyleSheet().getStyles(root);
*
* FontMetrics fm = this.g.getFontMetrics();
*
- * // Test Case 1: check the offsets // // UPPER CASE indicates static text
- * // lower case indicates document text // [ ] represent element start and
- * end // // BLACK WHITE GRAY // RED [orange] YELLOW (line is 1:8,
- * last=false) // BLACK WHITE GRAY // [blue] GREEN [pink] (line is 9:20
- * last=true) // BLACK WHITE GRAY // // Document looks like this (# chars
- * are element sentinels // 2 8 16 20 // / / / / // ##orange##blue##pink##
- * // \ \ // 10 14 //
+ * // Test Case 1: check the offsets // // UPPER CASE indicates static text // lower case indicates document text //
+ * [ ] represent element start and end // // BLACK WHITE GRAY // RED [orange] YELLOW (line is 1:8, last=false) //
+ * BLACK WHITE GRAY // [blue] GREEN [pink] (line is 9:20 last=true) // BLACK WHITE GRAY // // Document looks like
+ * this (# chars are element sentinels // 2 8 16 20 // / / / / // ##orange##blue##pink## // \ \ // 10 14 //
*
* }
*/
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestStaticTextBox.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestStaticTextBox.java
index f4c9b185..a4b603d8 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestStaticTextBox.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestStaticTextBox.java
@@ -12,18 +12,14 @@ package org.eclipse.vex.core.internal.layout;
import java.net.URL;
+import junit.framework.TestCase;
+
import org.eclipse.vex.core.internal.core.DisplayDevice;
import org.eclipse.vex.core.internal.css.MockDisplayDevice;
import org.eclipse.vex.core.internal.css.StyleSheet;
import org.eclipse.vex.core.internal.css.StyleSheetReader;
import org.eclipse.vex.core.internal.css.Styles;
import org.eclipse.vex.core.internal.dom.RootElement;
-import org.eclipse.vex.core.internal.layout.CssBoxFactory;
-import org.eclipse.vex.core.internal.layout.InlineBox;
-import org.eclipse.vex.core.internal.layout.LayoutContext;
-import org.eclipse.vex.core.internal.layout.StaticTextBox;
-
-import junit.framework.TestCase;
public class TestStaticTextBox extends TestCase {
@@ -37,31 +33,30 @@ public class TestStaticTextBox extends TestCase {
// TODO Auto-generated method stub
super.setUp();
DisplayDevice.setCurrent(new MockDisplayDevice(90, 90));
- URL url = this.getClass().getResource("test.css");
- StyleSheetReader reader = new StyleSheetReader();
- StyleSheet ss = reader.read(url);
+ final URL url = this.getClass().getResource("test.css");
+ final StyleSheetReader reader = new StyleSheetReader();
+ final StyleSheet ss = reader.read(url);
g = new FakeGraphics();
context = new LayoutContext();
context.setBoxFactory(new CssBoxFactory());
- context.setGraphics(this.g);
+ context.setGraphics(g);
context.setStyleSheet(ss);
styles = context.getStyleSheet().getStyles(root);
-
+
}
-
+
public TestStaticTextBox() throws Exception {
}
public void testSplit() throws Exception {
- int width = g.getCharWidth();
+ final int width = g.getCharWidth();
- StaticTextBox box = new StaticTextBox(this.context, root,
- "baggy orange trousers");
+ final StaticTextBox box = new StaticTextBox(context, root, "baggy orange trousers");
assertEquals(box.getText().length() * width, box.getWidth());
assertEquals(styles.getLineHeight(), box.getHeight());
assertSplit(box, 22, false, "baggy orange ", "trousers");
@@ -89,28 +84,25 @@ public class TestStaticTextBox extends TestCase {
assertSplit(box, 0, true, "b", "aggy orange trousers");
assertSplit(box, -1, true, "b", "aggy orange trousers");
}
-
+
public void testSpaceSplit() throws Exception {
- StaticTextBox box = new StaticTextBox(context, root, "red green");
+ final StaticTextBox box = new StaticTextBox(context, root, "red green");
assertSplit(box, 11, false, "red ", "green");
assertSplit(box, 10, false, "red ", "green");
assertSplit(box, 9, false, "red ", "green");
assertSplit(box, 5, false, "red ", "green");
-
+
}
-
- private void assertSplit(StaticTextBox box, int splitPos, boolean force,
- String left, String right) {
+ private void assertSplit(final StaticTextBox box, final int splitPos, final boolean force, final String left, final String right) {
- Styles styles = this.context.getStyleSheet()
- .getStyles(box.getElement());
- int width = g.getCharWidth();
+ final Styles styles = context.getStyleSheet().getStyles(box.getElement());
+ final int width = g.getCharWidth();
- InlineBox.Pair pair = box.split(context, splitPos * width, force);
+ final InlineBox.Pair pair = box.split(context, splitPos * width, force);
- StaticTextBox leftBox = (StaticTextBox) pair.getLeft();
- StaticTextBox rightBox = (StaticTextBox) pair.getRight();
+ final StaticTextBox leftBox = (StaticTextBox) pair.getLeft();
+ final StaticTextBox rightBox = (StaticTextBox) pair.getRight();
if (left == null) {
assertNull(leftBox);
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/MockHostComponent.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/MockHostComponent.java
index 055df154..b7de8311 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/MockHostComponent.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/MockHostComponent.java
@@ -13,7 +13,6 @@ package org.eclipse.vex.core.internal.widget;
import org.eclipse.vex.core.internal.core.Graphics;
import org.eclipse.vex.core.internal.core.Rectangle;
import org.eclipse.vex.core.internal.layout.FakeGraphics;
-import org.eclipse.vex.core.internal.widget.HostComponent;
public class MockHostComponent implements HostComponent {
@@ -28,19 +27,19 @@ public class MockHostComponent implements HostComponent {
return new Rectangle(0, 0, 0, 0);
}
- public void invokeLater(Runnable runnable) {
+ public void invokeLater(final Runnable runnable) {
}
public void repaint() {
}
- public void repaint(int x, int y, int width, int height) {
+ public void repaint(final int x, final int y, final int width, final int height) {
}
- public void scrollTo(int left, int top) {
+ public void scrollTo(final int left, final int top) {
}
- public void setPreferredSize(int width, int height) {
+ public void setPreferredSize(final int width, final int height) {
}
}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/VexWidgetTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/VexWidgetTest.java
index c0969912..861d8fbc 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/VexWidgetTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/VexWidgetTest.java
@@ -85,24 +85,24 @@ public class VexWidgetTest {
widget.insertText("comment text");
widget.moveBy(1);
widget.insertText("text after comment");
-
+
final String expectedContentStructure = getContentStructure(widget.getDocument().getRootElement());
widget.doWork(new Runnable() {
public void run() {
- widget.moveTo(commentElement.getStartOffset() + 1, false);
- widget.moveTo(commentElement.getEndOffset(), true);
- final DocumentFragment fragment = widget.getSelectedFragment();
- widget.deleteSelection();
- widget.moveBy(-1, false);
- widget.moveBy(2, true);
- widget.deleteSelection();
- widget.insertFragment(fragment);
+ widget.moveTo(commentElement.getStartOffset() + 1, false);
+ widget.moveTo(commentElement.getEndOffset(), true);
+ final DocumentFragment fragment = widget.getSelectedFragment();
+ widget.deleteSelection();
+ widget.moveBy(-1, false);
+ widget.moveBy(2, true);
+ widget.deleteSelection();
+ widget.insertFragment(fragment);
}
});
-
+
widget.undo();
-
+
assertEquals(expectedContentStructure, getContentStructure(widget.getDocument().getRootElement()));
}
@@ -128,8 +128,9 @@ public class VexWidgetTest {
private static String[] sortedCopyOf(final Object[] objects) {
final String[] result = new String[objects.length];
- for (int i = 0; i < result.length; i++)
+ for (int i = 0; i < result.length; i++) {
result[i] = objects[i].toString();
+ }
Arrays.sort(result);
return result;
}
@@ -138,14 +139,15 @@ public class VexWidgetTest {
final StringBuilder result = new StringBuilder();
result.append("<").append(element.getQualifiedName()).append(" (").append(element.getStartOffset()).append("-").append(element.getEndOffset()).append(")");
result.append(" ").append(element.getText());
- List<Node> children = element.getChildNodes();
+ final List<Node> children = element.getChildNodes();
if (!children.isEmpty()) {
result.append(" [");
for (final Node child : children) {
- if (child instanceof Element)
+ if (child instanceof Element) {
result.append(getContentStructure((Element) child));
- else if (child instanceof Text)
+ } else if (child instanceof Text) {
result.append(getContentStructure((Text) child));
+ }
}
result.append("]");
}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/ListenerListTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/ListenerListTest.java
index 6a7b5850..85f7f139 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/ListenerListTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/ListenerListTest.java
@@ -21,113 +21,104 @@ import org.eclipse.vex.core.internal.core.ListenerList;
public class ListenerListTest extends TestCase {
- private ListenerList<MockEventListener, EventObject> listenerList;
- private Exception handledException;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- listenerList = new ListenerList<MockEventListener, EventObject>(MockEventListener.class) {
- @Override
- public void handleException(Exception e) {
- handledException = e;
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- listenerList = null;
- handledException = null;
- super.tearDown();
- }
-
- public static class MockEventListener implements EventListener {
- public int invocations = 0;
- public boolean throwExceptionMethodInvoced;
-
- public void handleEvent(EventObject event) {
- invocations++;
- }
-
- public void throwException(EventObject event) {
- throwExceptionMethodInvoced = true;
- throw new MyException();
- }
-
- }
-
- private static class MyException extends RuntimeException {
+ private ListenerList<MockEventListener, EventObject> listenerList;
+ private Exception handledException;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ listenerList = new ListenerList<MockEventListener, EventObject>(MockEventListener.class) {
+ @Override
+ public void handleException(final Exception e) {
+ handledException = e;
+ }
+ };
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ listenerList = null;
+ handledException = null;
+ super.tearDown();
+ }
+
+ public static class MockEventListener implements EventListener {
+ public int invocations = 0;
+ public boolean throwExceptionMethodInvoced;
+
+ public void handleEvent(final EventObject event) {
+ invocations++;
+ }
+
+ public void throwException(final EventObject event) {
+ throwExceptionMethodInvoced = true;
+ throw new MyException();
+ }
+
+ }
+
+ private static class MyException extends RuntimeException {
private static final long serialVersionUID = 1L;
- }
-
- public void testListenerInvocation() throws Exception {
- final MockEventListener eventListener = new MockEventListener();
-
- listenerList.add(eventListener);
- assertEquals(0, eventListener.invocations);
- listenerList.fireEvent("handleEvent", new EventObject(""));
- assertEquals(1, eventListener.invocations);
- listenerList.fireEvent("handleEvent", new EventObject(""));
- assertEquals(2, eventListener.invocations);
-
- // add another listener
- listenerList.add(new MockEventListener());
- assertEquals(2, eventListener.invocations);
- listenerList.fireEvent("handleEvent", new EventObject(""));
- assertEquals(3, eventListener.invocations);
-
- if (handledException != null) {
- throw handledException;
- }
- }
-
- public void testAddRemove() throws Exception {
- final MockEventListener listener = new MockEventListener();
- final MockEventListener anotherListener = new MockEventListener();
-
-
- listenerList.fireEvent("handleEvent", new EventObject(""));
- assertEquals("The listener should not be invoked if it was never added to the list.",
- 0,
- listener.invocations);
-
- listenerList.add(listener);
- listenerList.fireEvent("handleEvent", new EventObject(""));
- assertEquals("The listener should not be invoked if it was never added to the list.",
- 0,
- anotherListener.invocations);
- assertEquals("The listener should be invoked after it was added to the list",
- 1,
- listener.invocations);
-
- listenerList.remove(listener);
- listenerList.fireEvent("handleEvent", new EventObject(""));
- assertEquals("The listener should not be invoked after it was removed from the list.",
- 1,
- listener.invocations);
-
- if (handledException != null) {
- throw handledException;
- }
- }
-
- public void testNoSuchMethod() throws Exception {
- listenerList.add(new MockEventListener());
- listenerList.fireEvent("unknownMethod", new EventObject(""));
- assertTrue(handledException instanceof NoSuchMethodException);
- }
-
- public void testExceptionWhileFireEvent() throws Exception {
- final MockEventListener eventListener = new MockEventListener();
-
- listenerList.add(eventListener);
- listenerList.fireEvent("throwException", new EventObject(""));
- assertTrue(eventListener.throwExceptionMethodInvoced);
- assertTrue(handledException instanceof InvocationTargetException);
- assertTrue(handledException.getCause() instanceof MyException);
- }
-
+ }
+
+ public void testListenerInvocation() throws Exception {
+ final MockEventListener eventListener = new MockEventListener();
+
+ listenerList.add(eventListener);
+ assertEquals(0, eventListener.invocations);
+ listenerList.fireEvent("handleEvent", new EventObject(""));
+ assertEquals(1, eventListener.invocations);
+ listenerList.fireEvent("handleEvent", new EventObject(""));
+ assertEquals(2, eventListener.invocations);
+
+ // add another listener
+ listenerList.add(new MockEventListener());
+ assertEquals(2, eventListener.invocations);
+ listenerList.fireEvent("handleEvent", new EventObject(""));
+ assertEquals(3, eventListener.invocations);
+
+ if (handledException != null) {
+ throw handledException;
+ }
+ }
+
+ public void testAddRemove() throws Exception {
+ final MockEventListener listener = new MockEventListener();
+ final MockEventListener anotherListener = new MockEventListener();
+
+ listenerList.fireEvent("handleEvent", new EventObject(""));
+ assertEquals("The listener should not be invoked if it was never added to the list.", 0, listener.invocations);
+
+ listenerList.add(listener);
+ listenerList.fireEvent("handleEvent", new EventObject(""));
+ assertEquals("The listener should not be invoked if it was never added to the list.", 0, anotherListener.invocations);
+ assertEquals("The listener should be invoked after it was added to the list", 1, listener.invocations);
+
+ listenerList.remove(listener);
+ listenerList.fireEvent("handleEvent", new EventObject(""));
+ assertEquals("The listener should not be invoked after it was removed from the list.", 1, listener.invocations);
+
+ if (handledException != null) {
+ throw handledException;
+ }
+ }
+
+ public void testNoSuchMethod() throws Exception {
+ listenerList.add(new MockEventListener());
+ listenerList.fireEvent("unknownMethod", new EventObject(""));
+ assertTrue(handledException instanceof NoSuchMethodException);
+ }
+
+ public void testExceptionWhileFireEvent() throws Exception {
+ final MockEventListener eventListener = new MockEventListener();
+
+ listenerList.add(eventListener);
+ listenerList.fireEvent("throwException", new EventObject(""));
+ assertTrue(eventListener.throwExceptionMethodInvoced);
+ assertTrue(handledException instanceof InvocationTargetException);
+ assertTrue(handledException.getCause() instanceof MyException);
+ }
+
}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/TestResources.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/TestResources.java
index 22a48dff..85de261c 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/TestResources.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/TestResources.java
@@ -20,18 +20,18 @@ import java.net.URL;
* @author Florian Thienel
*/
public class TestResources {
-
+
public static final String STRUCTURE_NS = "http://www.eclipse.org/vex/test/structure";
public static final String CONTENT_NS = "http://www.eclipse.org/vex/test/content";
public static final String TEST_DTD = "-//Eclipse Foundation//DTD Vex Test//EN";
private static final String ROOT_DIRECTORY = "/testResources/";
-
+
public static URL get(final String name) {
return VEXCoreTestPlugin.getDefault().getBundle().getEntry(ROOT_DIRECTORY + name);
}
- public static InputStream getAsStream(String name) throws IOException {
+ public static InputStream getAsStream(final String name) throws IOException {
final URL url = get(name);
return url.openStream();
}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/VEXCoreTestPlugin.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/VEXCoreTestPlugin.java
index 87bcdb89..4d45e70a 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/VEXCoreTestPlugin.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/tests/VEXCoreTestPlugin.java
@@ -23,11 +23,10 @@ public class VEXCoreTestPlugin extends AbstractUIPlugin {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
- * )
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext )
*/
- public void start(BundleContext context) throws Exception {
+ @Override
+ public void start(final BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
@@ -35,11 +34,10 @@ public class VEXCoreTestPlugin extends AbstractUIPlugin {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
- * )
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext )
*/
- public void stop(BundleContext context) throws Exception {
+ @Override
+ public void stop(final BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
diff --git a/org.eclipse.vex.core/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.vex.core/.settings/org.eclipse.jdt.core.prefs
index f23f0b07..89d4b848 100644
--- a/org.eclipse.vex.core/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.vex.core/.settings/org.eclipse.jdt.core.prefs
@@ -1,12 +1,291 @@
-#Fri Oct 24 20:14:12 GMT 2008
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
+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_resources_in_try=80
+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.alignment_for_union_type_in_multicatch=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=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=false
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=120
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
+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=false
+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_field=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=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_annotation_on_type=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_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=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=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_semicolon_in_try_resources=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_try=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_try=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_semicolon_in_try_resources=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=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=200
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.tabulation.char=tab
+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_before_or_operator_multicatch=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
diff --git a/org.eclipse.vex.core/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.vex.core/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 00000000..b8381b1e
--- /dev/null
+++ b/org.eclipse.vex.core/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,56 @@
+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=true
+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=true
+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=true
+cleanup.make_private_fields_final=true
+cleanup.make_type_abstract_if_missing_method=false
+cleanup.make_variable_declarations_final=true
+cleanup.never_use_blocks=false
+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=false
+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=true
+cleanup.use_this_for_non_static_field_access=true
+cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+cleanup.use_this_for_non_static_method_access=true
+cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+cleanup_profile=_Vex
+cleanup_settings_version=2
+eclipse.preferences.version=1
+formatter_profile=_Vex
+formatter_settings_version=12
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/VEXCorePlugin.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/VEXCorePlugin.java
index 95a55a4c..59a036c5 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/VEXCorePlugin.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/VEXCorePlugin.java
@@ -21,8 +21,9 @@ public class VEXCorePlugin extends AbstractUIPlugin {
private static VEXCorePlugin instance;
public VEXCorePlugin() {
- if (instance != null)
+ if (instance != null) {
throw new IllegalStateException("This plug-in must be a singleton."); //$NON-NLS-1$
+ }
instance = this;
}
@@ -30,11 +31,13 @@ public class VEXCorePlugin extends AbstractUIPlugin {
return instance;
}
- public void start(BundleContext bundleContext) throws Exception {
+ @Override
+ public void start(final BundleContext bundleContext) throws Exception {
super.start(bundleContext);
}
- public void stop(BundleContext context) throws Exception {
+ @Override
+ public void stop(final BundleContext context) throws Exception {
super.stop(context);
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Caret.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Caret.java
index 09ef8103..6855ee55 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Caret.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Caret.java
@@ -11,8 +11,7 @@
package org.eclipse.vex.core.internal.core;
/**
- * Represents the caret, a line that indicates an insertion point in the
- * document.
+ * Represents the caret, a line that indicates an insertion point in the document.
*/
public abstract class Caret {
@@ -27,7 +26,7 @@ public abstract class Caret {
* @param y
* y-coordinate of the top left corner of the caret
*/
- public Caret(int x, int y) {
+ public Caret(final int x, final int y) {
this.x = x;
this.y = y;
}
@@ -51,14 +50,14 @@ public abstract class Caret {
* Returns the x-coordinate of the top left corner of the caret
*/
public int getX() {
- return this.x;
+ return x;
}
/**
* Returns the y-coordinate of the top left corner of the caret
*/
public int getY() {
- return this.y;
+ return y;
}
/**
@@ -69,7 +68,7 @@ public abstract class Caret {
* @param y
* amount by which to move the caret down
*/
- public void translate(int x, int y) {
+ public void translate(final int x, final int y) {
this.x += x;
this.y += y;
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Color.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Color.java
index 78d717a4..33e10d5c 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Color.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Color.java
@@ -11,9 +11,8 @@
package org.eclipse.vex.core.internal.core;
/**
- * Toolkit-independent representation of a color. Colors consist of three
- * integers in the range 0..255 representing red, green, and blue components.
- * Objects of this class are immutable.
+ * Toolkit-independent representation of a color. Colors consist of three integers in the range 0..255 representing red,
+ * green, and blue components. Objects of this class are immutable.
*/
public class Color {
@@ -33,7 +32,7 @@ public class Color {
* @param blue
* blue value, 0..255
*/
- public Color(int red, int green, int blue) {
+ public Color(final int red, final int green, final int blue) {
this.red = red;
this.green = green;
this.blue = blue;
@@ -60,29 +59,36 @@ public class Color {
return red;
}
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null) return false;
- if (getClass() != obj.getClass()) return false;
-
- Color other = (Color) obj;
- return red == other.red
- && green == other.green
- && blue == other.blue;
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ final Color other = (Color) obj;
+ return red == other.red && green == other.green && blue == other.blue;
}
+ @Override
public int hashCode() {
- return this.red + this.green << 16 + this.blue << 24;
+ return red + green << 16 + blue << 24;
}
+ @Override
public String toString() {
- StringBuffer sb = new StringBuffer(20);
+ final StringBuffer sb = new StringBuffer(20);
sb.append("Color[r=");
- sb.append(this.red);
+ sb.append(red);
sb.append(",g=");
- sb.append(this.green);
+ sb.append(green);
sb.append(",b=");
- sb.append(this.blue);
+ sb.append(blue);
sb.append("]");
return sb.toString();
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/ColorResource.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/ColorResource.java
index a44c37b2..eef4b68b 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/ColorResource.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/ColorResource.java
@@ -11,9 +11,8 @@
package org.eclipse.vex.core.internal.core;
/**
- * Wrapper for a toolkit-defined color. Color objects are system resources. They
- * should be retrieved with the Graphics.createColor method and should be
- * disposed when no longer needed.
+ * Wrapper for a toolkit-defined color. Color objects are system resources. They should be retrieved with the
+ * Graphics.createColor method and should be disposed when no longer needed.
*/
public interface ColorResource {
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/DisplayDevice.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/DisplayDevice.java
index ede95eab..d82af09b 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/DisplayDevice.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/DisplayDevice.java
@@ -11,8 +11,7 @@
package org.eclipse.vex.core.internal.core;
/**
- * Represents a device that can display graphics. This class is subclassed for
- * each target system.
+ * Represents a device that can display graphics. This class is subclassed for each target system.
*/
public abstract class DisplayDevice {
@@ -27,7 +26,7 @@ public abstract class DisplayDevice {
return 0;
}
};
-
+
/**
* Class constructor.
*/
@@ -52,13 +51,12 @@ public abstract class DisplayDevice {
public abstract int getVerticalPPI();
/**
- * Sets the current display device. This is typically called by the
- * platform-specific widget;
+ * Sets the current display device. This is typically called by the platform-specific widget;
*
* @param current
* The device to use as the current device.
*/
- public static void setCurrent(DisplayDevice current) {
+ public static void setCurrent(final DisplayDevice current) {
DisplayDevice.current = current;
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/ElementName.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/ElementName.java
index f2f9eaec..e294aca9 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/ElementName.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/ElementName.java
@@ -18,34 +18,35 @@ import org.eclipse.core.runtime.QualifiedName;
public class ElementName {
private final QualifiedName qualifiedName;
-
+
private final String prefix;
-
- public ElementName(QualifiedName qualifiedName, String prefix) {
+
+ public ElementName(final QualifiedName qualifiedName, final String prefix) {
this.qualifiedName = qualifiedName;
this.prefix = prefix;
}
-
+
public QualifiedName getQualifiedName() {
return qualifiedName;
}
-
+
public String getQualifier() {
return qualifiedName.getQualifier();
}
-
+
public String getLocalName() {
return qualifiedName.getLocalName();
}
-
+
public String getPrefix() {
return prefix;
}
-
+
@Override
public String toString() {
- if (prefix == null)
+ if (prefix == null) {
return qualifiedName.getLocalName();
+ }
return prefix + ":" + qualifiedName.getLocalName();
}
@@ -53,31 +54,38 @@ public class ElementName {
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((prefix == null) ? 0 : prefix.hashCode());
- result = prime * result + ((qualifiedName == null) ? 0 : qualifiedName.hashCode());
+ result = prime * result + (prefix == null ? 0 : prefix.hashCode());
+ result = prime * result + (qualifiedName == null ? 0 : qualifiedName.hashCode());
return result;
}
@Override
- public boolean equals(Object obj) {
- if (this == obj)
+ public boolean equals(final Object obj) {
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
- ElementName other = (ElementName) obj;
+ }
+ final ElementName other = (ElementName) obj;
if (prefix == null) {
- if (other.prefix != null)
+ if (other.prefix != null) {
return false;
- } else if (!prefix.equals(other.prefix))
+ }
+ } else if (!prefix.equals(other.prefix)) {
return false;
+ }
if (qualifiedName == null) {
- if (other.qualifiedName != null)
+ if (other.qualifiedName != null) {
return false;
- } else if (!qualifiedName.equals(other.qualifiedName))
+ }
+ } else if (!qualifiedName.equals(other.qualifiedName)) {
return false;
+ }
return true;
}
-
+
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/FontResource.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/FontResource.java
index 15e382b5..328e409d 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/FontResource.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/FontResource.java
@@ -11,9 +11,8 @@
package org.eclipse.vex.core.internal.core;
/**
- * Wrapper for a toolkit-defined font. Fonts are system-defined resources. They
- * must be retrieved from the Graphics.createFont method, and must be disposed
- * when no longer needed.
+ * Wrapper for a toolkit-defined font. Fonts are system-defined resources. They must be retrieved from the
+ * Graphics.createFont method, and must be disposed when no longer needed.
*/
public interface FontResource {
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/FontSpec.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/FontSpec.java
index 1a2059a5..04bebd2d 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/FontSpec.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/FontSpec.java
@@ -12,14 +12,12 @@
package org.eclipse.vex.core.internal.core;
/**
- * Toolkit-independent specifier of a font. This class does not encapsulate an
- * actual font, but simply the information needed for the toolkit to find an
- * actual font.
+ * Toolkit-independent specifier of a font. This class does not encapsulate an actual font, but simply the information
+ * needed for the toolkit to find an actual font.
*
* <p>
- * An array of font family names may be specified. If more than one name is
- * specified, the toolkit should select the first name that matches an actual
- * font on the platform.
+ * An array of font family names may be specified. If more than one name is specified, the toolkit should select the
+ * first name that matches an actual font on the platform.
* </p>
*/
public class FontSpec {
@@ -31,9 +29,9 @@ public class FontSpec {
public static final int OVERLINE = 1 << 3;
public static final int LINE_THROUGH = 1 << 4;
- private String[] names;
- private float size;
- private int style;
+ private final String[] names;
+ private final float size;
+ private final int style;
/**
* Class constructor.
@@ -45,7 +43,7 @@ public class FontSpec {
* @param size
* Size of the font, in points.
*/
- public FontSpec(String[] names, int style, float size) {
+ public FontSpec(final String[] names, final int style, final float size) {
this.names = names;
this.style = style;
this.size = size;
@@ -66,8 +64,7 @@ public class FontSpec {
}
/**
- * Returns a bitwise-OR of the style flags. The following sample checks if
- * the font is bold.
+ * Returns a bitwise-OR of the style flags. The following sample checks if the font is bold.
*
* <pre>
* if (font.getStyle | VexFont.BOLD) {
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Graphics.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Graphics.java
index 0d0558e0..9a52a140 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Graphics.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Graphics.java
@@ -14,8 +14,8 @@ package org.eclipse.vex.core.internal.core;
import java.net.URL;
/**
- * Interface through which Vex performs graphics operations. Implemented by
- * adapters to the java.awt.Graphics and org.eclipse.swt.graphics.GC classes.
+ * Interface through which Vex performs graphics operations. Implemented by adapters to the java.awt.Graphics and
+ * org.eclipse.swt.graphics.GC classes.
*/
public interface Graphics {
@@ -51,8 +51,8 @@ public interface Graphics {
public void drawRect(int x, int y, int width, int height);
- public void drawImage(Image image, int x, int y, int width, int height);
-
+ public void drawImage(Image image, int x, int y, int width, int height);
+
public void fillOval(int x, int y, int width, int height);
public void fillRect(int x, int y, int width, int height);
@@ -70,7 +70,7 @@ public interface Graphics {
public ColorResource getSystemColor(int id);
public FontMetrics getFontMetrics();
-
+
public Image getImage(URL url);
public boolean isAntiAliased();
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Image.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Image.java
index c63bc7bd..91598a99 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Image.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Image.java
@@ -15,5 +15,6 @@ package org.eclipse.vex.core.internal.core;
*/
public interface Image {
int getHeight();
+
int getWidth();
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Insets.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Insets.java
index 5ca6d09f..74439004 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Insets.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Insets.java
@@ -15,10 +15,10 @@ package org.eclipse.vex.core.internal.core;
*/
public class Insets {
- private int top;
- private int left;
- private int bottom;
- private int right;
+ private final int top;
+ private final int left;
+ private final int bottom;
+ private final int right;
/** Zero insets */
public static final Insets ZERO_INSETS = new Insets(0, 0, 0, 0);
@@ -35,7 +35,7 @@ public class Insets {
* @param right
* Right inset.
*/
- public Insets(int top, int left, int bottom, int right) {
+ public Insets(final int top, final int left, final int bottom, final int right) {
this.top = top;
this.left = left;
this.bottom = bottom;
@@ -70,17 +70,18 @@ public class Insets {
return right;
}
+ @Override
public String toString() {
- StringBuffer sb = new StringBuffer(80);
+ final StringBuffer sb = new StringBuffer(80);
sb.append(Insets.class.getName());
sb.append("[top=");
- sb.append(this.getTop());
+ sb.append(getTop());
sb.append(",left=");
- sb.append(this.getLeft());
+ sb.append(getLeft());
sb.append(",bottom=");
- sb.append(this.getBottom());
+ sb.append(getBottom());
sb.append(",right=");
- sb.append(this.getRight());
+ sb.append(getRight());
sb.append("]");
return sb.toString();
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/IntRange.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/IntRange.java
index a268b48b..ade273b6 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/IntRange.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/IntRange.java
@@ -11,8 +11,8 @@
package org.eclipse.vex.core.internal.core;
/**
- * Represents a range of integers. Zero-length ranges (i.e. ranges where start
- * == end) are permitted. This class is immutable.
+ * Represents a range of integers. Zero-length ranges (i.e. ranges where start == end) are permitted. This class is
+ * immutable.
*/
public class IntRange {
@@ -24,10 +24,9 @@ public class IntRange {
* @param end
* End of the range. Must be >= start.
*/
- public IntRange(int start, int end) {
+ public IntRange(final int start, final int end) {
if (start > end) {
- throw new IllegalArgumentException("start (" + start
- + ") is greater than end (" + end + ")");
+ throw new IllegalArgumentException("start (" + start + ") is greater than end (" + end + ")");
}
this.start = start;
this.end = end;
@@ -37,28 +36,26 @@ public class IntRange {
* Returns the start of the range.
*/
public int getStart() {
- return this.start;
+ return start;
}
/**
* Returns the end of the range.
*/
public int getEnd() {
- return this.end;
+ return end;
}
/**
- * Returns the range that represents the intersection of this range and the
- * given range. If the ranges do not intersect, returns null. May return an
- * empty range.
+ * Returns the range that represents the intersection of this range and the given range. If the ranges do not
+ * intersect, returns null. May return an empty range.
*
* @param range
* Range with which to perform an intersection.
*/
- public IntRange intersection(IntRange range) {
- if (this.intersects(range)) {
- return new IntRange(Math.max(this.start, range.start), Math.min(
- this.end, range.end));
+ public IntRange intersection(final IntRange range) {
+ if (intersects(range)) {
+ return new IntRange(Math.max(start, range.start), Math.min(end, range.end));
} else {
return null;
}
@@ -66,14 +63,13 @@ public class IntRange {
}
/**
- * Returns true if this range intersects the given range, even if the result
- * would be an empty range.
+ * Returns true if this range intersects the given range, even if the result would be an empty range.
*
* @param range
* Range with which to intersect.
*/
- public boolean intersects(IntRange range) {
- return this.start <= range.end && this.end >= range.start;
+ public boolean intersects(final IntRange range) {
+ return start <= range.end && end >= range.start;
}
/**
@@ -84,20 +80,19 @@ public class IntRange {
}
/**
- * Returns a range that is the union of this range and the given range. If
- * the ranges are disjoint, the gap between the ranges is included in the
- * result.
+ * Returns a range that is the union of this range and the given range. If the ranges are disjoint, the gap between
+ * the ranges is included in the result.
*
* @param range
* Rnage with which to perform the union
*/
- public IntRange union(IntRange range) {
- return new IntRange(Math.min(this.start, range.start), Math.min(
- this.end, range.end));
+ public IntRange union(final IntRange range) {
+ return new IntRange(Math.min(start, range.start), Math.min(end, range.end));
}
+ @Override
public String toString() {
- StringBuffer sb = new StringBuffer();
+ final StringBuffer sb = new StringBuffer();
sb.append("IntRange(");
sb.append(start);
sb.append(",");
@@ -108,6 +103,6 @@ public class IntRange {
// ============================================================= PRIVATE
- private int start;
- private int end;
+ private final int start;
+ private final int end;
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/ListenerList.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/ListenerList.java
index 94d03a48..0eec2096 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/ListenerList.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/ListenerList.java
@@ -20,102 +20,108 @@ import java.util.List;
import java.util.Map;
/**
- * A collection of listener objects. The main point of this class is the
- * fireEvent method, which takes care of the tedium of iterating over the
- * collection and catching exceptions generated by listeners.
- *
- * @param <L> the type of listeners maintained by this list
- * @param <E> the type of events to fire
+ * A collection of listener objects. The main point of this class is the fireEvent method, which takes care of the
+ * tedium of iterating over the collection and catching exceptions generated by listeners.
+ *
+ * @param <L>
+ * the type of listeners maintained by this list
+ * @param <E>
+ * the type of events to fire
*/
public class ListenerList<L, E extends EventObject> {
- private final Class<L> listenerClass;
+ private final Class<L> listenerClass;
private final List<L> listeners = new ArrayList<L>();
- /** Mapping: method name => method object */
- private Map<String, Method> methods = new HashMap<String, Method>();
-
+ /** Mapping: method name => method object */
+ private final Map<String, Method> methods = new HashMap<String, Method>();
+
/**
* Class constructor.
*
- * @param listenerClass Class of the listener interface.
+ * @param listenerClass
+ * Class of the listener interface.
*/
- public ListenerList(Class<L> listenerClass) {
+ public ListenerList(final Class<L> listenerClass) {
this.listenerClass = listenerClass;
}
- /**
- * Adds a listener to the list. Rejects listeners that are not subclasses of
- * the listener class passed to the constructor.
- *
- * @param listener Listener to be added.
- */
- public void add(L listener) {
- this.listeners.add(listener);
- }
+ /**
+ * Adds a listener to the list. Rejects listeners that are not subclasses of the listener class passed to the
+ * constructor.
+ *
+ * @param listener
+ * Listener to be added.
+ */
+ public void add(final L listener) {
+ this.listeners.add(listener);
+ }
+
+ /**
+ * Removes a listener from the list.
+ *
+ * @param listener
+ * Listener to remove.
+ */
+ public void remove(final L listener) {
+ this.listeners.remove(listener);
+ }
+
+ /**
+ * Called from fireEvent whenever a called listener method throws an exception, or if there is a problem looking up
+ * the listener method by reflection. By default, simply prints the stack trace to stdout. Clients may override this
+ * method to provide a more suitable implementation.
+ *
+ * @param e
+ * Exception thrown by the listener method.
+ */
+ public void handleException(final Exception e) {
+ e.printStackTrace();
+ }
- /**
- * Removes a listener from the list.
- *
- * @param listener
- * Listener to remove.
- */
- public void remove(L listener) {
- this.listeners.remove(listener);
- }
-
- /**
- * Called from fireEvent whenever a called listener method throws an
- * exception, or if there is a problem looking up the listener method by
- * reflection. By default, simply prints the stack trace to stdout. Clients
- * may override this method to provide a more suitable implementation.
- *
- * @param e Exception thrown by the listener method.
- */
- public void handleException(Exception e) {
- e.printStackTrace();
- }
+ /**
+ * Calls the given method on each registered listener. Any exception thrown from one of the called methods is passed
+ * to handleException, as is any introspection error, e.g. if the given method doesn't exist.
+ *
+ * @param methodName
+ * Listener method to call.
+ * @param event
+ * Event to be passed to each call.
+ */
+ public void fireEvent(final String methodName, final E event) {
+ final Method method = getMethod(methodName, event.getClass());
+ if (method == null) {
+ return; // Exception handling already done by getMethod
+ }
- /**
- * Calls the given method on each registered listener. Any exception thrown
- * from one of the called methods is passed to handleException, as is any
- * introspection error, e.g. if the given method doesn't exist.
- *
- * @param methodName Listener method to call.
- * @param event Event to be passed to each call.
- */
- public void fireEvent(String methodName, E event) {
- final Method method = getMethod(methodName, event.getClass());
- if (method == null)
- return; // Exception handling already done by getMethod
+ for (final L listener : listeners) {
+ try {
+ method.invoke(listener, event);
+ } catch (final IllegalArgumentException e) {
+ handleException(e);
+ } catch (final IllegalAccessException e) {
+ handleException(e);
+ } catch (final InvocationTargetException e) {
+ handleException(e);
+ }
+ }
+ }
- for (L listener : listeners) {
- try {
- method.invoke(listener, event);
- } catch (IllegalArgumentException e) {
- handleException(e);
- } catch (IllegalAccessException e) {
- handleException(e);
- } catch (InvocationTargetException e) {
- handleException(e);
- }
- }
- }
+ private Method getMethod(final String methodName, final Class<?> eventClass) {
+ if (this.methods.containsKey(methodName)) {
+ return this.methods.get(methodName);
+ }
- private Method getMethod(String methodName, Class<?> eventClass) {
- if (this.methods.containsKey(methodName))
- return this.methods.get(methodName);
-
try {
- Method method = listenerClass.getMethod(methodName, eventClass);
+ final Method method = listenerClass.getMethod(methodName, eventClass);
this.methods.put(methodName, method);
return method;
- } catch (SecurityException e) {
+ } catch (final SecurityException e) {
handleException(e);
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
handleException(e);
}
return null;
- }
+ }
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Point.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Point.java
index fd25bc66..37387fd7 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Point.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Point.java
@@ -15,8 +15,8 @@ package org.eclipse.vex.core.internal.core;
*/
public class Point {
- private int x;
- private int y;
+ private final int x;
+ private final int y;
/**
* Class constructor.
@@ -26,18 +26,19 @@ public class Point {
* @param y
* Y-coordinate.
*/
- public Point(int x, int y) {
+ public Point(final int x, final int y) {
this.x = x;
this.y = y;
}
+ @Override
public String toString() {
- StringBuffer sb = new StringBuffer(80);
+ final StringBuffer sb = new StringBuffer(80);
sb.append(Point.class.getName());
sb.append("[x=");
- sb.append(this.getX());
+ sb.append(getX());
sb.append(",y=");
- sb.append(this.getY());
+ sb.append(getY());
sb.append("]");
return sb.toString();
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/QualifiedNameComparator.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/QualifiedNameComparator.java
index 8916bcce..b79c764b 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/QualifiedNameComparator.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/QualifiedNameComparator.java
@@ -19,7 +19,7 @@ import org.eclipse.core.runtime.QualifiedName;
*/
public class QualifiedNameComparator implements Comparator<QualifiedName> {
- public int compare(QualifiedName name1, QualifiedName name2) {
+ public int compare(final QualifiedName name1, final QualifiedName name2) {
return name1.toString().compareTo(name2.toString());
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Rectangle.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Rectangle.java
index fca20097..5f6e0e60 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Rectangle.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Rectangle.java
@@ -15,35 +15,34 @@ package org.eclipse.vex.core.internal.core;
*/
public class Rectangle {
- private int x;
- private int y;
- private int width;
- private int height;
+ private final int x;
+ private final int y;
+ private final int width;
+ private final int height;
- public Rectangle(int x, int y, int width, int height) {
+ public Rectangle(final int x, final int y, final int width, final int height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
- public boolean intersects(Rectangle rect) {
- return rect.x < this.x + this.width && rect.x + rect.width > this.x
- && rect.y < this.y + this.height
- && rect.y + rect.height > this.y;
+ public boolean intersects(final Rectangle rect) {
+ return rect.x < x + width && rect.x + rect.width > x && rect.y < y + height && rect.y + rect.height > y;
}
+ @Override
public String toString() {
- StringBuffer sb = new StringBuffer(80);
+ final StringBuffer sb = new StringBuffer(80);
sb.append(Rectangle.class.getName());
sb.append("[x=");
- sb.append(this.getX());
+ sb.append(getX());
sb.append(",y=");
- sb.append(this.getY());
+ sb.append(getY());
sb.append(",width=");
- sb.append(this.getWidth());
+ sb.append(getWidth());
sb.append(",height=");
- sb.append(this.getHeight());
+ sb.append(getHeight());
sb.append("]");
return sb.toString();
}
@@ -82,11 +81,11 @@ public class Rectangle {
* @param rect
* Rectangle with which to union this one.
*/
- public Rectangle union(Rectangle rect) {
- int left = Math.min(this.x, rect.x);
- int top = Math.min(this.y, rect.y);
- int right = Math.max(this.x + this.width, rect.x + rect.width);
- int bottom = Math.max(this.y + this.height, rect.y + rect.height);
+ public Rectangle union(final Rectangle rect) {
+ final int left = Math.min(x, rect.x);
+ final int top = Math.min(y, rect.y);
+ final int right = Math.max(x + width, rect.x + rect.width);
+ final int bottom = Math.max(y + height, rect.y + rect.height);
return new Rectangle(left, top, right - left, bottom - top);
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/AbstractProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/AbstractProperty.java
index c00a411e..28e4d5da 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/AbstractProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/AbstractProperty.java
@@ -13,9 +13,8 @@ package org.eclipse.vex.core.internal.css;
import org.w3c.css.sac.LexicalUnit;
/**
- * Abstract base class for property classes. Implements the <code>name</code>
- * property but leaves the implementation of <code>calculate</code> to the
- * subclass.
+ * Abstract base class for property classes. Implements the <code>name</code> property but leaves the implementation of
+ * <code>calculate</code> to the subclass.
*/
public abstract class AbstractProperty implements IProperty {
@@ -25,52 +24,45 @@ public abstract class AbstractProperty implements IProperty {
* @param name
* Name of the property.
*/
- public AbstractProperty(String name) {
+ public AbstractProperty(final String name) {
this.name = name;
}
/**
* Returns true if the given lexical unit represents the token "inherit".
*/
- public static boolean isInherit(LexicalUnit lu) {
+ public static boolean isInherit(final LexicalUnit lu) {
return lu != null && lu.getLexicalUnitType() == LexicalUnit.SAC_INHERIT;
}
public String getName() {
- return this.name;
+ return name;
}
- public static boolean isPercentage(LexicalUnit lu) {
- return lu != null
- && lu.getLexicalUnitType() == LexicalUnit.SAC_PERCENTAGE;
+ public static boolean isPercentage(final LexicalUnit lu) {
+ return lu != null && lu.getLexicalUnitType() == LexicalUnit.SAC_PERCENTAGE;
}
- public static boolean isLength(LexicalUnit lu) {
+ public static boolean isLength(final LexicalUnit lu) {
if (lu == null) {
return false;
}
- short type = lu.getLexicalUnitType();
+ final short type = lu.getLexicalUnitType();
if (type == LexicalUnit.SAC_INTEGER && lu.getIntegerValue() == 0) {
return true;
}
- return type == LexicalUnit.SAC_CENTIMETER
- || type == LexicalUnit.SAC_DIMENSION
- || type == LexicalUnit.SAC_EM || type == LexicalUnit.SAC_EX
- || type == LexicalUnit.SAC_INCH
- || type == LexicalUnit.SAC_MILLIMETER
- || type == LexicalUnit.SAC_PICA
- || type == LexicalUnit.SAC_PIXEL
- || type == LexicalUnit.SAC_POINT;
+ return type == LexicalUnit.SAC_CENTIMETER || type == LexicalUnit.SAC_DIMENSION || type == LexicalUnit.SAC_EM || type == LexicalUnit.SAC_EX || type == LexicalUnit.SAC_INCH
+ || type == LexicalUnit.SAC_MILLIMETER || type == LexicalUnit.SAC_PICA || type == LexicalUnit.SAC_PIXEL || type == LexicalUnit.SAC_POINT;
}
- public static int getIntLength(LexicalUnit lu, float fontSize, int ppi) {
+ public static int getIntLength(final LexicalUnit lu, final float fontSize, final int ppi) {
return Math.round(getFloatLength(lu, fontSize, ppi));
}
- public static float getFloatLength(LexicalUnit lu, float fontSize, int ppi) {
+ public static float getFloatLength(final LexicalUnit lu, final float fontSize, final int ppi) {
float value = 0f;
@@ -109,24 +101,21 @@ public abstract class AbstractProperty implements IProperty {
// ============================================================== PRIVATE
- public static boolean isNumber(LexicalUnit lu) {
- return lu != null
- && (lu.getLexicalUnitType() == LexicalUnit.SAC_INTEGER || lu
- .getLexicalUnitType() == LexicalUnit.SAC_REAL);
+ public static boolean isNumber(final LexicalUnit lu) {
+ return lu != null && (lu.getLexicalUnitType() == LexicalUnit.SAC_INTEGER || lu.getLexicalUnitType() == LexicalUnit.SAC_REAL);
}
- public static float getNumber(LexicalUnit lu) {
+ public static float getNumber(final LexicalUnit lu) {
if (lu.getLexicalUnitType() == LexicalUnit.SAC_INTEGER) {
return lu.getIntegerValue();
} else if (lu.getLexicalUnitType() == LexicalUnit.SAC_REAL) {
return lu.getFloatValue();
} else {
- throw new RuntimeException("LexicalUnit type "
- + lu.getLexicalUnitType() + " is not a numeric type.");
+ throw new RuntimeException("LexicalUnit type " + lu.getLexicalUnitType() + " is not a numeric type.");
}
}
- private String name;
+ private final String name;
private static final float EX_FACTOR = 0.6f;
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BackgroundImageProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BackgroundImageProperty.java
index 740ef52d..410485c7 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BackgroundImageProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BackgroundImageProperty.java
@@ -30,22 +30,24 @@ public class BackgroundImageProperty extends AbstractProperty {
}
public Object calculate(final LexicalUnit lexicalUnit, final Styles parentStyles, final Styles styles, final Element element) {
- if (lexicalUnit == null)
+ if (lexicalUnit == null) {
return DEFAULT;
+ }
switch (lexicalUnit.getLexicalUnitType()) {
case LexicalUnit.SAC_STRING_VALUE:
return lexicalUnit.getStringValue();
case LexicalUnit.SAC_ATTR:
final String attributeValue = element.getAttributeValue(lexicalUnit.getStringValue());
- if (attributeValue != null)
+ if (attributeValue != null) {
return attributeValue;
+ }
return DEFAULT;
default:
VEXCorePlugin
.getInstance()
.getLog()
- .log(new Status(IStatus.WARNING, VEXCorePlugin.ID, MessageFormat.format(
- "Unsupported lexical unit type in ''background-image: {0}'' (type: {1})", lexicalUnit.toString(), lexicalUnit.getLexicalUnitType())));
+ .log(new Status(IStatus.WARNING, VEXCorePlugin.ID, MessageFormat.format("Unsupported lexical unit type in ''background-image: {0}'' (type: {1})", lexicalUnit.toString(),
+ lexicalUnit.getLexicalUnitType())));
return DEFAULT;
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BorderSpacingProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BorderSpacingProperty.java
index 1a58809c..f3eb417f 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BorderSpacingProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BorderSpacingProperty.java
@@ -20,17 +20,17 @@ import org.w3c.css.sac.LexicalUnit;
public class BorderSpacingProperty extends AbstractProperty {
/**
- * Represents the computed value of border-spacing, which is a pair of
- * values representing vertical and horizontal spacing.
+ * Represents the computed value of border-spacing, which is a pair of values representing vertical and horizontal
+ * spacing.
*/
public static class Value {
- private int horizontal;
- private int vertical;
+ private final int horizontal;
+ private final int vertical;
public static final Value ZERO = new Value(0, 0);
- public Value(int horizontal, int vertical) {
+ public Value(final int horizontal, final int vertical) {
this.horizontal = horizontal;
this.vertical = vertical;
}
@@ -39,14 +39,14 @@ public class BorderSpacingProperty extends AbstractProperty {
* Returns the horizontal spacing, in pixels.
*/
public int getHorizontal() {
- return this.horizontal;
+ return horizontal;
}
/**
* Returns the vertical spacing, in pixels.
*/
public int getVertical() {
- return this.vertical;
+ return vertical;
}
}
@@ -57,20 +57,18 @@ public class BorderSpacingProperty extends AbstractProperty {
super(CSS.BORDER_SPACING);
}
- public Object calculate(LexicalUnit lu, Styles parentStyles, Styles styles, Element element) {
+ public Object calculate(LexicalUnit lu, final Styles parentStyles, final Styles styles, final Element element) {
int horizontal = 0;
int vertical = 0;
- DisplayDevice device = DisplayDevice.getCurrent();
+ final DisplayDevice device = DisplayDevice.getCurrent();
if (isLength(lu)) {
- horizontal = getIntLength(lu, styles.getFontSize(), device
- .getHorizontalPPI());
+ horizontal = getIntLength(lu, styles.getFontSize(), device.getHorizontalPPI());
lu = lu.getNextLexicalUnit();
if (isLength(lu)) {
- vertical = getIntLength(lu, styles.getFontSize(), device
- .getVerticalPPI());
+ vertical = getIntLength(lu, styles.getFontSize(), device.getVerticalPPI());
} else {
vertical = horizontal;
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BorderStyleProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BorderStyleProperty.java
index b9864e95..b6e8a59d 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BorderStyleProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BorderStyleProperty.java
@@ -24,7 +24,7 @@ public class BorderStyleProperty extends AbstractProperty {
* @param name
* Name of the property.
*/
- public BorderStyleProperty(String name) {
+ public BorderStyleProperty(final String name) {
super(name);
}
@@ -34,26 +34,23 @@ public class BorderStyleProperty extends AbstractProperty {
* @param lu
* LexicalUnit to check.
*/
- public static boolean isBorderStyle(LexicalUnit lu) {
+ public static boolean isBorderStyle(final LexicalUnit lu) {
if (lu == null) {
return false;
} else if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
- String s = lu.getStringValue();
- return s.equals(CSS.NONE) || s.equals(CSS.HIDDEN)
- || s.equals(CSS.DOTTED) || s.equals(CSS.DASHED)
- || s.equals(CSS.SOLID) || s.equals(CSS.DOUBLE)
- || s.equals(CSS.GROOVE) || s.equals(CSS.RIDGE)
- || s.equals(CSS.INSET) || s.equals(CSS.OUTSET);
+ final String s = lu.getStringValue();
+ return s.equals(CSS.NONE) || s.equals(CSS.HIDDEN) || s.equals(CSS.DOTTED) || s.equals(CSS.DASHED) || s.equals(CSS.SOLID) || s.equals(CSS.DOUBLE) || s.equals(CSS.GROOVE)
+ || s.equals(CSS.RIDGE) || s.equals(CSS.INSET) || s.equals(CSS.OUTSET);
}
return false;
}
- public Object calculate(LexicalUnit lu, Styles parentStyles, Styles styles, Element element) {
+ public Object calculate(final LexicalUnit lu, final Styles parentStyles, final Styles styles, final Element element) {
if (isBorderStyle(lu)) {
return lu.getStringValue();
} else if (isInherit(lu) && parentStyles != null) {
- return parentStyles.get(this.getName());
+ return parentStyles.get(getName());
} else {
return CSS.NONE;
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BorderWidthProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BorderWidthProperty.java
index 6dc949e8..1cbd85b5 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BorderWidthProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/BorderWidthProperty.java
@@ -15,29 +15,28 @@ import org.eclipse.vex.core.internal.dom.Element;
import org.w3c.css.sac.LexicalUnit;
/**
- * The border-XXX-width CSS property. Since the value of this property depends
- * on the corresponding border-XXX-style property, the style property must be
- * calculated first and placed in the styles, and its name given to the
- * constructor of this class.
+ * The border-XXX-width CSS property. Since the value of this property depends on the corresponding border-XXX-style
+ * property, the style property must be calculated first and placed in the styles, and its name given to the constructor
+ * of this class.
*/
public class BorderWidthProperty extends AbstractProperty {
// Name of the corresponding border style property
- private String borderStyleName;
+ private final String borderStyleName;
// Axis along which the border width is measured.
- private Axis axis;
+ private final Axis axis;
// named border widths
private static final int BORDER_WIDTH_THIN = 1;
private static final int BORDER_WIDTH_MEDIUM = 3;
private static final int BORDER_WIDTH_THICK = 5;
- private static int getBorderWidth(LexicalUnit lu, float fontSize, int ppi) {
+ private static int getBorderWidth(final LexicalUnit lu, final float fontSize, final int ppi) {
if (isLength(lu)) {
return getIntLength(lu, fontSize, ppi);
} else if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
- String s = lu.getStringValue();
+ final String s = lu.getStringValue();
if (s.equals(CSS.THIN)) {
return BORDER_WIDTH_THIN;
} else if (s.equals(CSS.MEDIUM)) {
@@ -58,14 +57,12 @@ public class BorderWidthProperty extends AbstractProperty {
* @param name
* Name of the property.
* @param borderStyleName
- * Name of the corresponding border style property. For example,
- * if name is CSS.BORDER_TOP_WIDTH, then borderStyleName should
- * be CSS.BORDER_TOP_STYLE.
+ * Name of the corresponding border style property. For example, if name is CSS.BORDER_TOP_WIDTH, then
+ * borderStyleName should be CSS.BORDER_TOP_STYLE.
* @param axis
- * AXIS_HORIZONTAL (for left and right borders) or AXIS_VERTICAL
- * (for top and bottom borders).
+ * AXIS_HORIZONTAL (for left and right borders) or AXIS_VERTICAL (for top and bottom borders).
*/
- public BorderWidthProperty(String name, String borderStyleName, Axis axis) {
+ public BorderWidthProperty(final String name, final String borderStyleName, final Axis axis) {
super(name);
this.borderStyleName = borderStyleName;
this.axis = axis;
@@ -77,39 +74,36 @@ public class BorderWidthProperty extends AbstractProperty {
* @param lu
* LexicalUnit to check.
*/
- public static boolean isBorderWidth(LexicalUnit lu) {
+ public static boolean isBorderWidth(final LexicalUnit lu) {
if (lu == null) {
return false;
} else if (isLength(lu)) {
return true;
} else if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
- String s = lu.getStringValue();
- return s.equals(CSS.THIN) || s.equals(CSS.MEDIUM)
- || s.equals(CSS.THICK);
+ final String s = lu.getStringValue();
+ return s.equals(CSS.THIN) || s.equals(CSS.MEDIUM) || s.equals(CSS.THICK);
} else {
return false;
}
}
- public Object calculate(LexicalUnit lu, Styles parentStyles, Styles styles, Element element) {
+ public Object calculate(final LexicalUnit lu, final Styles parentStyles, final Styles styles, final Element element) {
return Integer.valueOf(calculateInternal(lu, parentStyles, styles));
}
- private int calculateInternal(LexicalUnit lu, Styles parentStyles,
- Styles styles) {
+ private int calculateInternal(final LexicalUnit lu, final Styles parentStyles, final Styles styles) {
- DisplayDevice device = DisplayDevice.getCurrent();
- int ppi = this.axis == Axis.HORIZONTAL ? device.getHorizontalPPI()
- : device.getVerticalPPI();
+ final DisplayDevice device = DisplayDevice.getCurrent();
+ final int ppi = axis == Axis.HORIZONTAL ? device.getHorizontalPPI() : device.getVerticalPPI();
- String borderStyle = (String) styles.get(this.borderStyleName);
+ final String borderStyle = (String) styles.get(borderStyleName);
if (borderStyle.equals(CSS.NONE) || borderStyle.equals(CSS.HIDDEN)) {
return 0;
} else if (isBorderWidth(lu)) {
return getBorderWidth(lu, styles.getFontSize(), ppi);
} else if (isInherit(lu) && parentStyles != null) {
- return ((Integer) parentStyles.get(this.getName())).intValue();
+ return ((Integer) parentStyles.get(getName())).intValue();
} else {
// not specified, "none", or other unknown value
return BORDER_WIDTH_MEDIUM;
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/ColorProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/ColorProperty.java
index 54e5f013..7b33b3be 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/ColorProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/ColorProperty.java
@@ -45,40 +45,37 @@ public class ColorProperty extends AbstractProperty {
}
/**
- * Class constructor. The names CSS.COLOR and CSS.BACKGROUND_COLOR are
- * treated specially, as follows.
+ * Class constructor. The names CSS.COLOR and CSS.BACKGROUND_COLOR are treated specially, as follows.
*
* <ul>
* <li>If name is CSS.COLOR, it is inherited and defaults to black.</li>
- * <li>If name is CSS.BACKGROUND_COLOR, it is not inherited and defaults to
- * transparent (null).</li>
+ * <li>If name is CSS.BACKGROUND_COLOR, it is not inherited and defaults to transparent (null).</li>
* <li>Otherwise, it is not inherited and defaults to the current color.</li>
* </ul>
*
* <p>
- * Because of the default in the third case, the ColorProperty for CSS.COLOR
- * must be processed before any others.
+ * Because of the default in the third case, the ColorProperty for CSS.COLOR must be processed before any others.
* </p>
*
* @param name
* Name of the element.
*/
- public ColorProperty(String name) {
+ public ColorProperty(final String name) {
super(name);
}
- public Object calculate(LexicalUnit lu, Styles parentStyles, Styles styles, Element element) {
+ public Object calculate(final LexicalUnit lu, final Styles parentStyles, final Styles styles, final Element element) {
- boolean inherit = isInherit(lu) || this.getName().equals(CSS.COLOR);
+ final boolean inherit = isInherit(lu) || getName().equals(CSS.COLOR);
if (isColor(lu)) {
return getColor(lu);
} else if (inherit && parentStyles != null) {
- return parentStyles.get(this.getName());
+ return parentStyles.get(getName());
} else {
- if (this.getName().equals(CSS.COLOR)) {
+ if (getName().equals(CSS.COLOR)) {
return Color.BLACK;
- } else if (this.getName().equals(CSS.BACKGROUND_COLOR)) {
+ } else if (getName().equals(CSS.BACKGROUND_COLOR)) {
return null; // transparent
} else {
return styles.getColor();
@@ -92,11 +89,10 @@ public class ColorProperty extends AbstractProperty {
* @param lu
* LexicalUnit to check.
*/
- public static boolean isColor(LexicalUnit lu) {
+ public static boolean isColor(final LexicalUnit lu) {
if (lu == null) {
return false;
- } else if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT
- && colorNames.containsKey(lu.getStringValue())) {
+ } else if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT && colorNames.containsKey(lu.getStringValue())) {
return true;
} else if (lu.getLexicalUnitType() == LexicalUnit.SAC_RGBCOLOR) {
return true;
@@ -109,21 +105,21 @@ public class ColorProperty extends AbstractProperty {
private static Color getColor(LexicalUnit lu) {
if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
- String s = lu.getStringValue();
+ final String s = lu.getStringValue();
if (colorNames.containsKey(s)) {
- return (Color) colorNames.get(s);
+ return colorNames.get(s);
} else {
return null;
}
} else if (lu.getLexicalUnitType() == LexicalUnit.SAC_RGBCOLOR) {
lu = lu.getParameters();
- int red = getColorPart(lu);
+ final int red = getColorPart(lu);
lu = lu.getNextLexicalUnit(); // gobble comma
lu = lu.getNextLexicalUnit();
- int green = getColorPart(lu);
+ final int green = getColorPart(lu);
lu = lu.getNextLexicalUnit(); // gobble comma
lu = lu.getNextLexicalUnit();
- int blue = getColorPart(lu);
+ final int blue = getColorPart(lu);
if (red == -1 || green == -1 || blue == -1) {
return null;
@@ -137,10 +133,9 @@ public class ColorProperty extends AbstractProperty {
}
/**
- * Converts one of the color channels into an int from 0-255, or -1 if
- * there's an error.
+ * Converts one of the color channels into an int from 0-255, or -1 if there's an error.
*/
- private static int getColorPart(LexicalUnit lu) {
+ private static int getColorPart(final LexicalUnit lu) {
int value;
if (lu.getLexicalUnitType() == LexicalUnit.SAC_INTEGER) {
value = lu.getIntegerValue();
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/DisplayProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/DisplayProperty.java
index 894f972d..f0075073 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/DisplayProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/DisplayProperty.java
@@ -25,7 +25,7 @@ public class DisplayProperty extends AbstractProperty {
super(CSS.DISPLAY);
}
- public Object calculate(LexicalUnit lu, Styles parentStyles, Styles styles, Element element) {
+ public Object calculate(final LexicalUnit lu, final Styles parentStyles, final Styles styles, final Element element) {
if (isDisplay(lu)) {
return lu.getStringValue();
@@ -40,27 +40,19 @@ public class DisplayProperty extends AbstractProperty {
// ======================================================== PRIVATE
/**
- * Returns true if the value of the given LexicalUnit represents a valid
- * value for this property.
+ * Returns true if the value of the given LexicalUnit represents a valid value for this property.
*
* @param lu
* LexicalUnit to inspect.
*/
- private static boolean isDisplay(LexicalUnit lu) {
+ private static boolean isDisplay(final LexicalUnit lu) {
if (lu == null) {
return false;
} else if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
- String s = lu.getStringValue();
- return s.equals(CSS.BLOCK) || s.equals(CSS.INLINE)
- || s.equals(CSS.INLINE_BLOCK) || s.equals(CSS.INLINE_TABLE)
- || s.equals(CSS.LIST_ITEM) || s.equals(CSS.NONE)
- || s.equals(CSS.RUN_IN) || s.equals(CSS.TABLE)
- || s.equals(CSS.TABLE_CAPTION) || s.equals(CSS.TABLE_CELL)
- || s.equals(CSS.TABLE_COLUMN)
- || s.equals(CSS.TABLE_COLUMN_GROUP)
- || s.equals(CSS.TABLE_FOOTER_GROUP)
- || s.equals(CSS.TABLE_HEADER_GROUP)
- || s.equals(CSS.TABLE_ROW) || s.equals(CSS.TABLE_ROW_GROUP);
+ final String s = lu.getStringValue();
+ return s.equals(CSS.BLOCK) || s.equals(CSS.INLINE) || s.equals(CSS.INLINE_BLOCK) || s.equals(CSS.INLINE_TABLE) || s.equals(CSS.LIST_ITEM) || s.equals(CSS.NONE) || s.equals(CSS.RUN_IN)
+ || s.equals(CSS.TABLE) || s.equals(CSS.TABLE_CAPTION) || s.equals(CSS.TABLE_CELL) || s.equals(CSS.TABLE_COLUMN) || s.equals(CSS.TABLE_COLUMN_GROUP)
+ || s.equals(CSS.TABLE_FOOTER_GROUP) || s.equals(CSS.TABLE_HEADER_GROUP) || s.equals(CSS.TABLE_ROW) || s.equals(CSS.TABLE_ROW_GROUP);
} else {
return false;
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontFamilyProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontFamilyProperty.java
index d9943c89..b6400b58 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontFamilyProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontFamilyProperty.java
@@ -30,7 +30,7 @@ public class FontFamilyProperty extends AbstractProperty {
super(CSS.FONT_FAMILY);
}
- public Object calculate(LexicalUnit lu, Styles parentStyles, Styles styles, Element element) {
+ public Object calculate(final LexicalUnit lu, final Styles parentStyles, final Styles styles, final Element element) {
if (isFontFamily(lu)) {
return getFontFamilies(lu);
} else {
@@ -38,26 +38,23 @@ public class FontFamilyProperty extends AbstractProperty {
if (parentStyles != null) {
return parentStyles.getFontFamilies();
} else {
- String[] fonts = new String[DEFAULT_FONT_FAMILY.length];
+ final String[] fonts = new String[DEFAULT_FONT_FAMILY.length];
System.arraycopy(DEFAULT_FONT_FAMILY, 0, fonts, 0, DEFAULT_FONT_FAMILY.length);
return fonts;
}
}
}
-
+
private static final String[] DEFAULT_FONT_FAMILY = new String[] { "sans-serif" };
- private static boolean isFontFamily(LexicalUnit lu) {
- return lu != null
- && (lu.getLexicalUnitType() == LexicalUnit.SAC_STRING_VALUE || lu
- .getLexicalUnitType() == LexicalUnit.SAC_IDENT);
+ private static boolean isFontFamily(final LexicalUnit lu) {
+ return lu != null && (lu.getLexicalUnitType() == LexicalUnit.SAC_STRING_VALUE || lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT);
}
private static String[] getFontFamilies(LexicalUnit lu) {
- List<String> list = new ArrayList<String>();
+ final List<String> list = new ArrayList<String>();
while (lu != null) {
- if (lu.getLexicalUnitType() == LexicalUnit.SAC_STRING_VALUE
- || lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
+ if (lu.getLexicalUnitType() == LexicalUnit.SAC_STRING_VALUE || lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
list.add(lu.getStringValue());
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontSizeProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontSizeProperty.java
index 7fc491c9..e714571e 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontSizeProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontSizeProperty.java
@@ -15,9 +15,8 @@ import org.eclipse.vex.core.internal.dom.Element;
import org.w3c.css.sac.LexicalUnit;
/**
- * The CSS font-size property. Note that other lengths depend on the computed
- * value of this property, so this should be evaluated early on in the
- * stylesheet, before any other lengths.
+ * The CSS font-size property. Note that other lengths depend on the computed value of this property, so this should be
+ * evaluated early on in the stylesheet, before any other lengths.
*/
public class FontSizeProperty extends AbstractProperty {
@@ -28,8 +27,8 @@ public class FontSizeProperty extends AbstractProperty {
super(CSS.FONT_SIZE);
}
- public Object calculate(LexicalUnit lu, Styles parentStyles, Styles styles, Element element) {
- return new Float(this.calculateInternal(lu, parentStyles, styles));
+ public Object calculate(final LexicalUnit lu, final Styles parentStyles, final Styles styles, final Element element) {
+ return new Float(calculateInternal(lu, parentStyles, styles));
}
/**
@@ -38,7 +37,7 @@ public class FontSizeProperty extends AbstractProperty {
* @param lu
* LexicalUnit to check.
*/
- public static boolean isFontSize(LexicalUnit lu) {
+ public static boolean isFontSize(final LexicalUnit lu) {
if (lu == null) {
return false;
} else if (isLength(lu)) {
@@ -46,12 +45,9 @@ public class FontSizeProperty extends AbstractProperty {
} else if (isPercentage(lu)) {
return true;
} else if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
- String s = lu.getStringValue();
- return s.equals(CSS.XX_SMALL) || s.equals(CSS.X_SMALL)
- || s.equals(CSS.SMALL) || s.equals(CSS.MEDIUM)
- || s.equals(CSS.LARGE) || s.equals(CSS.X_LARGE)
- || s.equals(CSS.XX_LARGE) || s.equals(CSS.SMALLER)
- || s.equals(CSS.LARGER);
+ final String s = lu.getStringValue();
+ return s.equals(CSS.XX_SMALL) || s.equals(CSS.X_SMALL) || s.equals(CSS.SMALL) || s.equals(CSS.MEDIUM) || s.equals(CSS.LARGE) || s.equals(CSS.X_LARGE) || s.equals(CSS.XX_LARGE)
+ || s.equals(CSS.SMALLER) || s.equals(CSS.LARGER);
} else {
return false;
}
@@ -59,12 +55,10 @@ public class FontSizeProperty extends AbstractProperty {
// ======================================================== PRIVATE
- private float calculateInternal(LexicalUnit lu, Styles parentStyles,
- Styles styles) {
+ private float calculateInternal(final LexicalUnit lu, final Styles parentStyles, final Styles styles) {
- DisplayDevice device = DisplayDevice.getCurrent();
- float baseFontSize = DEFAULT_FONT_SIZE_POINTS * device.getVerticalPPI()
- / 72;
+ final DisplayDevice device = DisplayDevice.getCurrent();
+ float baseFontSize = DEFAULT_FONT_SIZE_POINTS * device.getVerticalPPI() / 72;
if (parentStyles != null) {
baseFontSize = parentStyles.getFontSize();
@@ -77,7 +71,7 @@ public class FontSizeProperty extends AbstractProperty {
} else if (isPercentage(lu)) {
return baseFontSize * lu.getFloatValue() / 100;
} else if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
- String s = lu.getStringValue();
+ final String s = lu.getStringValue();
if (s.equals(CSS.XX_SMALL)) {
return baseFontSize * FONT_FACTOR_XX_SMALL;
@@ -123,22 +117,16 @@ public class FontSizeProperty extends AbstractProperty {
// Sizes of named font sizes, relative to "medium"
private static final float FONT_FACTOR_MEDIUM = 1.0f;
- private static final float FONT_FACTOR_SMALL = FONT_FACTOR_MEDIUM
- / FONT_SIZE_FACTOR;
+ private static final float FONT_FACTOR_SMALL = FONT_FACTOR_MEDIUM / FONT_SIZE_FACTOR;
- private static final float FONT_FACTOR_X_SMALL = FONT_FACTOR_SMALL
- / FONT_SIZE_FACTOR;
+ private static final float FONT_FACTOR_X_SMALL = FONT_FACTOR_SMALL / FONT_SIZE_FACTOR;
- private static final float FONT_FACTOR_XX_SMALL = FONT_FACTOR_X_SMALL
- / FONT_SIZE_FACTOR;
+ private static final float FONT_FACTOR_XX_SMALL = FONT_FACTOR_X_SMALL / FONT_SIZE_FACTOR;
- private static final float FONT_FACTOR_LARGE = FONT_FACTOR_MEDIUM
- * FONT_SIZE_FACTOR;
+ private static final float FONT_FACTOR_LARGE = FONT_FACTOR_MEDIUM * FONT_SIZE_FACTOR;
- private static final float FONT_FACTOR_X_LARGE = FONT_FACTOR_LARGE
- * FONT_SIZE_FACTOR;
+ private static final float FONT_FACTOR_X_LARGE = FONT_FACTOR_LARGE * FONT_SIZE_FACTOR;
- private static final float FONT_FACTOR_XX_LARGE = FONT_FACTOR_X_LARGE
- * FONT_SIZE_FACTOR;
+ private static final float FONT_FACTOR_XX_LARGE = FONT_FACTOR_X_LARGE * FONT_SIZE_FACTOR;
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontStyleProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontStyleProperty.java
index c32095da..2858adeb 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontStyleProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontStyleProperty.java
@@ -25,7 +25,7 @@ public class FontStyleProperty extends AbstractProperty {
super(CSS.FONT_STYLE);
}
- public Object calculate(LexicalUnit lu, Styles parentStyles, Styles styles, Element element) {
+ public Object calculate(final LexicalUnit lu, final Styles parentStyles, final Styles styles, final Element element) {
if (isFontStyle(lu)) {
return lu.getStringValue();
} else {
@@ -45,13 +45,12 @@ public class FontStyleProperty extends AbstractProperty {
* @param lu
* LexicalUnit to check.
*/
- public static boolean isFontStyle(LexicalUnit lu) {
+ public static boolean isFontStyle(final LexicalUnit lu) {
if (lu == null) {
return false;
} else if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
- String s = lu.getStringValue();
- return s.equals(CSS.NORMAL) || s.equals(CSS.ITALIC)
- || s.equals(CSS.OBLIQUE);
+ final String s = lu.getStringValue();
+ return s.equals(CSS.NORMAL) || s.equals(CSS.ITALIC) || s.equals(CSS.OBLIQUE);
} else {
return false;
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontVariantProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontVariantProperty.java
index 6a6b3fc6..6db1f95c 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontVariantProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontVariantProperty.java
@@ -25,7 +25,7 @@ public class FontVariantProperty extends AbstractProperty {
super(CSS.FONT_VARIANT);
}
- public Object calculate(LexicalUnit lu, Styles parentStyles, Styles styles, Element element) {
+ public Object calculate(final LexicalUnit lu, final Styles parentStyles, final Styles styles, final Element element) {
if (isFontVariant(lu)) {
return lu.getStringValue();
} else {
@@ -45,11 +45,11 @@ public class FontVariantProperty extends AbstractProperty {
* @param lu
* LexicalUnit to check.
*/
- public static boolean isFontVariant(LexicalUnit lu) {
+ public static boolean isFontVariant(final LexicalUnit lu) {
if (lu == null) {
return false;
} else if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
- String s = lu.getStringValue();
+ final String s = lu.getStringValue();
return s.equals(CSS.NORMAL) || s.equals(CSS.SMALL_CAPS);
} else {
return false;
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontWeightProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontWeightProperty.java
index 32fe788c..6e3c9922 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontWeightProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/FontWeightProperty.java
@@ -28,12 +28,11 @@ public class FontWeightProperty extends AbstractProperty {
super(CSS.FONT_WEIGHT);
}
- public Object calculate(LexicalUnit lu, Styles parentStyles, Styles styles, Element element) {
+ public Object calculate(final LexicalUnit lu, final Styles parentStyles, final Styles styles, final Element element) {
return Integer.valueOf(calculateInternal(lu, parentStyles, styles));
}
- public int calculateInternal(LexicalUnit lu, Styles parentStyles,
- Styles styles) {
+ public int calculateInternal(final LexicalUnit lu, final Styles parentStyles, final Styles styles) {
if (isFontWeight(lu)) {
return getFontWeight(lu, parentStyles);
} else {
@@ -53,27 +52,26 @@ public class FontWeightProperty extends AbstractProperty {
* @param lu
* LexicalUnit to check.
*/
- public static boolean isFontWeight(LexicalUnit lu) {
+ public static boolean isFontWeight(final LexicalUnit lu) {
if (lu == null) {
return false;
} else if (lu.getLexicalUnitType() == LexicalUnit.SAC_INTEGER) {
return true;
} else if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
- String s = lu.getStringValue();
- return s.equals(CSS.NORMAL) || s.equals(CSS.BOLD)
- || s.equals(CSS.BOLDER) || s.equals(CSS.LIGHTER);
+ final String s = lu.getStringValue();
+ return s.equals(CSS.NORMAL) || s.equals(CSS.BOLD) || s.equals(CSS.BOLDER) || s.equals(CSS.LIGHTER);
} else {
return false;
}
}
- private static int getFontWeight(LexicalUnit lu, Styles parentStyles) {
+ private static int getFontWeight(final LexicalUnit lu, final Styles parentStyles) {
if (lu == null) {
return FONT_WEIGHT_NORMAL;
} else if (lu.getLexicalUnitType() == LexicalUnit.SAC_INTEGER) {
return lu.getIntegerValue();
} else if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
- String s = lu.getStringValue();
+ final String s = lu.getStringValue();
if (s.equals(CSS.NORMAL)) {
return FONT_WEIGHT_NORMAL;
} else if (s.equals(CSS.BOLD)) {
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/IProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/IProperty.java
index 87b4a16f..e643ea70 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/IProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/IProperty.java
@@ -33,15 +33,12 @@ public interface IProperty {
* @param lu
* LexicalUnit to interpret.
* @param parentStyles
- * Styles of the parent element. These are used when the property
- * inherits a value.
+ * Styles of the parent element. These are used when the property inherits a value.
* @param styles
- * Styles currently in effect. Often, the calculated value
- * depends on previously calculated styles such as font size and
- * color.
+ * Styles currently in effect. Often, the calculated value depends on previously calculated styles such
+ * as font size and color.
* @param element
- * The current element for which this property is calculated. May
- * be null.
+ * The current element for which this property is calculated. May be null.
*/
public Object calculate(LexicalUnit lu, Styles parentStyles, Styles styles, Element element);
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/LengthProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/LengthProperty.java
index 976b6c10..4a590a14 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/LengthProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/LengthProperty.java
@@ -37,18 +37,20 @@ public class LengthProperty extends AbstractProperty {
public Object calculate(final LexicalUnit lu, final Styles parentStyles, final Styles styles, final Element element) {
final int ppi = getPpi();
- if (isAttr(lu))
+ if (isAttr(lu)) {
return calculate(parseAttribute(lu, element), parentStyles, styles, element);
+ }
if (isLength(lu)) {
final int length = getIntLength(lu, styles.getFontSize(), ppi);
return RelativeLength.createAbsolute(length);
- } else if (isPercentage(lu))
+ } else if (isPercentage(lu)) {
return RelativeLength.createRelative(lu.getFloatValue() / 100);
- else if (isInherit(lu) && parentStyles != null)
+ } else if (isInherit(lu) && parentStyles != null) {
return parentStyles.get(getName());
- else
+ } else {
// not specified, "auto", or other unknown value
return RelativeLength.createAbsolute(0);
+ }
}
private static boolean isAttr(final LexicalUnit lexicalUnit) {
@@ -58,8 +60,9 @@ public class LengthProperty extends AbstractProperty {
private static LexicalUnit parseAttribute(final LexicalUnit lexicalUnit, final Element element) {
final String attributeName = lexicalUnit.getStringValue();
final String attributeValue = element.getAttributeValue(attributeName);
- if (attributeValue == null)
+ if (attributeValue == null) {
return null;
+ }
final Parser parser = StyleSheetReader.createParser();
try {
return parser.parsePropertyValue(new InputSource(new StringReader(attributeValue)));
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/LineHeightProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/LineHeightProperty.java
index 053c259d..d3a4f844 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/LineHeightProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/LineHeightProperty.java
@@ -29,17 +29,15 @@ public class LineHeightProperty extends AbstractProperty {
}
/**
- * Calculates the value of the property given a LexicalUnit. Returns a
- * RelativeLength that is relative to the current font size.
+ * Calculates the value of the property given a LexicalUnit. Returns a RelativeLength that is relative to the
+ * current font size.
*/
- public Object calculate(LexicalUnit lu, Styles parentStyles, Styles styles, Element element) {
+ public Object calculate(final LexicalUnit lu, final Styles parentStyles, final Styles styles, final Element element) {
- int ppi = DisplayDevice.getCurrent().getVerticalPPI();
+ final int ppi = DisplayDevice.getCurrent().getVerticalPPI();
if (isLength(lu)) {
- return RelativeLength.createAbsolute(Math.round(getIntLength(lu,
- styles.getFontSize(), ppi)
- / styles.getFontSize()));
+ return RelativeLength.createAbsolute(Math.round(getIntLength(lu, styles.getFontSize(), ppi) / styles.getFontSize()));
} else if (isNumber(lu)) {
if (getNumber(lu) <= 0) {
return RelativeLength.createRelative(LINE_HEIGHT_NORMAL);
@@ -57,7 +55,7 @@ public class LineHeightProperty extends AbstractProperty {
if (parentStyles == null) {
return RelativeLength.createRelative(LINE_HEIGHT_NORMAL);
} else {
- return (RelativeLength) parentStyles.get(CSS.LINE_HEIGHT);
+ return parentStyles.get(CSS.LINE_HEIGHT);
}
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/ListStyleTypeProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/ListStyleTypeProperty.java
index 5ca842fe..56a188a2 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/ListStyleTypeProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/ListStyleTypeProperty.java
@@ -22,7 +22,7 @@ public class ListStyleTypeProperty extends AbstractProperty {
super(CSS.LIST_STYLE_TYPE);
}
- public Object calculate(LexicalUnit lu, Styles parentStyles, Styles styles, Element element) {
+ public Object calculate(final LexicalUnit lu, final Styles parentStyles, final Styles styles, final Element element) {
if (isListStyleType(lu)) {
return lu.getStringValue();
} else {
@@ -35,24 +35,17 @@ public class ListStyleTypeProperty extends AbstractProperty {
}
- private static boolean isListStyleType(LexicalUnit lu) {
+ private static boolean isListStyleType(final LexicalUnit lu) {
if (lu == null || lu.getLexicalUnitType() != LexicalUnit.SAC_IDENT) {
return false;
}
- String s = lu.getStringValue();
- return s.equals(CSS.ARMENIAN) || s.equals(CSS.CIRCLE)
- || s.equals(CSS.CJK_IDEOGRAPHIC) || s.equals(CSS.DECIMAL)
- || s.equals(CSS.DECIMAL_LEADING_ZERO) || s.equals(CSS.DISC)
- || s.equals(CSS.GEORGIAN) || s.equals(CSS.HEBREW)
- || s.equals(CSS.HIRAGANA) || s.equals(CSS.HIRAGANA_IROHA)
- || s.equals(CSS.KATAKANA) || s.equals(CSS.KATAKANA_IROHA)
- || s.equals(CSS.LOWER_ALPHA) || s.equals(CSS.LOWER_GREEK)
- || s.equals(CSS.LOWER_LATIN) || s.equals(CSS.LOWER_ROMAN)
- || s.equals(CSS.NONE) || s.equals(CSS.SQUARE)
- || s.equals(CSS.UPPER_ALPHA) || s.equals(CSS.UPPER_LATIN)
- || s.equals(CSS.UPPER_ROMAN);
+ final String s = lu.getStringValue();
+ return s.equals(CSS.ARMENIAN) || s.equals(CSS.CIRCLE) || s.equals(CSS.CJK_IDEOGRAPHIC) || s.equals(CSS.DECIMAL) || s.equals(CSS.DECIMAL_LEADING_ZERO) || s.equals(CSS.DISC)
+ || s.equals(CSS.GEORGIAN) || s.equals(CSS.HEBREW) || s.equals(CSS.HIRAGANA) || s.equals(CSS.HIRAGANA_IROHA) || s.equals(CSS.KATAKANA) || s.equals(CSS.KATAKANA_IROHA)
+ || s.equals(CSS.LOWER_ALPHA) || s.equals(CSS.LOWER_GREEK) || s.equals(CSS.LOWER_LATIN) || s.equals(CSS.LOWER_ROMAN) || s.equals(CSS.NONE) || s.equals(CSS.SQUARE)
+ || s.equals(CSS.UPPER_ALPHA) || s.equals(CSS.UPPER_LATIN) || s.equals(CSS.UPPER_ROMAN);
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/PropertyDecl.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/PropertyDecl.java
index 0056459a..d1374b59 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/PropertyDecl.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/PropertyDecl.java
@@ -23,12 +23,11 @@ public class PropertyDecl {
private final String property;
private final LexicalUnit value;
private final boolean important;
-
+
/**
* Class constructor.
*/
- public PropertyDecl(Rule rule, String property, LexicalUnit value,
- boolean important) {
+ public PropertyDecl(final Rule rule, final String property, final LexicalUnit value, final boolean important) {
this.rule = rule;
this.property = property;
this.value = value;
@@ -39,28 +38,28 @@ public class PropertyDecl {
* Return the value of the <code>important</code> property.
*/
public boolean isImportant() {
- return this.important;
+ return important;
}
/**
* Return the value of the <code>property</code> property.
*/
public String getProperty() {
- return this.property;
+ return property;
}
/**
* Return the value of the <code>rule</code> property.
*/
public Rule getRule() {
- return this.rule;
+ return rule;
}
/**
* Return the value of the <code>value</code> property.
*/
public LexicalUnit getValue() {
- return this.value;
+ return value;
}
-
+
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/PseudoElement.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/PseudoElement.java
index 7173b4f0..7dc0b72d 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/PseudoElement.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/PseudoElement.java
@@ -28,27 +28,28 @@ public class PseudoElement extends Element {
* @param name
* Name of this pseudo-element, e.g. PseudoElement.BEFORE.
*/
- public PseudoElement(Element parent, String name) {
+ public PseudoElement(final Element parent, final String name) {
super(name);
- this.setParent(parent);
+ setParent(parent);
}
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
- public boolean equals(Object o) {
+ @Override
+ public boolean equals(final Object o) {
if (o == null || o.getClass() != this.getClass()) {
return false;
}
- PseudoElement other = (PseudoElement) o;
- return this.getParent() == other.getParent()
- && this.getQualifiedName().equals(other.getQualifiedName());
+ final PseudoElement other = (PseudoElement) o;
+ return getParent() == other.getParent() && getQualifiedName().equals(other.getQualifiedName());
}
/**
* @see java.lang.Object#hashCode()
*/
+ @Override
public int hashCode() {
- return this.getParent().hashCode() + this.getQualifiedName().hashCode();
+ return getParent().hashCode() + getQualifiedName().hashCode();
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/RelativeLength.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/RelativeLength.java
index 450255bc..93b14a92 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/RelativeLength.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/RelativeLength.java
@@ -10,14 +10,13 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.css;
-
/**
* A length that may be expressed as an absolute or relative value.
*/
public class RelativeLength {
- private float percentage;
- private int absolute;
+ private final float percentage;
+ private final int absolute;
boolean isAbsolute;
private static RelativeLength ZERO = new RelativeLength(0, 0, true);
@@ -27,7 +26,7 @@ public class RelativeLength {
*
* @return the new RelativeLength value.
*/
- public static RelativeLength createAbsolute(int value) {
+ public static RelativeLength createAbsolute(final int value) {
if (value == 0) {
return ZERO;
} else {
@@ -40,32 +39,30 @@ public class RelativeLength {
*
* @return the new RelativeLength value.
*/
- public static RelativeLength createRelative(float percentage) {
+ public static RelativeLength createRelative(final float percentage) {
return new RelativeLength(percentage, 0, false);
}
/**
- * Return the value of the length given a reference value. If this object
- * represents an absolute value, that value is simply returned. Otherwise,
- * returns the given reference length multiplied by the given percentage and
- * rounded to the nearest integer.
+ * Return the value of the length given a reference value. If this object represents an absolute value, that value
+ * is simply returned. Otherwise, returns the given reference length multiplied by the given percentage and rounded
+ * to the nearest integer.
*
* @param referenceLength
- * reference length by which percentage lengths will by
- * multiplied.
+ * reference length by which percentage lengths will by multiplied.
* @return the actual value
*/
- public int get(int referenceLength) {
- if (this.isAbsolute) {
- return this.absolute;
+ public int get(final int referenceLength) {
+ if (isAbsolute) {
+ return absolute;
} else {
- return Math.round(this.percentage * referenceLength);
+ return Math.round(percentage * referenceLength);
}
}
// ==================================================== PRIVATE
- private RelativeLength(float percentage, int absolute, boolean isAbsolute) {
+ private RelativeLength(final float percentage, final int absolute, final boolean isAbsolute) {
this.percentage = percentage;
this.absolute = absolute;
this.isAbsolute = isAbsolute;
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/Rule.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/Rule.java
index c5cf0871..47962b3d 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/Rule.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/Rule.java
@@ -33,18 +33,14 @@ import org.w3c.css.sac.Selector;
import org.w3c.css.sac.SiblingSelector;
/**
- * Represents a pairing of a selector with a list of styles. This does not
- * exactly correspond to a rule in a style sheet; there is only one selector
- * associated with an instance of this class, whereas multiple selectors may be
+ * Represents a pairing of a selector with a list of styles. This does not exactly correspond to a rule in a style
+ * sheet; there is only one selector associated with an instance of this class, whereas multiple selectors may be
* associated with a style sheet rule.
*
- * Note: <code>Rule</code> implements the <code>Comparable</code> interface in
- * order to be sorted by "specificity" as defined by the CSS spec. However, this
- * ordering is <em>not</em> consistent with <code>equals</code> (rules with the
- * same specificity may not be equal). Therefore, <code>Rule</code> objects
- * should not be used with sorted collections or maps in the
- * <code>java.util</code> package, unless a suitable <code>Comparator</code> is
- * also used.
+ * Note: <code>Rule</code> implements the <code>Comparable</code> interface in order to be sorted by "specificity" as
+ * defined by the CSS spec. However, this ordering is <em>not</em> consistent with <code>equals</code> (rules with the
+ * same specificity may not be equal). Therefore, <code>Rule</code> objects should not be used with sorted collections
+ * or maps in the <code>java.util</code> package, unless a suitable <code>Comparator</code> is also used.
*/
public class Rule {
@@ -86,11 +82,9 @@ public class Rule {
}
/**
- * Calculates the specificity for the selector associated with this rule.
- * The specificity is represented as an integer whose base-10
- * representation, xxxyyyzzz, can be decomposed into the number of "id"
- * selectors (xxx), "class" selectors (yyy), and "element" selectors (zzz).
- * Composite selectors result in a recursive call.
+ * Calculates the specificity for the selector associated with this rule. The specificity is represented as an
+ * integer whose base-10 representation, xxxyyyzzz, can be decomposed into the number of "id" selectors (xxx),
+ * "class" selectors (yyy), and "element" selectors (zzz). Composite selectors result in a recursive call.
*/
public int getSpecificity() {
return specificity(getSelector());
@@ -113,12 +107,13 @@ public class Rule {
*/
private static boolean matches(final Selector selector, final Element element) {
- if (element == null)
+ if (element == null) {
// This can happen when, e.g., with the rule "foo > *".
// Since the root element matches the "*", we check if
// its parent matches "foo", but of course its parent
// is null
return false;
+ }
final int selectorType = selector.getSelectorType();
@@ -136,10 +131,12 @@ public class Rule {
} else if (element instanceof CommentElement) {
final AttributeCondition ac = (AttributeCondition) cs.getCondition();
return CommentElement.CSS_RULE_NAME.equals(ac.getValue()) && matches(cs.getSimpleSelector(), element.getParent());
- } else
+ } else {
return false;
- } else
+ }
+ } else {
return matches(cs.getSimpleSelector(), element) && matchesCondition(cs.getCondition(), element);
+ }
case Selector.SAC_ANY_NODE_SELECTOR:
// You'd think we land here if we have a * rule, but instead
@@ -149,21 +146,23 @@ public class Rule {
case Selector.SAC_ROOT_NODE_SELECTOR:
return element instanceof RootElement;
-
+
case Selector.SAC_NEGATIVE_SELECTOR:
break; // not yet supported
-
+
case Selector.SAC_ELEMENT_NODE_SELECTOR:
final String elementName = element.getLocalName();
final String selectorName = ((ElementSelector) selector).getLocalName();
- if (selectorName == null)
+ if (selectorName == null) {
// We land here if we have a wildcard selector (*) or
// a pseudocondition w/o an element name (:before)
// Probably other situations too (conditional w/o element
// name? e.g. [attr=value])
return true;
- if (selectorName.equals(elementName))
+ }
+ if (selectorName.equals(elementName)) {
return true;
+ }
return false;
case Selector.SAC_TEXT_NODE_SELECTOR:
@@ -171,17 +170,17 @@ public class Rule {
case Selector.SAC_CDATA_SECTION_NODE_SELECTOR:
return false; // not yet supported
-
+
case Selector.SAC_PROCESSING_INSTRUCTION_NODE_SELECTOR:
return false; // not yet supported
-
+
case Selector.SAC_COMMENT_NODE_SELECTOR:
return false; // not yet supported
-
+
case Selector.SAC_PSEUDO_ELEMENT_SELECTOR:
final ElementSelector elementSelector = (ElementSelector) selector;
return elementSelector.getLocalName().equals(element.getLocalName());
-
+
case Selector.SAC_DESCENDANT_SELECTOR:
final DescendantSelector ds = (DescendantSelector) selector;
return matches(ds.getSimpleSelector(), element) && matchesAncestor(ds.getAncestorSelector(), element.getParent());
@@ -206,8 +205,9 @@ public class Rule {
e = i.next();
}
- if (e == element)
+ if (e == element) {
return matches(ss.getSelector(), f);
+ }
}
return false;
@@ -219,14 +219,14 @@ public class Rule {
}
/**
- * Returns true if some ancestor of the given element matches the given
- * selector.
+ * Returns true if some ancestor of the given element matches the given selector.
*/
private static boolean matchesAncestor(final Selector selector, final Element element) {
Element e = element;
while (e != null) {
- if (matches(selector, e))
+ if (matches(selector, e)) {
return true;
+ }
e = e.getParent();
}
return false;
@@ -245,28 +245,33 @@ public class Rule {
case Condition.SAC_ATTRIBUTE_CONDITION:
attributeCondition = (AttributeCondition) condition;
value = element.getAttributeValue(attributeCondition.getLocalName());
- if (attributeCondition.getValue() != null)
+ if (attributeCondition.getValue() != null) {
return attributeCondition.getValue().equals(value);
- else
+ } else {
return value != null;
+ }
case Condition.SAC_ONE_OF_ATTRIBUTE_CONDITION:
case Condition.SAC_CLASS_CONDITION:
attributeCondition = (AttributeCondition) condition;
- if (condition.getConditionType() == Condition.SAC_CLASS_CONDITION)
+ if (condition.getConditionType() == Condition.SAC_CLASS_CONDITION) {
attributeName = "class";
- else
+ } else {
attributeName = attributeCondition.getLocalName();
+ }
value = element.getAttributeValue(attributeName);
- if (value == null)
+ if (value == null) {
return false;
+ }
final StringTokenizer st = new StringTokenizer(value);
- while (st.hasMoreTokens())
- if (st.nextToken().equals(attributeCondition.getValue()))
+ while (st.hasMoreTokens()) {
+ if (st.nextToken().equals(attributeCondition.getValue())) {
return true;
+ }
+ }
return false;
case Condition.SAC_AND_CONDITION:
@@ -285,11 +290,12 @@ public class Rule {
*/
private static int specificity(final Selector sel) {
if (sel instanceof ElementSelector) {
- if (((ElementSelector) sel).getLocalName() == null)
+ if (((ElementSelector) sel).getLocalName() == null) {
// actually wildcard selector -- see comment in matches()
return 0;
- else
+ } else {
return 1;
+ }
} else if (sel instanceof DescendantSelector) {
final DescendantSelector ds = (DescendantSelector) sel;
return specificity(ds.getAncestorSelector()) + specificity(ds.getSimpleSelector());
@@ -302,8 +308,9 @@ public class Rule {
} else if (sel instanceof ConditionalSelector) {
final ConditionalSelector cs = (ConditionalSelector) sel;
return specificity(cs.getCondition()) + specificity(cs.getSimpleSelector());
- } else
+ } else {
return 0;
+ }
}
/**
@@ -314,11 +321,13 @@ public class Rule {
final CombinatorCondition cc = (CombinatorCondition) cond;
return specificity(cc.getFirstCondition()) + specificity(cc.getSecondCondition());
} else if (cond instanceof AttributeCondition) {
- if (cond.getConditionType() == Condition.SAC_ID_CONDITION)
+ if (cond.getConditionType() == Condition.SAC_ID_CONDITION) {
return 1000000;
- else
+ } else {
return 1000;
- } else
+ }
+ } else {
return 0;
+ }
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/StyleSheet.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/StyleSheet.java
index 735effa2..525f6a52 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/StyleSheet.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/StyleSheet.java
@@ -35,72 +35,42 @@ import org.w3c.css.sac.LexicalUnit;
* Represents a CSS style sheet.
*/
public class StyleSheet {
-
+
public static final StyleSheet NULL = new StyleSheet(Collections.<Rule> emptyList());
-
- private static final Comparator<PropertyDecl> PROPERTY_CASCADE_ORDERING =
- new Comparator<PropertyDecl>() {
- public int compare(PropertyDecl propertyDecl1,
- PropertyDecl propertyDecl2) {
+
+ private static final Comparator<PropertyDecl> PROPERTY_CASCADE_ORDERING = new Comparator<PropertyDecl>() {
+ public int compare(final PropertyDecl propertyDecl1, final PropertyDecl propertyDecl2) {
if (propertyDecl1.isImportant() != propertyDecl2.isImportant()) {
- return (propertyDecl1.isImportant() ? 1 : 0)
- - (propertyDecl2.isImportant() ? 1 : 0);
+ return (propertyDecl1.isImportant() ? 1 : 0) - (propertyDecl2.isImportant() ? 1 : 0);
}
- return propertyDecl1.getRule().getSpecificity()
- - propertyDecl2.getRule().getSpecificity();
+ return propertyDecl1.getRule().getSpecificity() - propertyDecl2.getRule().getSpecificity();
}
};
/**
* Standard CSS properties.
*/
- private static final IProperty[] CSS_PROPERTIES = new IProperty[] {
- new DisplayProperty(),
- new LineHeightProperty(),
- new ListStyleTypeProperty(),
- new TextAlignProperty(),
+ private static final IProperty[] CSS_PROPERTIES = new IProperty[] { new DisplayProperty(), new LineHeightProperty(), new ListStyleTypeProperty(), new TextAlignProperty(),
new WhiteSpaceProperty(),
- new FontFamilyProperty(),
- new FontSizeProperty(),
- new FontStyleProperty(),
- new FontWeightProperty(),
- new TextDecorationProperty(),
-
- new ColorProperty(CSS.COLOR),
- new ColorProperty(CSS.BACKGROUND_COLOR),
-
- new LengthProperty(CSS.MARGIN_BOTTOM, IProperty.Axis.VERTICAL),
- new LengthProperty(CSS.MARGIN_LEFT, IProperty.Axis.HORIZONTAL),
- new LengthProperty(CSS.MARGIN_RIGHT, IProperty.Axis.HORIZONTAL),
- new LengthProperty(CSS.MARGIN_TOP, IProperty.Axis.VERTICAL),
-
- new LengthProperty(CSS.PADDING_BOTTOM, IProperty.Axis.VERTICAL),
- new LengthProperty(CSS.PADDING_LEFT, IProperty.Axis.HORIZONTAL),
- new LengthProperty(CSS.PADDING_RIGHT, IProperty.Axis.HORIZONTAL),
- new LengthProperty(CSS.PADDING_TOP, IProperty.Axis.VERTICAL),
-
- new ColorProperty(CSS.BORDER_BOTTOM_COLOR),
- new ColorProperty(CSS.BORDER_LEFT_COLOR),
- new ColorProperty(CSS.BORDER_RIGHT_COLOR),
- new ColorProperty(CSS.BORDER_TOP_COLOR),
- new BorderStyleProperty(CSS.BORDER_BOTTOM_STYLE),
- new BorderStyleProperty(CSS.BORDER_LEFT_STYLE),
- new BorderStyleProperty(CSS.BORDER_RIGHT_STYLE),
- new BorderStyleProperty(CSS.BORDER_TOP_STYLE),
- new BorderWidthProperty(CSS.BORDER_BOTTOM_WIDTH,
- CSS.BORDER_BOTTOM_STYLE, IProperty.Axis.VERTICAL),
- new BorderWidthProperty(CSS.BORDER_LEFT_WIDTH,
- CSS.BORDER_LEFT_STYLE, IProperty.Axis.HORIZONTAL),
- new BorderWidthProperty(CSS.BORDER_RIGHT_WIDTH,
- CSS.BORDER_RIGHT_STYLE, IProperty.Axis.HORIZONTAL),
- new BorderWidthProperty(CSS.BORDER_TOP_WIDTH, CSS.BORDER_TOP_STYLE,
- IProperty.Axis.VERTICAL), new BorderSpacingProperty(),
- new LengthProperty(CSS.HEIGHT, IProperty.Axis.VERTICAL),
- new LengthProperty(CSS.WIDTH, IProperty.Axis.HORIZONTAL),
- new BackgroundImageProperty()
- };
+ new FontFamilyProperty(), new FontSizeProperty(), new FontStyleProperty(), new FontWeightProperty(), new TextDecorationProperty(),
+
+ new ColorProperty(CSS.COLOR), new ColorProperty(CSS.BACKGROUND_COLOR),
+
+ new LengthProperty(CSS.MARGIN_BOTTOM, IProperty.Axis.VERTICAL), new LengthProperty(CSS.MARGIN_LEFT, IProperty.Axis.HORIZONTAL),
+ new LengthProperty(CSS.MARGIN_RIGHT, IProperty.Axis.HORIZONTAL), new LengthProperty(CSS.MARGIN_TOP, IProperty.Axis.VERTICAL),
+
+ new LengthProperty(CSS.PADDING_BOTTOM, IProperty.Axis.VERTICAL), new LengthProperty(CSS.PADDING_LEFT, IProperty.Axis.HORIZONTAL),
+ new LengthProperty(CSS.PADDING_RIGHT, IProperty.Axis.HORIZONTAL), new LengthProperty(CSS.PADDING_TOP, IProperty.Axis.VERTICAL),
+
+ new ColorProperty(CSS.BORDER_BOTTOM_COLOR), new ColorProperty(CSS.BORDER_LEFT_COLOR), new ColorProperty(CSS.BORDER_RIGHT_COLOR), new ColorProperty(CSS.BORDER_TOP_COLOR),
+ new BorderStyleProperty(CSS.BORDER_BOTTOM_STYLE), new BorderStyleProperty(CSS.BORDER_LEFT_STYLE), new BorderStyleProperty(CSS.BORDER_RIGHT_STYLE),
+ new BorderStyleProperty(CSS.BORDER_TOP_STYLE), new BorderWidthProperty(CSS.BORDER_BOTTOM_WIDTH, CSS.BORDER_BOTTOM_STYLE, IProperty.Axis.VERTICAL),
+ new BorderWidthProperty(CSS.BORDER_LEFT_WIDTH, CSS.BORDER_LEFT_STYLE, IProperty.Axis.HORIZONTAL),
+ new BorderWidthProperty(CSS.BORDER_RIGHT_WIDTH, CSS.BORDER_RIGHT_STYLE, IProperty.Axis.HORIZONTAL),
+ new BorderWidthProperty(CSS.BORDER_TOP_WIDTH, CSS.BORDER_TOP_STYLE, IProperty.Axis.VERTICAL), new BorderSpacingProperty(), new LengthProperty(CSS.HEIGHT, IProperty.Axis.VERTICAL),
+ new LengthProperty(CSS.WIDTH, IProperty.Axis.HORIZONTAL), new BackgroundImageProperty() };
/**
* The rules that comprise the stylesheet.
@@ -108,14 +78,12 @@ public class StyleSheet {
private final List<Rule> rules;
/**
- * Computing styles can be expensive, e.g. we have to calculate the styles
- * of all parents of an element. We therefore cache styles in a map of
- * element => WeakReference(styles). A weak hash map is used to avoid
- * leaking memory as elements are deleted. By using weak references to the
- * values, we also ensure the cache is memory-sensitive.
+ * Computing styles can be expensive, e.g. we have to calculate the styles of all parents of an element. We
+ * therefore cache styles in a map of element => WeakReference(styles). A weak hash map is used to avoid leaking
+ * memory as elements are deleted. By using weak references to the values, we also ensure the cache is
+ * memory-sensitive.
*
- * This must be transient to prevent it from being serialized, as
- * WeakHashMaps are not serializable.
+ * This must be transient to prevent it from being serialized, as WeakHashMaps are not serializable.
*/
private transient Map<Element, WeakReference<Styles>> styleMap;
@@ -135,20 +103,20 @@ public class StyleSheet {
* @param element
* IVEXElement for which styles are to be flushed.
*/
- public void flushStyles(Element element) {
- this.getStyleMap().remove(element);
+ public void flushStyles(final Element element) {
+ getStyleMap().remove(element);
}
/**
- * Returns a pseudo-element representing content to be displayed after the
- * given element, or null if there is no such content.
+ * Returns a pseudo-element representing content to be displayed after the given element, or null if there is no
+ * such content.
*
* @param element
* Parent element of the pseudo-element.
*/
- public Element getAfterElement(Element element) {
- PseudoElement pe = new PseudoElement(element, PseudoElement.AFTER);
- Styles styles = this.getStyles(pe);
+ public Element getAfterElement(final Element element) {
+ final PseudoElement pe = new PseudoElement(element, PseudoElement.AFTER);
+ final Styles styles = getStyles(pe);
if (styles == null) {
return null;
} else {
@@ -157,15 +125,15 @@ public class StyleSheet {
}
/**
- * Returns a pseudo-element representing content to be displayed before the
- * given element, or null if there is no such content.
+ * Returns a pseudo-element representing content to be displayed before the given element, or null if there is no
+ * such content.
*
* @param element
* Parent element of the pseudo-element.
*/
- public Element getBeforeElement(Element element) {
- PseudoElement pe = new PseudoElement(element, PseudoElement.BEFORE);
- Styles styles = this.getStyles(pe);
+ public Element getBeforeElement(final Element element) {
+ final PseudoElement pe = new PseudoElement(element, PseudoElement.BEFORE);
+ final Styles styles = getStyles(pe);
if (styles == null) {
return null;
} else {
@@ -174,16 +142,15 @@ public class StyleSheet {
}
/**
- * Returns the styles for the given element. The styles are cached to ensure
- * reasonable performance.
+ * Returns the styles for the given element. The styles are cached to ensure reasonable performance.
*
* @param element
* Element for which to calculate the styles.
*/
- public Styles getStyles(Element element) {
+ public Styles getStyles(final Element element) {
Styles styles;
- WeakReference<Styles> ref = getStyleMap().get(element);
+ final WeakReference<Styles> ref = getStyleMap().get(element);
if (ref != null) {
// can't combine these tests, since calling ref.get() twice
@@ -211,15 +178,15 @@ public class StyleSheet {
return styles;
}
- private Styles calculateStyles(Element element) {
+ private Styles calculateStyles(final Element element) {
- Styles styles = new Styles();
+ final Styles styles = new Styles();
Styles parentStyles = null;
if (element.getParent() != null) {
- parentStyles = this.getStyles(element.getParent());
+ parentStyles = getStyles(element.getParent());
}
- Map<String, LexicalUnit> decls = getApplicableDeclarations(element);
+ final Map<String, LexicalUnit> decls = getApplicableDeclarations(element);
LexicalUnit lexicalUnit;
@@ -227,21 +194,23 @@ public class StyleSheet {
// first, since most of the time it'll be empty and we'll return null.
if (element instanceof PseudoElement) {
lexicalUnit = decls.get(CSS.CONTENT);
- if (lexicalUnit == null)
+ if (lexicalUnit == null) {
return null;
+ }
- List<String> content = new ArrayList<String>();
+ final List<String> content = new ArrayList<String>();
while (lexicalUnit != null) {
switch (lexicalUnit.getLexicalUnitType()) {
- case LexicalUnit.SAC_STRING_VALUE :
+ case LexicalUnit.SAC_STRING_VALUE:
// content: "A String"
content.add(lexicalUnit.getStringValue());
break;
- case LexicalUnit.SAC_ATTR :
+ case LexicalUnit.SAC_ATTR:
// content: attr(attributeName)
final String attributeValue = element.getParent().getAttributeValue(lexicalUnit.getStringValue());
- if (attributeValue != null)
+ if (attributeValue != null) {
content.add(attributeValue);
+ }
break;
}
lexicalUnit = lexicalUnit.getNextLexicalUnit();
@@ -259,7 +228,7 @@ public class StyleSheet {
// an AWT font.
int styleFlags = FontSpec.PLAIN;
- String fontStyle = styles.getFontStyle();
+ final String fontStyle = styles.getFontStyle();
if (fontStyle.equals(CSS.ITALIC) || fontStyle.equals(CSS.OBLIQUE)) {
styleFlags |= FontSpec.ITALIC;
}
@@ -267,7 +236,7 @@ public class StyleSheet {
// 550 is halfway btn normal (400) and bold (700)
styleFlags |= FontSpec.BOLD;
}
- String textDecoration = styles.getTextDecoration();
+ final String textDecoration = styles.getTextDecoration();
if (textDecoration.equals(CSS.UNDERLINE)) {
styleFlags |= FontSpec.UNDERLINE;
} else if (textDecoration.equals(CSS.OVERLINE)) {
@@ -276,19 +245,18 @@ public class StyleSheet {
styleFlags |= FontSpec.LINE_THROUGH;
}
- styles.setFont(new FontSpec(styles.getFontFamilies(), styleFlags, Math
- .round(styles.getFontSize())));
+ styles.setFont(new FontSpec(styles.getFontFamilies(), styleFlags, Math.round(styles.getFontSize())));
return styles;
}
-
+
/**
* Returns the rules comprising this stylesheet.
*/
public List<Rule> getRules() {
- return Collections.unmodifiableList(this.rules);
+ return Collections.unmodifiableList(rules);
}
-
+
/**
* Returns all the declarations that apply to the given element.
*/
@@ -304,8 +272,7 @@ public class StyleSheet {
final Map<String, LexicalUnit> values = new HashMap<String, LexicalUnit>();
for (final PropertyDecl declaration : rawDeclarationsForElement) {
final PropertyDecl previousDeclaration = distilledDeclarations.get(declaration.getProperty());
- if (previousDeclaration == null || !previousDeclaration.isImportant()
- || declaration.isImportant()) {
+ if (previousDeclaration == null || !previousDeclaration.isImportant() || declaration.isImportant()) {
distilledDeclarations.put(declaration.getProperty(), declaration);
values.put(declaration.getProperty(), declaration.getValue());
}
@@ -313,12 +280,12 @@ public class StyleSheet {
return values;
}
-
+
private List<PropertyDecl> findAllDeclarationsFor(final Element element) {
final List<PropertyDecl> rawDeclarations = new ArrayList<PropertyDecl>();
for (final Rule rule : rules) {
if (rule.matches(element)) {
- PropertyDecl[] ruleDecls = rule.getPropertyDecls();
+ final PropertyDecl[] ruleDecls = rule.getPropertyDecls();
for (final PropertyDecl ruleDecl : ruleDecls) {
rawDeclarations.add(ruleDecl);
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/StyleSheetReader.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/StyleSheetReader.java
index 53f3a9fc..9dd2c329 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/StyleSheetReader.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/StyleSheetReader.java
@@ -37,7 +37,7 @@ import org.w3c.css.sac.SelectorList;
public class StyleSheetReader {
private static final URIResolver URI_RESOLVER = URIResolverPlugin.createResolver();
-
+
public static Parser createParser() {
return new org.apache.batik.css.parser.Parser();
}
@@ -48,19 +48,18 @@ public class StyleSheetReader {
* @param url
* URL from which to read the style sheet.
*/
- public StyleSheet read(URL url) throws IOException {
+ public StyleSheet read(final URL url) throws IOException {
return this.read(new InputSource(url.toString()), url);
}
/**
- * Creates a style sheet from a string. This is mainly used for small style
- * sheets within unit tests.
+ * Creates a style sheet from a string. This is mainly used for small style sheets within unit tests.
*
* @param s
* String containing the style sheet.
*/
- public StyleSheet read(String s) throws CSSException, IOException {
- Reader reader = new CharArrayReader(s.toCharArray());
+ public StyleSheet read(final String s) throws CSSException, IOException {
+ final Reader reader = new CharArrayReader(s.toCharArray());
return this.read(new InputSource(reader), null);
}
@@ -70,11 +69,10 @@ public class StyleSheetReader {
* @param inputSource
* InputSource from which to read the stylesheet.
* @param url
- * URL representing the input source, used to resolve @import
- * rules with relative URIs. May be null, in which case @import
- * rules are ignored.
+ * URL representing the input source, used to resolve @import rules with relative URIs. May be null, in
+ * which case @import rules are ignored.
*/
- public StyleSheet read(InputSource inputSource, URL url) throws CSSException, IOException {
+ public StyleSheet read(final InputSource inputSource, final URL url) throws CSSException, IOException {
final Parser parser = createParser();
final List<Rule> rules = new ArrayList<Rule>();
final StyleSheetBuilder styleSheetBuilder = new StyleSheetBuilder(rules, url);
@@ -97,58 +95,59 @@ public class StyleSheetReader {
// May be null!
private final URL url;
- public StyleSheetBuilder(List<Rule> rules, URL url) {
+ public StyleSheetBuilder(final List<Rule> rules, final URL url) {
this.rules = rules;
this.url = url;
}
// -------------------------------------------- DocumentHandler methods
- public void comment(java.lang.String text) {
+ public void comment(final java.lang.String text) {
}
- public void endDocument(InputSource source) {
+ public void endDocument(final InputSource source) {
}
public void endFontFace() {
}
- public void endMedia(SACMediaList media) {
+ public void endMedia(final SACMediaList media) {
}
- public void endPage(String name, String pseudo_page) {
+ public void endPage(final String name, final String pseudo_page) {
}
- public void endSelector(SelectorList selectors) {
- this.rules.addAll(this.currentRules);
- this.currentRules = null;
+ public void endSelector(final SelectorList selectors) {
+ rules.addAll(currentRules);
+ currentRules = null;
}
- public void ignorableAtRule(String atRule) {
+ public void ignorableAtRule(final String atRule) {
}
- public void importStyle(String uri, SACMediaList media, String defaultNamespaceURI) {
- if (this.url == null)
+ public void importStyle(final String uri, final SACMediaList media, final String defaultNamespaceURI) {
+ if (url == null) {
return;
+ }
try {
final Parser parser = createParser();
- final URL importUrl = new URL(URI_RESOLVER.resolve(this.url.toString(), null, uri));
+ final URL importUrl = new URL(URI_RESOLVER.resolve(url.toString(), null, uri));
final StyleSheetBuilder styleSheetBuilder = new StyleSheetBuilder(rules, importUrl);
parser.setDocumentHandler(styleSheetBuilder);
parser.parseStyleSheet(new InputSource(importUrl.toString()));
- } catch (CSSException e) {
+ } catch (final CSSException e) {
System.out.println("Cannot parse stylesheet " + uri + ": " + e.getMessage());
- } catch (IOException e) {
+ } catch (final IOException e) {
System.out.println("Cannot read stylesheet " + uri + ": " + e.getMessage());
}
}
- public void namespaceDeclaration(String prefix, String uri) {
+ public void namespaceDeclaration(final String prefix, final String uri) {
}
- public void property(String name, LexicalUnit value, boolean important) {
+ public void property(final String name, final LexicalUnit value, final boolean important) {
if (name.equals(CSS.BORDER)) {
this.expandBorder(value, important);
} else if (name.equals(CSS.BORDER_BOTTOM)) {
@@ -160,39 +159,39 @@ public class StyleSheetReader {
} else if (name.equals(CSS.BORDER_TOP)) {
this.expandBorder(value, CSS.BORDER_TOP, important);
} else if (name.equals(CSS.BORDER_COLOR)) {
- this.expandBorderColor(value, important);
+ expandBorderColor(value, important);
} else if (name.equals(CSS.BORDER_STYLE)) {
- this.expandBorderStyle(value, important);
+ expandBorderStyle(value, important);
} else if (name.equals(CSS.BORDER_WIDTH)) {
- this.expandBorderWidth(value, important);
+ expandBorderWidth(value, important);
} else if (name.equals(CSS.FONT)) {
- this.expandFont(value, important);
+ expandFont(value, important);
} else if (name.equals(CSS.MARGIN)) {
- this.expandMargin(value, important);
+ expandMargin(value, important);
} else if (name.equals(CSS.PADDING)) {
- this.expandPadding(value, important);
+ expandPadding(value, important);
} else {
- this.addDecl(name, value, important);
+ addDecl(name, value, important);
}
}
- public void startDocument(InputSource source) {
+ public void startDocument(final InputSource source) {
}
public void startFontFace() {
}
- public void startMedia(SACMediaList media) {
+ public void startMedia(final SACMediaList media) {
}
- public void startPage(String name, String pseudo_page) {
+ public void startPage(final String name, final String pseudo_page) {
}
- public void startSelector(SelectorList selectors) {
- this.currentRules = new ArrayList<Rule>();
+ public void startSelector(final SelectorList selectors) {
+ currentRules = new ArrayList<Rule>();
for (int i = 0; i < selectors.getLength(); i++) {
final Selector selector = selectors.item(i);
- this.currentRules.add(new Rule(selector));
+ currentRules.add(new Rule(selector));
}
}
@@ -203,8 +202,8 @@ public class StyleSheetReader {
/**
* Adds a PropertyDecl to the current set of rules.
*/
- private void addDecl(String name, LexicalUnit value, boolean important) {
- for (Rule rule : this.currentRules) {
+ private void addDecl(final String name, final LexicalUnit value, final boolean important) {
+ for (final Rule rule : currentRules) {
rule.add(new PropertyDecl(rule, name, value, important));
}
}
@@ -212,7 +211,7 @@ public class StyleSheetReader {
/**
* Expand the "border" shorthand property.
*/
- private void expandBorder(LexicalUnit value, boolean important) {
+ private void expandBorder(final LexicalUnit value, final boolean important) {
this.expandBorder(value, CSS.BORDER_BOTTOM, important);
this.expandBorder(value, CSS.BORDER_LEFT, important);
this.expandBorder(value, CSS.BORDER_RIGHT, important);
@@ -220,33 +219,32 @@ public class StyleSheetReader {
}
/**
- * Expand one of the the "border-xxx" shorthand properties. whichBorder
- * must be one of CSS.BORDER_BOTTOM, CSS.BORDER_LEFT, CSS.BORDER_RIGHT,
- * CSS.BORDER_TOP.
+ * Expand one of the the "border-xxx" shorthand properties. whichBorder must be one of CSS.BORDER_BOTTOM,
+ * CSS.BORDER_LEFT, CSS.BORDER_RIGHT, CSS.BORDER_TOP.
*/
- private void expandBorder(LexicalUnit value, String whichBorder, boolean important) {
+ private void expandBorder(final LexicalUnit value, final String whichBorder, final boolean important) {
if (AbstractProperty.isInherit(value)) {
- this.addDecl(whichBorder + CSS.COLOR_SUFFIX, value, important);
- this.addDecl(whichBorder + CSS.STYLE_SUFFIX, value, important);
- this.addDecl(whichBorder + CSS.WIDTH_SUFFIX, value, important);
+ addDecl(whichBorder + CSS.COLOR_SUFFIX, value, important);
+ addDecl(whichBorder + CSS.STYLE_SUFFIX, value, important);
+ addDecl(whichBorder + CSS.WIDTH_SUFFIX, value, important);
return;
}
- LexicalUnit[] lus = getLexicalUnitList(value);
+ final LexicalUnit[] lus = getLexicalUnitList(value);
int i = 0;
if (BorderWidthProperty.isBorderWidth(lus[i])) {
- this.addDecl(whichBorder + CSS.WIDTH_SUFFIX, lus[i], important);
+ addDecl(whichBorder + CSS.WIDTH_SUFFIX, lus[i], important);
i++;
}
if (i < lus.length && BorderStyleProperty.isBorderStyle(lus[i])) {
- this.addDecl(whichBorder + CSS.STYLE_SUFFIX, lus[i], important);
+ addDecl(whichBorder + CSS.STYLE_SUFFIX, lus[i], important);
i++;
}
if (i < lus.length && ColorProperty.isColor(lus[i])) {
- this.addDecl(whichBorder + CSS.COLOR_SUFFIX, lus[i], important);
+ addDecl(whichBorder + CSS.COLOR_SUFFIX, lus[i], important);
i++;
}
@@ -255,244 +253,243 @@ public class StyleSheetReader {
/**
* Expand the "border-color" shorthand property.
*/
- private void expandBorderColor(LexicalUnit value, boolean important) {
+ private void expandBorderColor(final LexicalUnit value, final boolean important) {
if (AbstractProperty.isInherit(value)) {
- this.addDecl(CSS.BORDER_TOP_COLOR, value, important);
- this.addDecl(CSS.BORDER_LEFT_COLOR, value, important);
- this.addDecl(CSS.BORDER_RIGHT_COLOR, value, important);
- this.addDecl(CSS.BORDER_BOTTOM_COLOR, value, important);
+ addDecl(CSS.BORDER_TOP_COLOR, value, important);
+ addDecl(CSS.BORDER_LEFT_COLOR, value, important);
+ addDecl(CSS.BORDER_RIGHT_COLOR, value, important);
+ addDecl(CSS.BORDER_BOTTOM_COLOR, value, important);
return;
}
- LexicalUnit[] lus = getLexicalUnitList(value);
+ final LexicalUnit[] lus = getLexicalUnitList(value);
if (lus.length >= 4) {
- this.addDecl(CSS.BORDER_TOP_COLOR, lus[0], important);
- this.addDecl(CSS.BORDER_RIGHT_COLOR, lus[1], important);
- this.addDecl(CSS.BORDER_BOTTOM_COLOR, lus[2], important);
- this.addDecl(CSS.BORDER_LEFT_COLOR, lus[3], important);
+ addDecl(CSS.BORDER_TOP_COLOR, lus[0], important);
+ addDecl(CSS.BORDER_RIGHT_COLOR, lus[1], important);
+ addDecl(CSS.BORDER_BOTTOM_COLOR, lus[2], important);
+ addDecl(CSS.BORDER_LEFT_COLOR, lus[3], important);
} else if (lus.length == 3) {
- this.addDecl(CSS.BORDER_TOP_COLOR, lus[0], important);
- this.addDecl(CSS.BORDER_LEFT_COLOR, lus[1], important);
- this.addDecl(CSS.BORDER_RIGHT_COLOR, lus[1], important);
- this.addDecl(CSS.BORDER_BOTTOM_COLOR, lus[2], important);
+ addDecl(CSS.BORDER_TOP_COLOR, lus[0], important);
+ addDecl(CSS.BORDER_LEFT_COLOR, lus[1], important);
+ addDecl(CSS.BORDER_RIGHT_COLOR, lus[1], important);
+ addDecl(CSS.BORDER_BOTTOM_COLOR, lus[2], important);
} else if (lus.length == 2) {
- this.addDecl(CSS.BORDER_TOP_COLOR, lus[0], important);
- this.addDecl(CSS.BORDER_LEFT_COLOR, lus[1], important);
- this.addDecl(CSS.BORDER_RIGHT_COLOR, lus[1], important);
- this.addDecl(CSS.BORDER_BOTTOM_COLOR, lus[0], important);
+ addDecl(CSS.BORDER_TOP_COLOR, lus[0], important);
+ addDecl(CSS.BORDER_LEFT_COLOR, lus[1], important);
+ addDecl(CSS.BORDER_RIGHT_COLOR, lus[1], important);
+ addDecl(CSS.BORDER_BOTTOM_COLOR, lus[0], important);
} else if (lus.length == 1) {
- this.addDecl(CSS.BORDER_TOP_COLOR, lus[0], important);
- this.addDecl(CSS.BORDER_LEFT_COLOR, lus[0], important);
- this.addDecl(CSS.BORDER_RIGHT_COLOR, lus[0], important);
- this.addDecl(CSS.BORDER_BOTTOM_COLOR, lus[0], important);
+ addDecl(CSS.BORDER_TOP_COLOR, lus[0], important);
+ addDecl(CSS.BORDER_LEFT_COLOR, lus[0], important);
+ addDecl(CSS.BORDER_RIGHT_COLOR, lus[0], important);
+ addDecl(CSS.BORDER_BOTTOM_COLOR, lus[0], important);
}
}
/**
* Expand the "border-style" shorthand property.
*/
- private void expandBorderStyle(LexicalUnit value, boolean important) {
+ private void expandBorderStyle(final LexicalUnit value, final boolean important) {
if (AbstractProperty.isInherit(value)) {
- this.addDecl(CSS.BORDER_TOP_STYLE, value, important);
- this.addDecl(CSS.BORDER_LEFT_STYLE, value, important);
- this.addDecl(CSS.BORDER_RIGHT_STYLE, value, important);
- this.addDecl(CSS.BORDER_BOTTOM_STYLE, value, important);
+ addDecl(CSS.BORDER_TOP_STYLE, value, important);
+ addDecl(CSS.BORDER_LEFT_STYLE, value, important);
+ addDecl(CSS.BORDER_RIGHT_STYLE, value, important);
+ addDecl(CSS.BORDER_BOTTOM_STYLE, value, important);
return;
}
- LexicalUnit[] lus = getLexicalUnitList(value);
+ final LexicalUnit[] lus = getLexicalUnitList(value);
if (lus.length >= 4) {
- this.addDecl(CSS.BORDER_TOP_STYLE, lus[0], important);
- this.addDecl(CSS.BORDER_RIGHT_STYLE, lus[1], important);
- this.addDecl(CSS.BORDER_BOTTOM_STYLE, lus[2], important);
- this.addDecl(CSS.BORDER_LEFT_STYLE, lus[3], important);
+ addDecl(CSS.BORDER_TOP_STYLE, lus[0], important);
+ addDecl(CSS.BORDER_RIGHT_STYLE, lus[1], important);
+ addDecl(CSS.BORDER_BOTTOM_STYLE, lus[2], important);
+ addDecl(CSS.BORDER_LEFT_STYLE, lus[3], important);
} else if (lus.length == 3) {
- this.addDecl(CSS.BORDER_TOP_STYLE, lus[0], important);
- this.addDecl(CSS.BORDER_LEFT_STYLE, lus[1], important);
- this.addDecl(CSS.BORDER_RIGHT_STYLE, lus[1], important);
- this.addDecl(CSS.BORDER_BOTTOM_STYLE, lus[2], important);
+ addDecl(CSS.BORDER_TOP_STYLE, lus[0], important);
+ addDecl(CSS.BORDER_LEFT_STYLE, lus[1], important);
+ addDecl(CSS.BORDER_RIGHT_STYLE, lus[1], important);
+ addDecl(CSS.BORDER_BOTTOM_STYLE, lus[2], important);
} else if (lus.length == 2) {
- this.addDecl(CSS.BORDER_TOP_STYLE, lus[0], important);
- this.addDecl(CSS.BORDER_LEFT_STYLE, lus[1], important);
- this.addDecl(CSS.BORDER_RIGHT_STYLE, lus[1], important);
- this.addDecl(CSS.BORDER_BOTTOM_STYLE, lus[0], important);
+ addDecl(CSS.BORDER_TOP_STYLE, lus[0], important);
+ addDecl(CSS.BORDER_LEFT_STYLE, lus[1], important);
+ addDecl(CSS.BORDER_RIGHT_STYLE, lus[1], important);
+ addDecl(CSS.BORDER_BOTTOM_STYLE, lus[0], important);
} else if (lus.length == 1) {
- this.addDecl(CSS.BORDER_TOP_STYLE, lus[0], important);
- this.addDecl(CSS.BORDER_LEFT_STYLE, lus[0], important);
- this.addDecl(CSS.BORDER_RIGHT_STYLE, lus[0], important);
- this.addDecl(CSS.BORDER_BOTTOM_STYLE, lus[0], important);
+ addDecl(CSS.BORDER_TOP_STYLE, lus[0], important);
+ addDecl(CSS.BORDER_LEFT_STYLE, lus[0], important);
+ addDecl(CSS.BORDER_RIGHT_STYLE, lus[0], important);
+ addDecl(CSS.BORDER_BOTTOM_STYLE, lus[0], important);
}
}
/**
* Expand the "border-width" shorthand property.
*/
- private void expandBorderWidth(LexicalUnit value, boolean important) {
+ private void expandBorderWidth(final LexicalUnit value, final boolean important) {
if (AbstractProperty.isInherit(value)) {
- this.addDecl(CSS.BORDER_TOP_WIDTH, value, important);
- this.addDecl(CSS.BORDER_LEFT_WIDTH, value, important);
- this.addDecl(CSS.BORDER_RIGHT_WIDTH, value, important);
- this.addDecl(CSS.BORDER_BOTTOM_WIDTH, value, important);
+ addDecl(CSS.BORDER_TOP_WIDTH, value, important);
+ addDecl(CSS.BORDER_LEFT_WIDTH, value, important);
+ addDecl(CSS.BORDER_RIGHT_WIDTH, value, important);
+ addDecl(CSS.BORDER_BOTTOM_WIDTH, value, important);
return;
}
- LexicalUnit[] lus = getLexicalUnitList(value);
+ final LexicalUnit[] lus = getLexicalUnitList(value);
if (lus.length >= 4) {
- this.addDecl(CSS.BORDER_TOP_WIDTH, lus[0], important);
- this.addDecl(CSS.BORDER_RIGHT_WIDTH, lus[1], important);
- this.addDecl(CSS.BORDER_BOTTOM_WIDTH, lus[2], important);
- this.addDecl(CSS.BORDER_LEFT_WIDTH, lus[3], important);
+ addDecl(CSS.BORDER_TOP_WIDTH, lus[0], important);
+ addDecl(CSS.BORDER_RIGHT_WIDTH, lus[1], important);
+ addDecl(CSS.BORDER_BOTTOM_WIDTH, lus[2], important);
+ addDecl(CSS.BORDER_LEFT_WIDTH, lus[3], important);
} else if (lus.length == 3) {
- this.addDecl(CSS.BORDER_TOP_WIDTH, lus[0], important);
- this.addDecl(CSS.BORDER_LEFT_WIDTH, lus[1], important);
- this.addDecl(CSS.BORDER_RIGHT_WIDTH, lus[1], important);
- this.addDecl(CSS.BORDER_BOTTOM_WIDTH, lus[2], important);
+ addDecl(CSS.BORDER_TOP_WIDTH, lus[0], important);
+ addDecl(CSS.BORDER_LEFT_WIDTH, lus[1], important);
+ addDecl(CSS.BORDER_RIGHT_WIDTH, lus[1], important);
+ addDecl(CSS.BORDER_BOTTOM_WIDTH, lus[2], important);
} else if (lus.length == 2) {
- this.addDecl(CSS.BORDER_TOP_WIDTH, lus[0], important);
- this.addDecl(CSS.BORDER_LEFT_WIDTH, lus[1], important);
- this.addDecl(CSS.BORDER_RIGHT_WIDTH, lus[1], important);
- this.addDecl(CSS.BORDER_BOTTOM_WIDTH, lus[0], important);
+ addDecl(CSS.BORDER_TOP_WIDTH, lus[0], important);
+ addDecl(CSS.BORDER_LEFT_WIDTH, lus[1], important);
+ addDecl(CSS.BORDER_RIGHT_WIDTH, lus[1], important);
+ addDecl(CSS.BORDER_BOTTOM_WIDTH, lus[0], important);
} else if (lus.length == 1) {
- this.addDecl(CSS.BORDER_TOP_WIDTH, lus[0], important);
- this.addDecl(CSS.BORDER_LEFT_WIDTH, lus[0], important);
- this.addDecl(CSS.BORDER_RIGHT_WIDTH, lus[0], important);
- this.addDecl(CSS.BORDER_BOTTOM_WIDTH, lus[0], important);
+ addDecl(CSS.BORDER_TOP_WIDTH, lus[0], important);
+ addDecl(CSS.BORDER_LEFT_WIDTH, lus[0], important);
+ addDecl(CSS.BORDER_RIGHT_WIDTH, lus[0], important);
+ addDecl(CSS.BORDER_BOTTOM_WIDTH, lus[0], important);
}
}
/**
* Expand the "font" shorthand property.
*/
- private void expandFont(LexicalUnit value, boolean important) {
+ private void expandFont(final LexicalUnit value, final boolean important) {
if (AbstractProperty.isInherit(value)) {
- this.addDecl(CSS.FONT_STYLE, value, important);
- this.addDecl(CSS.FONT_VARIANT, value, important);
- this.addDecl(CSS.FONT_WEIGHT, value, important);
- this.addDecl(CSS.FONT_SIZE, value, important);
- this.addDecl(CSS.FONT_FAMILY, value, important);
+ addDecl(CSS.FONT_STYLE, value, important);
+ addDecl(CSS.FONT_VARIANT, value, important);
+ addDecl(CSS.FONT_WEIGHT, value, important);
+ addDecl(CSS.FONT_SIZE, value, important);
+ addDecl(CSS.FONT_FAMILY, value, important);
return;
}
- LexicalUnit[] lus = getLexicalUnitList(value);
- int n = lus.length;
+ final LexicalUnit[] lus = getLexicalUnitList(value);
+ final int n = lus.length;
int i = 0;
if (i < n && FontStyleProperty.isFontStyle(lus[i])) {
- this.addDecl(CSS.FONT_STYLE, lus[i], important);
+ addDecl(CSS.FONT_STYLE, lus[i], important);
i++;
}
if (i < n && FontVariantProperty.isFontVariant(lus[i])) {
- this.addDecl(CSS.FONT_VARIANT, lus[i], important);
+ addDecl(CSS.FONT_VARIANT, lus[i], important);
i++;
}
if (i < n && FontWeightProperty.isFontWeight(lus[i])) {
- this.addDecl(CSS.FONT_WEIGHT, lus[i], important);
+ addDecl(CSS.FONT_WEIGHT, lus[i], important);
i++;
}
if (i < n && FontSizeProperty.isFontSize(lus[i])) {
- this.addDecl(CSS.FONT_SIZE, lus[i], important);
+ addDecl(CSS.FONT_SIZE, lus[i], important);
i++;
}
if (i < n && lus[i].getLexicalUnitType() == LexicalUnit.SAC_OPERATOR_SLASH) {
i++; // gobble slash
if (i < n) {
- this.addDecl(CSS.LINE_HEIGHT, lus[i], important);
+ addDecl(CSS.LINE_HEIGHT, lus[i], important);
}
i++;
}
if (i < n) {
- this.addDecl(CSS.FONT_FAMILY, lus[i], important);
+ addDecl(CSS.FONT_FAMILY, lus[i], important);
}
}
/**
* Expand the "margin" shorthand property.
*/
- private void expandMargin(LexicalUnit value, boolean important) {
+ private void expandMargin(final LexicalUnit value, final boolean important) {
if (AbstractProperty.isInherit(value)) {
- this.addDecl(CSS.MARGIN_TOP, value, important);
- this.addDecl(CSS.MARGIN_RIGHT, value, important);
- this.addDecl(CSS.MARGIN_BOTTOM, value, important);
- this.addDecl(CSS.MARGIN_LEFT, value, important);
+ addDecl(CSS.MARGIN_TOP, value, important);
+ addDecl(CSS.MARGIN_RIGHT, value, important);
+ addDecl(CSS.MARGIN_BOTTOM, value, important);
+ addDecl(CSS.MARGIN_LEFT, value, important);
return;
}
- LexicalUnit[] lus = getLexicalUnitList(value);
+ final LexicalUnit[] lus = getLexicalUnitList(value);
if (lus.length >= 4) {
- this.addDecl(CSS.MARGIN_TOP, lus[0], important);
- this.addDecl(CSS.MARGIN_RIGHT, lus[1], important);
- this.addDecl(CSS.MARGIN_BOTTOM, lus[2], important);
- this.addDecl(CSS.MARGIN_LEFT, lus[3], important);
+ addDecl(CSS.MARGIN_TOP, lus[0], important);
+ addDecl(CSS.MARGIN_RIGHT, lus[1], important);
+ addDecl(CSS.MARGIN_BOTTOM, lus[2], important);
+ addDecl(CSS.MARGIN_LEFT, lus[3], important);
} else if (lus.length == 3) {
- this.addDecl(CSS.MARGIN_TOP, lus[0], important);
- this.addDecl(CSS.MARGIN_LEFT, lus[1], important);
- this.addDecl(CSS.MARGIN_RIGHT, lus[1], important);
- this.addDecl(CSS.MARGIN_BOTTOM, lus[2], important);
+ addDecl(CSS.MARGIN_TOP, lus[0], important);
+ addDecl(CSS.MARGIN_LEFT, lus[1], important);
+ addDecl(CSS.MARGIN_RIGHT, lus[1], important);
+ addDecl(CSS.MARGIN_BOTTOM, lus[2], important);
} else if (lus.length == 2) {
- this.addDecl(CSS.MARGIN_TOP, lus[0], important);
- this.addDecl(CSS.MARGIN_LEFT, lus[1], important);
- this.addDecl(CSS.MARGIN_RIGHT, lus[1], important);
- this.addDecl(CSS.MARGIN_BOTTOM, lus[0], important);
+ addDecl(CSS.MARGIN_TOP, lus[0], important);
+ addDecl(CSS.MARGIN_LEFT, lus[1], important);
+ addDecl(CSS.MARGIN_RIGHT, lus[1], important);
+ addDecl(CSS.MARGIN_BOTTOM, lus[0], important);
} else if (lus.length == 1) {
- this.addDecl(CSS.MARGIN_TOP, lus[0], important);
- this.addDecl(CSS.MARGIN_LEFT, lus[0], important);
- this.addDecl(CSS.MARGIN_RIGHT, lus[0], important);
- this.addDecl(CSS.MARGIN_BOTTOM, lus[0], important);
+ addDecl(CSS.MARGIN_TOP, lus[0], important);
+ addDecl(CSS.MARGIN_LEFT, lus[0], important);
+ addDecl(CSS.MARGIN_RIGHT, lus[0], important);
+ addDecl(CSS.MARGIN_BOTTOM, lus[0], important);
}
}
/**
* Expand the "padding" shorthand property.
*/
- private void expandPadding(LexicalUnit value, boolean important) {
+ private void expandPadding(final LexicalUnit value, final boolean important) {
if (AbstractProperty.isInherit(value)) {
- this.addDecl(CSS.PADDING_TOP, value, important);
- this.addDecl(CSS.PADDING_LEFT, value, important);
- this.addDecl(CSS.PADDING_RIGHT, value, important);
- this.addDecl(CSS.PADDING_BOTTOM, value, important);
+ addDecl(CSS.PADDING_TOP, value, important);
+ addDecl(CSS.PADDING_LEFT, value, important);
+ addDecl(CSS.PADDING_RIGHT, value, important);
+ addDecl(CSS.PADDING_BOTTOM, value, important);
return;
}
- LexicalUnit[] lus = getLexicalUnitList(value);
+ final LexicalUnit[] lus = getLexicalUnitList(value);
if (lus.length >= 4) {
- this.addDecl(CSS.PADDING_TOP, lus[0], important);
- this.addDecl(CSS.PADDING_RIGHT, lus[1], important);
- this.addDecl(CSS.PADDING_BOTTOM, lus[2], important);
- this.addDecl(CSS.PADDING_LEFT, lus[3], important);
+ addDecl(CSS.PADDING_TOP, lus[0], important);
+ addDecl(CSS.PADDING_RIGHT, lus[1], important);
+ addDecl(CSS.PADDING_BOTTOM, lus[2], important);
+ addDecl(CSS.PADDING_LEFT, lus[3], important);
} else if (lus.length == 3) {
- this.addDecl(CSS.PADDING_TOP, lus[0], important);
- this.addDecl(CSS.PADDING_LEFT, lus[1], important);
- this.addDecl(CSS.PADDING_RIGHT, lus[1], important);
- this.addDecl(CSS.PADDING_BOTTOM, lus[2], important);
+ addDecl(CSS.PADDING_TOP, lus[0], important);
+ addDecl(CSS.PADDING_LEFT, lus[1], important);
+ addDecl(CSS.PADDING_RIGHT, lus[1], important);
+ addDecl(CSS.PADDING_BOTTOM, lus[2], important);
} else if (lus.length == 2) {
- this.addDecl(CSS.PADDING_TOP, lus[0], important);
- this.addDecl(CSS.PADDING_LEFT, lus[1], important);
- this.addDecl(CSS.PADDING_RIGHT, lus[1], important);
- this.addDecl(CSS.PADDING_BOTTOM, lus[0], important);
+ addDecl(CSS.PADDING_TOP, lus[0], important);
+ addDecl(CSS.PADDING_LEFT, lus[1], important);
+ addDecl(CSS.PADDING_RIGHT, lus[1], important);
+ addDecl(CSS.PADDING_BOTTOM, lus[0], important);
} else if (lus.length == 1) {
- this.addDecl(CSS.PADDING_TOP, lus[0], important);
- this.addDecl(CSS.PADDING_LEFT, lus[0], important);
- this.addDecl(CSS.PADDING_RIGHT, lus[0], important);
- this.addDecl(CSS.PADDING_BOTTOM, lus[0], important);
+ addDecl(CSS.PADDING_TOP, lus[0], important);
+ addDecl(CSS.PADDING_LEFT, lus[0], important);
+ addDecl(CSS.PADDING_RIGHT, lus[0], important);
+ addDecl(CSS.PADDING_BOTTOM, lus[0], important);
}
}
/**
- * Returns an array of <code>LexicalUnit</code> objects, the first of
- * which is given.
+ * Returns an array of <code>LexicalUnit</code> objects, the first of which is given.
*/
private static LexicalUnit[] getLexicalUnitList(LexicalUnit lu) {
- List<LexicalUnit> lus = new ArrayList<LexicalUnit>();
+ final List<LexicalUnit> lus = new ArrayList<LexicalUnit>();
while (lu != null) {
lus.add(lu);
lu = lu.getNextLexicalUnit();
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/Styles.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/Styles.java
index 7adff582..73f8b7e2 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/Styles.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/Styles.java
@@ -25,103 +25,100 @@ import org.eclipse.vex.core.internal.core.FontSpec;
public class Styles {
/** Maps property name (String) => value (Object) */
- private Map<String, Object> values = new HashMap<String, Object>();
+ private final Map<String, Object> values = new HashMap<String, Object>();
private List<String> content;
private FontSpec font;
/**
- * Returns the value of the given property, or null if the property does not
- * have a value.
+ * Returns the value of the given property, or null if the property does not have a value.
*
* @param propertyName
* @return
*/
- public Object get(String propertyName) {
- return this.values.get(propertyName);
+ public Object get(final String propertyName) {
+ return values.get(propertyName);
}
/**
* Returns the value of the <code>backgroundColor</code> property.
*/
public Color getBackgroundColor() {
- return (Color) this.values.get(CSS.BACKGROUND_COLOR);
+ return (Color) values.get(CSS.BACKGROUND_COLOR);
}
/**
* Returns the value of the <code>borderBottomColor</code> property.
*/
public Color getBorderBottomColor() {
- return (Color) this.values.get(CSS.BORDER_BOTTOM_COLOR);
+ return (Color) values.get(CSS.BORDER_BOTTOM_COLOR);
}
/**
* Returns the value of the <code>borderBottomStyle</code> property.
*/
public String getBorderBottomStyle() {
- return (String) this.values.get(CSS.BORDER_BOTTOM_STYLE);
+ return (String) values.get(CSS.BORDER_BOTTOM_STYLE);
}
/**
* Returns the value of the <code>borderLeftColor</code> property.
*/
public Color getBorderLeftColor() {
- return (Color) this.values.get(CSS.BORDER_LEFT_COLOR);
+ return (Color) values.get(CSS.BORDER_LEFT_COLOR);
}
/**
* Returns the value of the <code>borderLeftStyle</code> property.
*/
public String getBorderLeftStyle() {
- return (String) this.values.get(CSS.BORDER_LEFT_STYLE);
+ return (String) values.get(CSS.BORDER_LEFT_STYLE);
}
/**
* Returns the value of the <code>borderRightColor</code> property.
*/
public Color getBorderRightColor() {
- return (Color) this.values.get(CSS.BORDER_RIGHT_COLOR);
+ return (Color) values.get(CSS.BORDER_RIGHT_COLOR);
}
/**
* Returns the value of the <code>borderRightStyle</code> property.
*/
public String getBorderRightStyle() {
- return (String) this.values.get(CSS.BORDER_RIGHT_STYLE);
+ return (String) values.get(CSS.BORDER_RIGHT_STYLE);
}
/**
* Returns the value of the <code>borderSpacing</code> property.
*/
public BorderSpacingProperty.Value getBorderSpacing() {
- return (BorderSpacingProperty.Value) this.values
- .get(CSS.BORDER_SPACING);
+ return (BorderSpacingProperty.Value) values.get(CSS.BORDER_SPACING);
}
/**
* Returns the value of the <code>borderTopColor</code> property.
*/
public Color getBorderTopColor() {
- return (Color) this.values.get(CSS.BORDER_TOP_COLOR);
+ return (Color) values.get(CSS.BORDER_TOP_COLOR);
}
/**
* Returns the value of the <code>borderTopStyle</code> property.
*/
public String getBorderTopStyle() {
- return (String) this.values.get(CSS.BORDER_TOP_STYLE);
+ return (String) values.get(CSS.BORDER_TOP_STYLE);
}
/**
* Returns the value of the <code>color</code> property.
*/
public Color getColor() {
- return (Color) this.values.get(CSS.COLOR);
+ return (Color) values.get(CSS.COLOR);
}
/**
- * Returns a <code>List</code> of <code>ContentPart</code> objects
- * representing the <code>content</code> property.
+ * Returns a <code>List</code> of <code>ContentPart</code> objects representing the <code>content</code> property.
*/
public List<String> getContent() {
return content;
@@ -131,7 +128,7 @@ public class Styles {
* Returns the value of the <code>display</code> property.
*/
public String getDisplay() {
- return (String) this.values.get(CSS.DISPLAY);
+ return (String) values.get(CSS.DISPLAY);
}
/**
@@ -140,7 +137,7 @@ public class Styles {
public boolean isDisplayed() {
return !CSS.NONE.equals(getDisplay());
}
-
+
/**
* Returns the value of the <code>font</code> property.
*/
@@ -152,82 +149,72 @@ public class Styles {
* Returns the value of the <code>fontFamily</code> property.
*/
public String[] getFontFamilies() {
- return (String[]) this.values.get(CSS.FONT_FAMILY);
+ return (String[]) values.get(CSS.FONT_FAMILY);
}
/**
* Returns the value of the <code>fontSize</code> property.
*/
public float getFontSize() {
- return ((Float) this.values.get(CSS.FONT_SIZE)).floatValue();
+ return ((Float) values.get(CSS.FONT_SIZE)).floatValue();
}
/**
* Returns the value of the <code>fontStyle</code> property.
*/
public String getFontStyle() {
- return (String) this.values.get(CSS.FONT_STYLE);
+ return (String) values.get(CSS.FONT_STYLE);
}
/**
* Returns the value of the <code>fontWeight</code> property.
*/
public int getFontWeight() {
- return ((Integer) this.values.get(CSS.FONT_WEIGHT)).intValue();
+ return ((Integer) values.get(CSS.FONT_WEIGHT)).intValue();
}
/**
* Returns the value of the <code>lineHeight</code> property.
*/
public int getLineHeight() {
- return ((RelativeLength) this.values.get(CSS.LINE_HEIGHT)).get(Math
- .round(this.getFontSize()));
+ return ((RelativeLength) values.get(CSS.LINE_HEIGHT)).get(Math.round(getFontSize()));
}
/**
* Returns the value of the <code>listStyleType</code> property.
*/
public String getListStyleType() {
- return (String) this.values.get(CSS.LIST_STYLE_TYPE);
+ return (String) values.get(CSS.LIST_STYLE_TYPE);
}
/**
* Returns the value of the <code>textAlign</code> property.
*/
public String getTextAlign() {
- return (String) this.values.get(CSS.TEXT_ALIGN);
+ return (String) values.get(CSS.TEXT_ALIGN);
}
/**
* Returns the value of the <code>textDecoration</code> property.
*/
public String getTextDecoration() {
- return (String) this.values.get(CSS.TEXT_DECORATION);
+ return (String) values.get(CSS.TEXT_DECORATION);
}
/**
* Returns the value of the <code>whiteSpace</code> property.
*/
public String getWhiteSpace() {
- return (String) this.values.get(CSS.WHITE_SPACE);
+ return (String) values.get(CSS.WHITE_SPACE);
}
/**
- * Returns true if this element is block-formatted, or false if it is
- * inline-formatted.
+ * Returns true if this element is block-formatted, or false if it is inline-formatted.
*/
public boolean isBlock() {
- return this.getDisplay().equals(CSS.BLOCK)
- || this.getDisplay().equals(CSS.LIST_ITEM)
- || this.getDisplay().equals(CSS.TABLE)
- || this.getDisplay().equals(CSS.TABLE_CAPTION)
- || this.getDisplay().equals(CSS.TABLE_CELL)
- || this.getDisplay().equals(CSS.TABLE_COLUMN)
- || this.getDisplay().equals(CSS.TABLE_COLUMN_GROUP)
- || this.getDisplay().equals(CSS.TABLE_FOOTER_GROUP)
- || this.getDisplay().equals(CSS.TABLE_HEADER_GROUP)
- || this.getDisplay().equals(CSS.TABLE_ROW)
- || this.getDisplay().equals(CSS.TABLE_ROW_GROUP);
+ return getDisplay().equals(CSS.BLOCK) || getDisplay().equals(CSS.LIST_ITEM) || getDisplay().equals(CSS.TABLE) || getDisplay().equals(CSS.TABLE_CAPTION) || getDisplay().equals(CSS.TABLE_CELL)
+ || getDisplay().equals(CSS.TABLE_COLUMN) || getDisplay().equals(CSS.TABLE_COLUMN_GROUP) || getDisplay().equals(CSS.TABLE_FOOTER_GROUP) || getDisplay().equals(CSS.TABLE_HEADER_GROUP)
+ || getDisplay().equals(CSS.TABLE_ROW) || getDisplay().equals(CSS.TABLE_ROW_GROUP);
}
/**
@@ -238,18 +225,17 @@ public class Styles {
* @param value
* Value of the property.
*/
- public void put(String propertyName, Object value) {
- this.values.put(propertyName, value);
+ public void put(final String propertyName, final Object value) {
+ values.put(propertyName, value);
}
/**
* Sets the vale of the <code>content</code> property.
*
* @param content
- * <code>List</code> of <code>ContentPart</code> objects
- * representing the content.
+ * <code>List</code> of <code>ContentPart</code> objects representing the content.
*/
- public void setContent(List<String> content) {
+ public void setContent(final List<String> content) {
this.content = content;
}
@@ -259,62 +245,63 @@ public class Styles {
* @param font
* new value for the <code>font</code> property.
*/
- public void setFont(FontSpec font) {
+ public void setFont(final FontSpec font) {
this.font = font;
}
public RelativeLength getElementWidth() {
- return (RelativeLength) this.values.get(CSS.WIDTH);
+ return (RelativeLength) values.get(CSS.WIDTH);
}
public RelativeLength getElementHeight() {
- return (RelativeLength) this.values.get(CSS.HEIGHT);
+ return (RelativeLength) values.get(CSS.HEIGHT);
}
-
+
public boolean hasBackgroundImage() {
- return this.values.get(CSS.BACKGROUND_IMAGE) != null;
+ return values.get(CSS.BACKGROUND_IMAGE) != null;
}
-
+
public String getBackgroundImage() {
- final Object value = this.values.get(CSS.BACKGROUND_IMAGE);
- if (value == null)
+ final Object value = values.get(CSS.BACKGROUND_IMAGE);
+ if (value == null) {
return BackgroundImageProperty.DEFAULT;
+ }
return value.toString();
}
-
+
/**
* @return the value of border-bottom-width
*/
public int getBorderBottomWidth() {
- return ((Integer) this.values.get(CSS.BORDER_BOTTOM_WIDTH)).intValue();
+ return ((Integer) values.get(CSS.BORDER_BOTTOM_WIDTH)).intValue();
}
/**
* @return the value of border-left-width
*/
public int getBorderLeftWidth() {
- return ((Integer) this.values.get(CSS.BORDER_LEFT_WIDTH)).intValue();
+ return ((Integer) values.get(CSS.BORDER_LEFT_WIDTH)).intValue();
}
/**
* @return the value of border-right-width
*/
public int getBorderRightWidth() {
- return ((Integer) this.values.get(CSS.BORDER_RIGHT_WIDTH)).intValue();
+ return ((Integer) values.get(CSS.BORDER_RIGHT_WIDTH)).intValue();
}
/**
* @return the value of border-top-width
*/
public int getBorderTopWidth() {
- return ((Integer) this.values.get(CSS.BORDER_TOP_WIDTH)).intValue();
+ return ((Integer) values.get(CSS.BORDER_TOP_WIDTH)).intValue();
}
/**
* @return the value of margin-bottom
*/
public RelativeLength getMarginBottom() {
- return (RelativeLength) this.values.get(CSS.MARGIN_BOTTOM);
+ return (RelativeLength) values.get(CSS.MARGIN_BOTTOM);
// return marginBottom;
}
@@ -322,49 +309,49 @@ public class Styles {
* @return the value of margin-left
*/
public RelativeLength getMarginLeft() {
- return (RelativeLength) this.values.get(CSS.MARGIN_LEFT);
+ return (RelativeLength) values.get(CSS.MARGIN_LEFT);
}
/**
* @return the value of margin-right
*/
public RelativeLength getMarginRight() {
- return (RelativeLength) this.values.get(CSS.MARGIN_RIGHT);
+ return (RelativeLength) values.get(CSS.MARGIN_RIGHT);
}
/**
* @return the value of margin-top
*/
public RelativeLength getMarginTop() {
- return (RelativeLength) this.values.get(CSS.MARGIN_TOP);
+ return (RelativeLength) values.get(CSS.MARGIN_TOP);
}
/**
* @return the value of padding-bottom
*/
public RelativeLength getPaddingBottom() {
- return (RelativeLength) this.values.get(CSS.PADDING_BOTTOM);
+ return (RelativeLength) values.get(CSS.PADDING_BOTTOM);
}
/**
* @return the value of padding-left
*/
public RelativeLength getPaddingLeft() {
- return (RelativeLength) this.values.get(CSS.PADDING_LEFT);
+ return (RelativeLength) values.get(CSS.PADDING_LEFT);
}
/**
* @return the value of padding-right
*/
public RelativeLength getPaddingRight() {
- return (RelativeLength) this.values.get(CSS.PADDING_RIGHT);
+ return (RelativeLength) values.get(CSS.PADDING_RIGHT);
}
/**
* @return the value of padding-top
*/
public RelativeLength getPaddingTop() {
- return (RelativeLength) this.values.get(CSS.PADDING_TOP);
+ return (RelativeLength) values.get(CSS.PADDING_TOP);
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/TextAlignProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/TextAlignProperty.java
index 9dc34348..e0098f71 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/TextAlignProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/TextAlignProperty.java
@@ -25,7 +25,7 @@ public class TextAlignProperty extends AbstractProperty {
super(CSS.TEXT_ALIGN);
}
- public Object calculate(LexicalUnit lu, Styles parentStyles, Styles styles, Element element) {
+ public Object calculate(final LexicalUnit lu, final Styles parentStyles, final Styles styles, final Element element) {
if (TextAlignProperty.isTextAlign(lu)) {
return lu.getStringValue();
} else {
@@ -41,7 +41,7 @@ public class TextAlignProperty extends AbstractProperty {
// =================================================== PRIVATE
- private static boolean isTextAlign(LexicalUnit lu) {
+ private static boolean isTextAlign(final LexicalUnit lu) {
if (lu == null) {
return false;
} else if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/TextDecorationProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/TextDecorationProperty.java
index 3744286f..3853db3c 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/TextDecorationProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/TextDecorationProperty.java
@@ -25,7 +25,7 @@ public class TextDecorationProperty extends AbstractProperty {
super(CSS.TEXT_DECORATION);
}
- public Object calculate(LexicalUnit lu, Styles parentStyles, Styles styles, Element element) {
+ public Object calculate(final LexicalUnit lu, final Styles parentStyles, final Styles styles, final Element element) {
if (isTextDecoration(lu)) {
return lu.getStringValue();
} else {
@@ -46,14 +46,12 @@ public class TextDecorationProperty extends AbstractProperty {
* @param lu
* LexicalUnit to check.
*/
- private static boolean isTextDecoration(LexicalUnit lu) {
+ private static boolean isTextDecoration(final LexicalUnit lu) {
if (lu == null) {
return false;
} else if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
- String s = lu.getStringValue();
- return s.equals(CSS.NONE) || s.equals(CSS.UNDERLINE)
- || s.equals(CSS.OVERLINE) || s.equals(CSS.LINE_THROUGH)
- || s.equals(CSS.BLINK);
+ final String s = lu.getStringValue();
+ return s.equals(CSS.NONE) || s.equals(CSS.UNDERLINE) || s.equals(CSS.OVERLINE) || s.equals(CSS.LINE_THROUGH) || s.equals(CSS.BLINK);
} else {
return false;
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/WhiteSpaceProperty.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/WhiteSpaceProperty.java
index cec05f59..6058864a 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/WhiteSpaceProperty.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/css/WhiteSpaceProperty.java
@@ -29,7 +29,7 @@ public class WhiteSpaceProperty extends AbstractProperty {
*
*/
- public Object calculate(LexicalUnit lu, Styles parentStyles, Styles styles, Element element) {
+ public Object calculate(final LexicalUnit lu, final Styles parentStyles, final Styles styles, final Element element) {
if (isWhiteSpace(lu)) {
return lu.getStringValue();
} else {
@@ -49,13 +49,12 @@ public class WhiteSpaceProperty extends AbstractProperty {
* @param lu
* LexicalUnit to check.
*/
- public static boolean isWhiteSpace(LexicalUnit lu) {
+ public static boolean isWhiteSpace(final LexicalUnit lu) {
if (lu == null) {
return false;
} else if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
- String s = lu.getStringValue();
- return s.equals(CSS.NORMAL) || s.equals(CSS.PRE)
- || s.equals(CSS.NOWRAP);
+ final String s = lu.getStringValue();
+ return s.equals(CSS.NORMAL) || s.equals(CSS.PRE) || s.equals(CSS.NOWRAP);
} else {
return false;
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Attribute.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Attribute.java
index b702ce39..d8b13a8b 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Attribute.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Attribute.java
@@ -13,9 +13,8 @@ package org.eclipse.vex.core.internal.dom;
import org.eclipse.core.runtime.QualifiedName;
/**
- * An immutable representation of an attribute within the start tag of an
- * element.
- * The attribute is Comparable by its qualified name.
+ * An immutable representation of an attribute within the start tag of an element. The attribute is Comparable by its
+ * qualified name.
*
* @author Florian Thienel
*/
@@ -57,16 +56,18 @@ public class Attribute implements Comparable<Attribute> {
}
/**
- * @return prefix:localName, or localName if prefix is null or this
- * attribute is in the same namespace as the parent element.
+ * @return prefix:localName, or localName if prefix is null or this attribute is in the same namespace as the parent
+ * element.
*/
public String getPrefixedName() {
final String attributeQualifier = name.getQualifier();
- if (parent == null || attributeQualifier == null)
+ if (parent == null || attributeQualifier == null) {
return getLocalName();
+ }
final String elementQualifier = parent.getQualifiedName().getQualifier();
- if (attributeQualifier.equals(elementQualifier))
+ if (attributeQualifier.equals(elementQualifier)) {
return getLocalName();
+ }
final String prefix = parent.getNamespacePrefix(attributeQualifier);
return (prefix == null ? "" : prefix + ":") + getLocalName();
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/CommentElement.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/CommentElement.java
index 19e152e2..b9c77a59 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/CommentElement.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/CommentElement.java
@@ -18,9 +18,9 @@ import org.eclipse.core.runtime.QualifiedName;
public class CommentElement extends Element {
public static final QualifiedName ELEMENT_NAME = new QualifiedName(null, "<!-- COMMENT -->");
-
+
public static final String CSS_RULE_NAME = "COMMENT";
-
+
public CommentElement() {
super(ELEMENT_NAME);
}
@@ -29,5 +29,5 @@ public class CommentElement extends Element {
public CommentElement clone() {
return new CommentElement();
}
-
+
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Content.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Content.java
index bcfbdd58..6bef7b7c 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Content.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Content.java
@@ -10,11 +10,8 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.dom;
-
-
/**
- * Interface for classes that manage a string of characters representing the
- * content of a document.
+ * Interface for classes that manage a string of characters representing the content of a document.
*
* @model
*/
@@ -39,7 +36,7 @@ public interface Content {
* @model
*/
public void insertString(int offset, String s);
-
+
/**
* Insert an element marker into the content.
*
@@ -77,13 +74,13 @@ public interface Content {
* @model
*/
public int getLength();
-
+
/**
* Indicates if the given character is an element marker.
*
* @param c
- * The character to check.
- * @model
+ * The character to check.
+ * @model
*/
public boolean isElementMarker(char c);
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Document.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Document.java
index 11192281..39a2cd20 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Document.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Document.java
@@ -45,8 +45,7 @@ public class Document {
* Class constructor.
*
* @param rootElement
- * root element of the document. The document property of this
- * RootElement is set by this constructor.
+ * root element of the document. The document property of this RootElement is set by this constructor.
*
*/
public Document(final RootElement rootElement) {
@@ -60,8 +59,8 @@ public class Document {
}
/**
- * Class constructor. This constructor is used by the document builder and
- * assumes that the content and root element have bee properly set up.
+ * Class constructor. This constructor is used by the document builder and assumes that the content and root element
+ * have bee properly set up.
*
* @param content
* Content object used to store the document's content.
@@ -77,8 +76,7 @@ public class Document {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.vex.core.internal.dom.IVEXDocument#addDocumentListener
+ * @see org.eclipse.vex.core.internal.dom.IVEXDocument#addDocumentListener
* (org.eclipse.vex.core.internal.dom.DocumentListener)
*/
public void addDocumentListener(final DocumentListener listener) {
@@ -88,13 +86,13 @@ public class Document {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.vex.core.internal.dom.IVEXDocument#canInsertFragment
- * (int, org.eclipse.vex.core.internal.dom.DocumentFragment)
+ * @see org.eclipse.vex.core.internal.dom.IVEXDocument#canInsertFragment (int,
+ * org.eclipse.vex.core.internal.dom.DocumentFragment)
*/
public boolean canInsertFragment(final int offset, final DocumentFragment fragment) {
- if (validator == null)
+ if (validator == null) {
return true;
+ }
final Element element = getElementAt(offset);
final List<QualifiedName> seq1 = getNodeNames(element.getStartOffset() + 1, offset);
@@ -105,8 +103,9 @@ public class Document {
}
public boolean canInsertText(final int offset) {
- if (validator == null)
+ if (validator == null) {
return true;
+ }
final Element element = getElementAt(offset);
final List<QualifiedName> seq1 = getNodeNames(element.getStartOffset() + 1, offset);
@@ -124,16 +123,18 @@ public class Document {
final Element e1 = getElementAt(startOffset);
final Element e2 = getElementAt(endOffset);
- if (e1 != e2)
+ if (e1 != e2) {
throw new IllegalArgumentException("Deletion from " + startOffset + " to " + endOffset + " is unbalanced");
+ }
final Validator validator = getValidator();
if (validator != null) {
final List<QualifiedName> seq1 = getNodeNames(e1.getStartOffset() + 1, startOffset);
final List<QualifiedName> seq2 = getNodeNames(endOffset, e1.getEndOffset());
- if (!validator.isValidSequence(e1.getQualifiedName(), seq1, seq2, null, true))
+ if (!validator.isValidSequence(e1.getQualifiedName(), seq1, seq2, null, true)) {
throw new DocumentValidationException("Unable to delete from " + startOffset + " to " + endOffset);
+ }
}
// Grab the fragment for the undoable edit while it's still here
@@ -142,12 +143,14 @@ public class Document {
fireBeforeContentDeleted(new DocumentEvent(this, e1, startOffset, endOffset - startOffset, null));
Iterator<Node> iter = e1.getChildNodes().iterator();
- if (e1 instanceof Element)
+ if (e1 instanceof Element) {
iter = e1.getChildIterator();
+ }
while (iter.hasNext()) {
final Node child = iter.next();
- if (startOffset <= child.getStartOffset() && child.getEndOffset() < endOffset)
+ if (startOffset <= child.getStartOffset() && child.getEndOffset() < endOffset) {
iter.remove();
+ }
}
content.remove(startOffset, endOffset - startOffset);
@@ -162,16 +165,17 @@ public class Document {
for (;;) {
boolean tryAgain = false;
final List<Element> children = element.getChildElements();
- for (int i = 0; i < children.size(); i++)
- if (offset1 > children.get(i).getStartOffset() && offset2 > children.get(i).getStartOffset() && offset1 <= children.get(i).getEndOffset()
- && offset2 <= children.get(i).getEndOffset()) {
+ for (int i = 0; i < children.size(); i++) {
+ if (offset1 > children.get(i).getStartOffset() && offset2 > children.get(i).getStartOffset() && offset1 <= children.get(i).getEndOffset() && offset2 <= children.get(i).getEndOffset()) {
element = children.get(i);
tryAgain = true;
break;
}
- if (!tryAgain)
+ }
+ if (!tryAgain) {
break;
+ }
}
return element;
}
@@ -181,24 +185,26 @@ public class Document {
}
public Element getElementAt(final int offset) {
- if (offset < 1 || offset >= getLength())
+ if (offset < 1 || offset >= getLength()) {
throw new IllegalArgumentException("Illegal offset: " + offset + ". Must be between 1 and n-1");
+ }
Element element = rootElement;
for (;;) {
boolean tryAgain = false;
final List<Element> children = element.getChildElements();
for (int i = 0; i < children.size(); i++) {
final Element child = children.get(i);
- if (offset <= child.getStartOffset())
+ if (offset <= child.getStartOffset()) {
return element;
- else if (offset <= child.getEndOffset()) {
+ } else if (offset <= child.getEndOffset()) {
element = child;
tryAgain = true;
break;
}
}
- if (!tryAgain)
+ if (!tryAgain) {
break;
+ }
}
return element;
}
@@ -216,13 +222,15 @@ public class Document {
assertOffset(startOffset, 0, content.getLength());
assertOffset(endOffset, 0, content.getLength());
- if (endOffset <= startOffset)
+ if (endOffset <= startOffset) {
throw new IllegalArgumentException("Invalid range (" + startOffset + ", " + endOffset + ")");
+ }
final Element e1 = getElementAt(startOffset);
final Element e2 = getElementAt(endOffset);
- if (e1 != e2)
+ if (e1 != e2) {
throw new IllegalArgumentException("Fragment from " + startOffset + " to " + endOffset + " is unbalanced");
+ }
final List<Element> children = e1.getChildElements();
@@ -232,12 +240,13 @@ public class Document {
final List<Element> newChildren = new ArrayList<Element>();
for (int i = 0; i < children.size(); i++) {
final Element child = children.get(i);
- if (child.getEndOffset() <= startOffset)
+ if (child.getEndOffset() <= startOffset) {
continue;
- else if (child.getStartOffset() >= endOffset)
+ } else if (child.getStartOffset() >= endOffset) {
break;
- else
+ } else {
newChildren.add(cloneElement(child, newContent, -startOffset, null));
+ }
}
return new DocumentFragment(newContent, newChildren);
@@ -254,10 +263,11 @@ public class Document {
for (int i = 0; i < nodes.size(); i++) {
final Node node = nodes.get(i);
- if (node instanceof Element)
+ if (node instanceof Element) {
names.add(((Element) node).getQualifiedName());
- else
+ } else {
names.add(Validator.PCDATA);
+ }
}
return names;
@@ -266,30 +276,32 @@ public class Document {
/*
* (non-Javadoc)
*
- * @see org.eclipse.vex.core.internal.dom.IVEXDocument#getNodes(int,
- * int)
+ * @see org.eclipse.vex.core.internal.dom.IVEXDocument#getNodes(int, int)
*/
public List<Node> getNodes(final int startOffset, final int endOffset) {
final Element element = getElementAt(startOffset);
- if (element != getElementAt(endOffset))
- throw new IllegalArgumentException(NLS.bind("Offsets are unbalanced: {0} is in {1}, {2} is in {3}.", new Object[] {startOffset, element.getPrefixedName(), endOffset,getElementAt(endOffset).getPrefixedName()}));
+ if (element != getElementAt(endOffset)) {
+ throw new IllegalArgumentException(NLS.bind("Offsets are unbalanced: {0} is in {1}, {2} is in {3}.",
+ new Object[] { startOffset, element.getPrefixedName(), endOffset, getElementAt(endOffset).getPrefixedName() }));
+ }
final List<Node> list = new ArrayList<Node>();
final List<Node> nodes = element.getChildNodes();
for (int i = 0; i < nodes.size(); i++) {
final Node node = nodes.get(i);
- if (node.getEndOffset() <= startOffset)
+ if (node.getEndOffset() <= startOffset) {
continue;
- else if (node.getStartOffset() >= endOffset)
+ } else if (node.getStartOffset() >= endOffset) {
break;
- else if (node instanceof Element)
+ } else if (node instanceof Element) {
list.add(node);
- else {
+ } else {
final Text text = (Text) node;
- if (text.getStartOffset() < startOffset)
+ if (text.getStartOffset() < startOffset) {
text.setContent(text.getContent(), startOffset, text.getEndOffset());
- else if (text.getEndOffset() > endOffset)
+ } else if (text.getEndOffset() > endOffset) {
text.setContent(text.getContent(), text.getStartOffset(), endOffset);
+ }
list.add(text);
}
}
@@ -298,9 +310,8 @@ public class Document {
}
/**
- * Creates an array of nodes for a given run of content. The returned array
- * includes the given child elements and <code>Text</code> objects where
- * text appears between elements.
+ * Creates an array of nodes for a given run of content. The returned array includes the given child elements and
+ * <code>Text</code> objects where text appears between elements.
*
* @param content
* Content object containing the content
@@ -317,14 +328,16 @@ public class Document {
int offset = startOffset;
for (int i = 0; i < elements.size(); i++) {
final int start = elements.get(i).getStartOffset();
- if (offset < start)
+ if (offset < start) {
nodes.add(new Text(content, offset, start));
+ }
nodes.add(elements.get(i));
offset = elements.get(i).getEndOffset() + 1;
}
- if (offset < endOffset)
+ if (offset < endOffset) {
nodes.add(new Text(content, offset, endOffset));
+ }
return nodes;
}
@@ -341,9 +354,7 @@ public class Document {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.vex.core.internal.dom.IVEXDocument#getRawText(int,
- * int)
+ * @see org.eclipse.vex.core.internal.dom.IVEXDocument#getRawText(int, int)
*/
public String getRawText(final int startOffset, final int endOffset) {
return content.getString(startOffset, endOffset - startOffset);
@@ -362,8 +373,9 @@ public class Document {
final StringBuffer sb = new StringBuffer(raw.length());
for (int i = 0; i < raw.length(); i++) {
final char c = raw.charAt(i);
- if (!content.isElementMarker(c))
+ if (!content.isElementMarker(c)) {
sb.append(c);
+ }
}
return sb.toString();
}
@@ -374,9 +386,9 @@ public class Document {
public void insertElement(final int offset, final Element element) throws DocumentValidationException {
- if (offset < 1 || offset >= getLength())
- throw new IllegalArgumentException("Error inserting element <" + element.getPrefixedName() + ">: offset is " + offset + ", but it must be between 1 and "
- + (getLength() - 1));
+ if (offset < 1 || offset >= getLength()) {
+ throw new IllegalArgumentException("Error inserting element <" + element.getPrefixedName() + ">: offset is " + offset + ", but it must be between 1 and " + (getLength() - 1));
+ }
final Validator validator = getValidator();
if (validator != null) {
@@ -385,8 +397,9 @@ public class Document {
final List<QualifiedName> seq2 = Collections.singletonList(element.getQualifiedName());
final List<QualifiedName> seq3 = getNodeNames(offset, parent.getEndOffset());
- if (!validator.isValidSequence(parent.getQualifiedName(), seq1, seq2, seq3, true))
+ if (!validator.isValidSequence(parent.getQualifiedName(), seq1, seq2, seq3, true)) {
throw new DocumentValidationException("Cannot insert element " + element.getPrefixedName() + " at offset " + offset);
+ }
}
// find the parent, and the index into its children at which
@@ -429,8 +442,9 @@ public class Document {
public void insertFragment(final int offset, final DocumentFragment fragment) throws DocumentValidationException {
- if (offset < 1 || offset >= getLength())
+ if (offset < 1 || offset >= getLength()) {
throw new IllegalArgumentException("Error inserting document fragment");
+ }
final Element parent = getElementAt(offset);
@@ -439,8 +453,9 @@ public class Document {
final List<QualifiedName> seq2 = fragment.getNodeNames();
final List<QualifiedName> seq3 = getNodeNames(offset, parent.getEndOffset());
- if (!validator.isValidSequence(parent.getQualifiedName(), seq1, seq2, seq3, true))
+ if (!validator.isValidSequence(parent.getQualifiedName(), seq1, seq2, seq3, true)) {
throw new DocumentValidationException("Cannot insert document fragment");
+ }
}
fireBeforeContentInserted(new DocumentEvent(this, parent, offset, 2, null));
@@ -451,8 +466,9 @@ public class Document {
final List<Element> children = parent.getChildElements();
int index = 0;
- while (index < children.size() && children.get(index).getEndOffset() < offset)
+ while (index < children.size() && children.get(index).getEndOffset() < offset) {
index++;
+ }
final List<Element> elements = fragment.getElements();
for (int i = 0; i < elements.size(); i++) {
@@ -468,17 +484,18 @@ public class Document {
public void insertText(final int offset, final String text) throws DocumentValidationException {
- if (offset < 1 || offset >= getLength())
+ if (offset < 1 || offset >= getLength()) {
throw new IllegalArgumentException("Offset must be between 1 and n-1");
+ }
final Element parent = getElementAt(offset);
boolean isValid = false;
- if (!content.isElementMarker(getCharacterAt(offset - 1)))
+ if (!content.isElementMarker(getCharacterAt(offset - 1))) {
isValid = true;
- else if (!content.isElementMarker(getCharacterAt(offset)))
+ } else if (!content.isElementMarker(getCharacterAt(offset))) {
isValid = true;
- else {
+ } else {
final Validator validator = getValidator();
if (validator != null) {
final List<QualifiedName> seq1 = getNodeNames(parent.getStartOffset() + 1, offset);
@@ -486,18 +503,22 @@ public class Document {
final List<QualifiedName> seq3 = getNodeNames(offset, parent.getEndOffset());
isValid = validator.isValidSequence(parent.getQualifiedName(), seq1, seq2, seq3, true);
- } else
+ } else {
isValid = true;
+ }
}
- if (!isValid)
+ if (!isValid) {
throw new DocumentValidationException("Cannot insert text '" + text + "' at offset " + offset);
+ }
// Convert control chars to spaces
final StringBuffer sb = new StringBuffer(text);
- for (int i = 0; i < sb.length(); i++)
- if (Character.isISOControl(sb.charAt(i)) && sb.charAt(i) != '\n')
+ for (int i = 0; i < sb.length(); i++) {
+ if (Character.isISOControl(sb.charAt(i)) && sb.charAt(i) != '\n') {
sb.setCharAt(i, ' ');
+ }
+ }
final String s = sb.toString();
@@ -513,8 +534,7 @@ public class Document {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.vex.core.internal.dom.IVEXDocument#isUndoEnabled()
+ * @see org.eclipse.vex.core.internal.dom.IVEXDocument#isUndoEnabled()
*/
public boolean isUndoEnabled() {
return undoEnabled;
@@ -523,8 +543,7 @@ public class Document {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.vex.core.internal.dom.IVEXDocument#removeDocumentListener
+ * @see org.eclipse.vex.core.internal.dom.IVEXDocument#removeDocumentListener
* (org.eclipse.vex.core.internal.dom.DocumentListener)
*/
public void removeDocumentListener(final DocumentListener listener) {
@@ -534,9 +553,7 @@ public class Document {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.vex.core.internal.dom.IVEXDocument#setPublicID(java
- * .lang.String)
+ * @see org.eclipse.vex.core.internal.dom.IVEXDocument#setPublicID(java .lang.String)
*/
public void setPublicID(final String publicID) {
this.publicID = publicID;
@@ -545,9 +562,7 @@ public class Document {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.vex.core.internal.dom.IVEXDocument#setSystemID(java
- * .lang.String)
+ * @see org.eclipse.vex.core.internal.dom.IVEXDocument#setSystemID(java .lang.String)
*/
public void setSystemID(final String systemID) {
this.systemID = systemID;
@@ -556,9 +571,7 @@ public class Document {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.vex.core.internal.dom.IVEXDocument#setUndoEnabled
- * (boolean)
+ * @see org.eclipse.vex.core.internal.dom.IVEXDocument#setUndoEnabled (boolean)
*/
public void setUndoEnabled(final boolean undoEnabled) {
this.undoEnabled = undoEnabled;
@@ -567,9 +580,7 @@ public class Document {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.vex.core.internal.dom.IVEXDocument#setValidator(org
- * .eclipse.vex.core.internal.dom.Validator)
+ * @see org.eclipse.vex.core.internal.dom.IVEXDocument#setValidator(org .eclipse.vex.core.internal.dom.Validator)
*/
public void setValidator(final Validator validator) {
this.validator = validator;
@@ -752,12 +763,12 @@ public class Document {
}
/**
- * Assert that the given offset is within the given range, throwing
- * IllegalArgumentException if not.
+ * Assert that the given offset is within the given range, throwing IllegalArgumentException if not.
*/
private static void assertOffset(final int offset, final int min, final int max) {
- if (offset < min || offset > max)
+ if (offset < min || offset > max) {
throw new IllegalArgumentException("Bad offset " + offset + "must be between " + min + " and " + max);
+ }
}
/**
@@ -793,7 +804,7 @@ public class Document {
public void fireNamespaceChanged(final DocumentEvent e) {
listeners.fireEvent("namespaceChanged", e);
}
-
+
private void fireBeforeContentDeleted(final DocumentEvent e) {
listeners.fireEvent("beforeContentDeleted", e);
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentBuilder.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentBuilder.java
index 743a6833..b335f478 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentBuilder.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentBuilder.java
@@ -23,20 +23,19 @@ import org.xml.sax.SAXParseException;
import org.xml.sax.ext.LexicalHandler;
/**
- * A SAX handler that builds a Vex document. This builder collapses whitespace
- * as it goes, according to the following rules.
+ * A SAX handler that builds a Vex document. This builder collapses whitespace as it goes, according to the following
+ * rules.
*
* <ul>
* <li>Elements with style white-space: pre are left alone.</li>
* <li>Runs of whitespace are replaced with a single space.</li>
* <li>Space just inside the start and end of elements is removed.</li>
- * <li>Space just outside the start and end of block-formatted elements is
- * removed.</li>
+ * <li>Space just outside the start and end of block-formatted elements is removed.</li>
* </ul>
*/
public class DocumentBuilder implements ContentHandler, LexicalHandler {
- private DocumentContentModel documentContentModel;
+ private final DocumentContentModel documentContentModel;
private IWhitespacePolicy policy;
@@ -86,10 +85,11 @@ public class DocumentBuilder implements ContentHandler, LexicalHandler {
private void appendPendingCharsFiltered(final char[] ch, final int start, final int length) {
// Convert control characters to spaces, since we use nulls for element delimiters
for (int i = start; i < start + length; i++) {
- if (isControlCharacter(ch[i]))
+ if (isControlCharacter(ch[i])) {
pendingChars.append(' ');
- else
+ } else {
pendingChars.append(ch[i]);
+ }
}
}
@@ -98,8 +98,9 @@ public class DocumentBuilder implements ContentHandler, LexicalHandler {
}
public void endDocument() {
- if (rootElement == null)
+ if (rootElement == null) {
return;
+ }
document = new Document(content, rootElement);
document.setPublicID(dtdPublicID);
@@ -117,8 +118,9 @@ public class DocumentBuilder implements ContentHandler, LexicalHandler {
content.insertElementMarker(content.getLength());
entry.element.setContent(content, entry.offset, content.getLength() - 1);
- if (isBlock(entry.element))
+ if (isBlock(entry.element)) {
trimLeading = true;
+ }
}
public void endPrefixMapping(final String prefix) {
@@ -142,10 +144,11 @@ public class DocumentBuilder implements ContentHandler, LexicalHandler {
public void startElement(final String namespaceURI, final String localName, final String qName, final Attributes attrs) throws SAXException {
final QualifiedName elementName;
- if ("".equals(namespaceURI))
+ if ("".equals(namespaceURI)) {
elementName = new QualifiedName(null, qName);
- else
+ } else {
elementName = new QualifiedName(namespaceURI, localName);
+ }
Element element;
if (stack.isEmpty()) {
rootElement = new RootElement(elementName);
@@ -158,21 +161,24 @@ public class DocumentBuilder implements ContentHandler, LexicalHandler {
}
final String defaultNamespaceUri = namespaceStack.peekDefault();
- if (defaultNamespaceUri != null)
+ if (defaultNamespaceUri != null) {
element.declareDefaultNamespace(defaultNamespaceUri);
+ }
- for (final String prefix : namespaceStack.getPrefixes())
+ for (final String prefix : namespaceStack.getPrefixes()) {
element.declareNamespace(prefix, namespaceStack.peek(prefix));
+ }
final int n = attrs.getLength();
for (int i = 0; i < n; i++) {
final QualifiedName attributeName;
- if ("".equals(attrs.getLocalName(i)))
+ if ("".equals(attrs.getLocalName(i))) {
attributeName = new QualifiedName(null, attrs.getQName(i));
- else if ("".equals(attrs.getURI(i)))
+ } else if ("".equals(attrs.getURI(i))) {
attributeName = new QualifiedName(elementName.getQualifier(), attrs.getLocalName(i));
- else
+ } else {
attributeName = new QualifiedName(attrs.getURI(i), attrs.getLocalName(i));
+ }
try {
element.setAttribute(attributeName, attrs.getValue(i));
} catch (final DocumentValidationException e) {
@@ -197,10 +203,11 @@ public class DocumentBuilder implements ContentHandler, LexicalHandler {
public void startPrefixMapping(final String prefix, final String uri) {
checkPrefix(prefix);
- if (isDefaultPrefix(prefix))
+ if (isDefaultPrefix(prefix)) {
namespaceStack.pushDefault(uri);
- else
+ } else {
namespaceStack.push(prefix, uri);
+ }
}
private static void checkPrefix(final String prefix) {
@@ -214,8 +221,9 @@ public class DocumentBuilder implements ContentHandler, LexicalHandler {
// ============================================== LexicalHandler methods
public void comment(final char[] ch, final int start, final int length) {
- if (stack.isEmpty()) // TODO support comments outside of the root element
+ if (stack.isEmpty()) {
return;
+ }
final CommentElement element = new CommentElement();
final Element parent = stack.getLast().element;
@@ -231,8 +239,9 @@ public class DocumentBuilder implements ContentHandler, LexicalHandler {
content.insertElementMarker(content.getLength());
element.setContent(content, startOffset, content.getLength() - 1);
- if (isBlock(element))
+ if (isBlock(element)) {
trimLeading = true;
+ }
}
public void endCDATA() {
@@ -274,18 +283,18 @@ public class DocumentBuilder implements ContentHandler, LexicalHandler {
StringBuilder sb;
final StackEntry entry = stack.isEmpty() ? null : stack.getLast();
- if (entry != null && entry.pre)
+ if (entry != null && entry.pre) {
sb = pendingChars;
- else {
+ } else {
// collapse the space in the pending characters
sb = new StringBuilder(pendingChars.length());
boolean ws = false; // true if we're in a run of whitespace
for (int i = 0; i < pendingChars.length(); i++) {
final char c = pendingChars.charAt(i);
- if (Character.isWhitespace(c))
+ if (Character.isWhitespace(c)) {
ws = true;
- else {
+ } else {
if (ws) {
sb.append(' ');
ws = false;
@@ -293,13 +302,16 @@ public class DocumentBuilder implements ContentHandler, LexicalHandler {
sb.append(c);
}
}
- if (ws)
+ if (ws) {
sb.append(' ');
+ }
// trim leading and trailing space, if necessary
- if (trimLeading && sb.length() > 0 && sb.charAt(0) == ' ')
+ if (trimLeading && sb.length() > 0 && sb.charAt(0) == ' ') {
sb.deleteCharAt(0);
- if (trimTrailing && sb.length() > 0 && sb.charAt(sb.length() - 1) == ' ')
+ }
+ if (trimTrailing && sb.length() > 0 && sb.charAt(sb.length() - 1) == ' ') {
sb.setLength(sb.length() - 1);
+ }
}
normalizeNewlines(sb);
@@ -335,8 +347,9 @@ public class DocumentBuilder implements ContentHandler, LexicalHandler {
switch (state) {
case START:
- if (c == '\r')
+ if (c == '\r') {
state = SEEN_CR;
+ }
i++;
break;
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentContentModel.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentContentModel.java
index 113ba211..3ecbc67b 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentContentModel.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentContentModel.java
@@ -46,17 +46,20 @@ public class DocumentContentModel implements EntityResolver {
this.baseUri = baseUri;
this.publicId = publicId;
this.systemId = systemId;
- if (rootElement != null)
+ if (rootElement != null) {
schemaId = rootElement.getQualifiedName().getQualifier();
- else
+ } else {
schemaId = null;
+ }
}
public String getMainDocumentTypeIdentifier() {
- if (publicId != null)
+ if (publicId != null) {
return publicId;
- if (systemId != null)
+ }
+ if (systemId != null) {
return systemId;
+ }
return schemaId;
}
@@ -66,14 +69,16 @@ public class DocumentContentModel implements EntityResolver {
public CMDocument getDTD() {
final URL resolvedPublicId = resolveSchemaIdentifier(publicId);
- if (resolvedPublicId != null)
+ if (resolvedPublicId != null) {
return createCMDocument(resolvedPublicId);
+ }
return createCMDocument(resolveSystemId(systemId));
}
private CMDocument createCMDocument(final URL resolvedDtdUrl) {
- if (resolvedDtdUrl == null)
+ if (resolvedDtdUrl == null) {
return null;
+ }
final ContentModelManager modelManager = ContentModelManager.getInstance();
return modelManager.createCMDocument(resolvedDtdUrl.toString(), null);
}
@@ -85,8 +90,9 @@ public class DocumentContentModel implements EntityResolver {
public InputSource resolveEntity(final String publicId, final String systemId) throws SAXException, IOException {
final String resolved = URI_RESOLVER.resolve(baseUri, publicId, systemId);
System.out.println("Resolved " + publicId + " " + systemId + " -> " + resolved);
- if (resolved == null)
+ if (resolved == null) {
return null;
+ }
final InputSource result = new InputSource(resolved);
result.setPublicId(publicId);
@@ -94,36 +100,35 @@ public class DocumentContentModel implements EntityResolver {
}
public URL resolveSchemaIdentifier(final String schemaIdentifier) {
- if (schemaIdentifier == null)
+ if (schemaIdentifier == null) {
return null;
+ }
final String schemaLocation = URI_RESOLVER.resolve(baseUri, schemaIdentifier, null);
- if (schemaLocation == null)
+ if (schemaLocation == null) {
/*
- * TODO this is a common case that should be handled somehow
- * - a hint should be shown: the schema is not available, the schema
- * should be added to the catalog by the user
- * - an inferred schema should be used, to allow to at least display
- * the document in the editor
- * - this is not the right place to either check or handle this
+ * TODO this is a common case that should be handled somehow - a hint should be shown: the schema is not
+ * available, the schema should be added to the catalog by the user - an inferred schema should be used, to
+ * allow to at least display the document in the editor - this is not the right place to either check or
+ * handle this
*/
return null;
+ }
try {
return new URL(schemaLocation);
} catch (final MalformedURLException e) {
- throw new AssertionError(MessageFormat.format("Resolution of schema ''{0}'' resulted in a malformed URL: ''{1}''. {2}", schemaIdentifier,
- schemaLocation, e.getMessage()));
+ throw new AssertionError(MessageFormat.format("Resolution of schema ''{0}'' resulted in a malformed URL: ''{1}''. {2}", schemaIdentifier, schemaLocation, e.getMessage()));
}
}
public URL resolveSystemId(final String systemId) {
final String schemaLocation = URI_RESOLVER.resolve(baseUri, null, systemId);
- if (schemaLocation == null)
+ if (schemaLocation == null) {
return null;
+ }
try {
return new URL(schemaLocation);
} catch (final MalformedURLException e) {
- throw new AssertionError(MessageFormat.format("Resolution of systemId ''{0}'' resulted in a malformed URL: ''{1}''. {2}", systemId,
- schemaLocation, e.getMessage()));
+ throw new AssertionError(MessageFormat.format("Resolution of systemId ''{0}'' resulted in a malformed URL: ''{1}''. {2}", systemId, schemaLocation, e.getMessage()));
}
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentEvent.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentEvent.java
index 7b215509..433921ee 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentEvent.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentEvent.java
@@ -17,20 +17,21 @@ import org.eclipse.vex.core.internal.undo.IUndoableEdit;
/**
* Encapsulation of the details of a document change
+ *
* @model
*/
public class DocumentEvent extends EventObject {
private static final long serialVersionUID = -9028980559838712720L;
-
- private Document document;
- private Element parentElement;
+
+ private final Document document;
+ private final Element parentElement;
private int offset;
private int length;
private QualifiedName attributeName;
private String oldAttributeValue;
private String newAttributeValue;
- private IUndoableEdit undoableEdit;
+ private final IUndoableEdit undoableEdit;
/**
* Class constructor.
@@ -46,12 +47,11 @@ public class DocumentEvent extends EventObject {
* @param undoableEdit
* IUndoableEdit that can be used to undo the change.
*/
- public DocumentEvent(Document document, Element e1, int offset,
- int length, IUndoableEdit undoableEdit) {
+ public DocumentEvent(final Document document, final Element e1, final int offset, final int length, final IUndoableEdit undoableEdit) {
super(document);
this.document = document;
- this.parentElement = e1;
+ parentElement = e1;
this.offset = offset;
this.length = length;
this.undoableEdit = undoableEdit;
@@ -73,9 +73,8 @@ public class DocumentEvent extends EventObject {
* @param undoableEdit
* IUndoableEdit that can be used to undo the change.
*/
- public DocumentEvent(Document document, Element parentElement,
- QualifiedName attributeName, String oldAttributeValue,
- String newAttributeValue, IUndoableEdit undoableEdit) {
+ public DocumentEvent(final Document document, final Element parentElement, final QualifiedName attributeName, final String oldAttributeValue, final String newAttributeValue,
+ final IUndoableEdit undoableEdit) {
super(document);
this.document = document;
@@ -88,31 +87,33 @@ public class DocumentEvent extends EventObject {
/**
* Returns the length of the change.
+ *
* @model
*/
public int getLength() {
- return this.length;
+ return length;
}
/**
* Returns the offset at which the change occurred.
+ *
* @model
*/
public int getOffset() {
- return this.offset;
+ return offset;
}
/**
* Returns the element containing the change.
+ *
* @model
*/
public Element getParentElement() {
- return this.parentElement;
+ return parentElement;
}
/**
- * @return the value of the attribute before the change. If null, indicates
- * that the attribute was removed.
+ * @return the value of the attribute before the change. If null, indicates that the attribute was removed.
* @model
*/
public String getNewAttributeValue() {
@@ -120,8 +121,8 @@ public class DocumentEvent extends EventObject {
}
/**
- * @return the value of the attribute after the change. If null, indicates
- * the attribute did not exist before the change.
+ * @return the value of the attribute after the change. If null, indicates the attribute did not exist before the
+ * change.
* @model
*/
public String getOldAttributeValue() {
@@ -145,8 +146,9 @@ public class DocumentEvent extends EventObject {
}
/**
- * Returns the undoable edit that can be used to undo the action. May be
- * null, in which case the action cannot be undone.
+ * Returns the undoable edit that can be used to undo the action. May be null, in which case the action cannot be
+ * undone.
+ *
* @model
*/
public IUndoableEdit getUndoableEdit() {
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentFragment.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentFragment.java
index 902d5d15..22452731 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentFragment.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentFragment.java
@@ -54,9 +54,7 @@ public class DocumentFragment implements Serializable {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.vex.core.internal.dom.IVEXDocumentFragment#getContent
- * ()
+ * @see org.eclipse.vex.core.internal.dom.IVEXDocumentFragment#getContent ()
*/
public Content getContent() {
return content;
@@ -65,9 +63,7 @@ public class DocumentFragment implements Serializable {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.vex.core.internal.dom.IVEXDocumentFragment#getLength
- * ()
+ * @see org.eclipse.vex.core.internal.dom.IVEXDocumentFragment#getLength ()
*/
public int getLength() {
return content.getLength();
@@ -76,9 +72,7 @@ public class DocumentFragment implements Serializable {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.vex.core.internal.dom.IVEXDocumentFragment#getElements
- * ()
+ * @see org.eclipse.vex.core.internal.dom.IVEXDocumentFragment#getElements ()
*/
public List<Element> getElements() {
return elements;
@@ -87,18 +81,18 @@ public class DocumentFragment implements Serializable {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.vex.core.internal.dom.IVEXDocumentFragment#getNodeNames
- * ()
+ * @see org.eclipse.vex.core.internal.dom.IVEXDocumentFragment#getNodeNames ()
*/
public List<QualifiedName> getNodeNames() {
final List<Node> nodes = getNodes();
final List<QualifiedName> names = new ArrayList<QualifiedName>(nodes.size());
- for (Node node : nodes)
- if (node instanceof Text)
+ for (final Node node : nodes) {
+ if (node instanceof Text) {
names.add(Validator.PCDATA);
- else
+ } else {
names.add(((Element) node).getQualifiedName());
+ }
+ }
return names;
}
@@ -106,8 +100,7 @@ public class DocumentFragment implements Serializable {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.vex.core.internal.dom.IVEXDocumentFragment#getNodes()
+ * @see org.eclipse.vex.core.internal.dom.IVEXDocumentFragment#getNodes()
*/
public List<Node> getNodes() {
return Document.createNodeList(getContent(), 0, getContent().getLength(), getNodes(getElements()));
@@ -115,9 +108,11 @@ public class DocumentFragment implements Serializable {
private List<Node> getNodes(final List<Element> elements) {
final List<Node> nodes = new ArrayList<Node>();
- for (final Node node : elements)
- if (node.getNodeType().equals("Element"))
+ for (final Node node : elements) {
+ if (node.getNodeType().equals("Element")) {
nodes.add(node);
+ }
+ }
return nodes;
}
@@ -128,8 +123,9 @@ public class DocumentFragment implements Serializable {
private void writeObject(final ObjectOutputStream out) throws IOException {
out.writeUTF(content.getString(0, content.getLength()));
out.writeInt(elements.size());
- for (int i = 0; i < elements.size(); i++)
+ for (int i = 0; i < elements.size(); i++) {
writeElement(elements.get(i), out);
+ }
}
private void writeElement(final Element element, final ObjectOutputStream out) throws IOException {
@@ -145,8 +141,9 @@ public class DocumentFragment implements Serializable {
}
final List<Element> children = element.getChildElements();
out.writeInt(children.size());
- for (int i = 0; i < children.size(); i++)
+ for (int i = 0; i < children.size(); i++) {
writeElement(children.get(i), out);
+ }
}
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
@@ -155,8 +152,9 @@ public class DocumentFragment implements Serializable {
content.insertString(0, s);
final int n = in.readInt();
elements = new ArrayList<Element>(n);
- for (int i = 0; i < n; i++)
+ for (int i = 0; i < n; i++) {
elements.add(readElement(in));
+ }
}
private Element readElement(final ObjectInputStream in) throws IOException, ClassNotFoundException {
@@ -191,8 +189,9 @@ public class DocumentFragment implements Serializable {
private static QualifiedName createQualifiedName(final Object object) {
final String serializedQualifiedName = object.toString();
final int localNameStartIndex = serializedQualifiedName.lastIndexOf(':') + 1;
- if (localNameStartIndex == 0)
+ if (localNameStartIndex == 0) {
return new QualifiedName(null, serializedQualifiedName);
+ }
final String qualifier = serializedQualifiedName.substring(0, localNameStartIndex - 1);
final String localName = serializedQualifiedName.substring(localNameStartIndex);
return new QualifiedName(qualifier, localName);
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentListener.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentListener.java
index 1e5092de..8db97075 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentListener.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentListener.java
@@ -30,7 +30,7 @@ public interface DocumentListener extends java.util.EventListener {
* the document event.
*/
public void namespaceChanged(DocumentEvent e);
-
+
/**
* Called before content is deleted from a document.
*
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentReader.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentReader.java
index 007fcaa3..8d167b84 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentReader.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentReader.java
@@ -37,18 +37,20 @@ public class DocumentReader {
private boolean debugging;
private DocumentContentModel documentContentModel = new DocumentContentModel(); // use the default implementation as default
-
+
private EntityResolver entityResolver;
-
+
private final EntityResolver combinedEntityResolver = new EntityResolver() {
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
+ public InputSource resolveEntity(final String publicId, final String systemId) throws SAXException, IOException {
final InputSource result;
- if (entityResolver != null)
+ if (entityResolver != null) {
result = entityResolver.resolveEntity(publicId, systemId);
- else
+ } else {
result = null;
- if (result == null)
+ }
+ if (result == null) {
return documentContentModel.resolveEntity(publicId, systemId);
+ }
return result;
}
};
@@ -78,8 +80,7 @@ public class DocumentReader {
}
/**
- * Reads a document from a string. This is mainly used for short documents
- * in unit tests.
+ * Reads a document from a string. This is mainly used for short documents in unit tests.
*
* @param s
* String containing the document to be read.
@@ -107,17 +108,16 @@ public class DocumentReader {
LexicalHandler lexicalHandler = builder;
if (isDebugging()) {
- final Object proxy = Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] { ContentHandler.class, LexicalHandler.class },
- new InvocationHandler() {
- public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
- try {
- return method.invoke(builder, args);
- } catch (final InvocationTargetException ex) {
- ex.getCause().printStackTrace();
- throw ex.getCause();
- }
- }
- });
+ final Object proxy = Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] { ContentHandler.class, LexicalHandler.class }, new InvocationHandler() {
+ public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
+ try {
+ return method.invoke(builder, args);
+ } catch (final InvocationTargetException ex) {
+ ex.getCause().printStackTrace();
+ throw ex.getCause();
+ }
+ }
+ });
contentHandler = (ContentHandler) proxy;
lexicalHandler = (LexicalHandler) proxy;
@@ -128,8 +128,9 @@ public class DocumentReader {
xmlReader.setEntityResolver(combinedEntityResolver);
xmlReader.parse(is);
final Document result = builder.getDocument();
- if (result != null)
+ if (result != null) {
result.setDocumentURI(is.getSystemId());
+ }
return result;
}
@@ -152,12 +153,12 @@ public class DocumentReader {
public void setEntityResolver(final EntityResolver entityResolver) {
this.entityResolver = entityResolver;
}
-
+
public DocumentContentModel getDocumentContentModel() {
return documentContentModel;
}
-
- public void setDocumentContentModel(DocumentContentModel documentContentModel) {
+
+ public void setDocumentContentModel(final DocumentContentModel documentContentModel) {
this.documentContentModel = documentContentModel;
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentValidationException.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentValidationException.java
index d12183b2..89a3c46f 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentValidationException.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentValidationException.java
@@ -23,7 +23,7 @@ public class DocumentValidationException extends RuntimeException {
* @param message
* Message indicating the nature of the exception.
*/
- public DocumentValidationException(String message) {
+ public DocumentValidationException(final String message) {
super(message);
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentWriter.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentWriter.java
index b3b3166f..cde09924 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentWriter.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentWriter.java
@@ -21,8 +21,7 @@ import java.util.List;
import org.eclipse.vex.core.internal.validator.AttributeDefinition;
/**
- * Writes a document to an output stream, using a stylesheet to provide
- * formatting hints.
+ * Writes a document to an output stream, using a stylesheet to provide formatting hints.
*
* <ul>
* <li>Children of an element are indented by a configurable amount.</li>
@@ -31,8 +30,7 @@ import org.eclipse.vex.core.internal.validator.AttributeDefinition;
* </ul>
*
* <p>
- * Documents are currently saved UTF-8 encoding, with no encoding specified in
- * the XML declaration.
+ * Documents are currently saved UTF-8 encoding, with no encoding specified in the XML declaration.
* </p>
*/
public class DocumentWriter {
@@ -49,7 +47,7 @@ public class DocumentWriter {
wrapColumn = 72;
}
- /**
+/**
* Escapes special XML characters. Changes '<', '>', and '&' to
* '&lt;', '&gt;' and '&amp;', respectively.
*
@@ -61,18 +59,19 @@ public class DocumentWriter {
for (int i = 0; i < s.length(); i++) {
final char c = s.charAt(i);
- if (c == '<')
+ if (c == '<') {
sb.append("&lt;");
- else if (c == '>')
+ } else if (c == '>') {
sb.append("&gt;");
- else if (c == '&')
+ } else if (c == '&') {
sb.append("&amp;");
- else if (c == '"')
+ } else if (c == '"') {
sb.append("&quot;");
- else if (c == '\'')
+ } else if (c == '\'') {
sb.append("&apos;");
- else
+ } else {
sb.append(c);
+ }
}
return sb.toString();
}
@@ -92,8 +91,7 @@ public class DocumentWriter {
}
/**
- * Returns the column at which text should be wrapped. By default this is
- * 72.
+ * Returns the column at which text should be wrapped. By default this is 72.
*/
public int getWrapColumn() {
return wrapColumn;
@@ -110,9 +108,8 @@ public class DocumentWriter {
}
/**
- * Sets the whitespace policy for this writer. The whitespace policy tells
- * the writer which elements are block-formatted and which are
- * pre-formatted.
+ * Sets the whitespace policy for this writer. The whitespace policy tells the writer which elements are
+ * block-formatted and which are pre-formatted.
*
* @param whitespacePolicy
* The whitespacePolicy to set.
@@ -146,8 +143,9 @@ public class DocumentWriter {
sb.append(" \"");
sb.append(doc.getPublicID());
sb.append("\"");
- } else
+ } else {
sb.append(" SYSTEM");
+ }
sb.append(" \"");
sb.append(doc.getSystemID());
sb.append("\">");
@@ -179,8 +177,9 @@ public class DocumentWriter {
pw.println("<!-- ");
final String childIndent = indent + this.indent;
- for (final Node child : element.getChildNodes())
+ for (final Node child : element.getChildNodes()) {
writeNode(child, pw, childIndent);
+ }
pw.print(indent);
pw.println(" -->");
@@ -197,11 +196,12 @@ public class DocumentWriter {
boolean hasBlockChild = false;
final List<Element> children = element.getChildElements();
- for (int i = 0; i < children.size(); i++)
+ for (int i = 0; i < children.size(); i++) {
if (whitespacePolicy != null && whitespacePolicy.isBlock(children.get(i))) {
hasBlockChild = true;
break;
}
+ }
if (hasBlockChild) {
pw.print(indent);
@@ -216,17 +216,20 @@ public class DocumentWriter {
final char[] bigIndent = new char[outdent];
Arrays.fill(bigIndent, ' ');
for (int i = 0; i < lines.length; i++) {
- if (i > 0)
+ if (i > 0) {
pw.print(bigIndent);
+ }
pw.print(lines[i]);
- if (i < lines.length - 1)
+ if (i < lines.length - 1) {
pw.println();
+ }
}
pw.println(">");
final String childIndent = indent + this.indent;
- for (final Node child : element.getChildNodes())
+ for (final Node child : element.getChildNodes()) {
writeNode(child, pw, childIndent);
+ }
pw.print(indent);
pw.print("</");
pw.print(element.getPrefixedName());
@@ -246,15 +249,16 @@ public class DocumentWriter {
private void writeNodeNoWrap(final Node node, final PrintWriter pw) {
- if (node instanceof Text)
+ if (node instanceof Text) {
pw.print(escape(node.getText()));
- else if (node instanceof CommentElement) {
-
+ } else if (node instanceof CommentElement) {
+
final CommentElement element = (CommentElement) node;
-
+
pw.print("<!-- ");
- for (final Node child : element.getChildNodes())
+ for (final Node child : element.getChildNodes()) {
writeNodeNoWrap(child, pw);
+ }
pw.print(" -->");
} else {
@@ -266,8 +270,9 @@ public class DocumentWriter {
pw.print(getAttributeString(element));
pw.print(">");
- for (final Node child : element.getChildNodes())
+ for (final Node child : element.getChildNodes()) {
writeNodeNoWrap(child, pw);
+ }
pw.print("</");
pw.print(element.getPrefixedName());
@@ -278,25 +283,28 @@ public class DocumentWriter {
private static String getNamespaceDeclarationsString(final Element element) {
final StringBuilder result = new StringBuilder();
final String declaredNamespaceURI = element.getDeclaredDefaultNamespaceURI();
- if (declaredNamespaceURI != null)
+ if (declaredNamespaceURI != null) {
result.append(" xmlns=\"").append(declaredNamespaceURI).append("\"");
- for (final String prefix : element.getDeclaredNamespacePrefixes())
+ }
+ for (final String prefix : element.getDeclaredNamespacePrefixes()) {
result.append(" xmlns:").append(prefix).append("=\"").append(element.getNamespaceURI(prefix)).append("\"");
+ }
return result.toString();
}
private static void addNode(final Node node, final TextWrapper wrapper) {
- if (node instanceof Text)
+ if (node instanceof Text) {
wrapper.add(escape(node.getText()));
- else if (node instanceof CommentElement) {
+ } else if (node instanceof CommentElement) {
final CommentElement element = (CommentElement) node;
-
+
wrapper.addNoSplit("<!-- ");
-
- for (final Node child: element.getChildNodes())
+
+ for (final Node child : element.getChildNodes()) {
addNode(child, wrapper);
-
+ }
+
wrapper.add(" -->");
} else {
final Element element = (Element) node;
@@ -306,17 +314,20 @@ public class DocumentWriter {
buffer.append("<").append(element.getPrefixedName());
buffer.append(getNamespaceDeclarationsString(element));
buffer.append(getAttributeString(element));
- if (content.isEmpty())
+ if (content.isEmpty()) {
buffer.append("/>");
- else
+ } else {
buffer.append(">");
+ }
wrapper.addNoSplit(buffer.toString());
- for (final Node child: content)
+ for (final Node child : content) {
addNode(child, wrapper);
+ }
- if (!content.isEmpty())
+ if (!content.isEmpty()) {
wrapper.add("</" + element.getPrefixedName() + ">");
+ }
}
}
@@ -324,7 +335,7 @@ public class DocumentWriter {
final Validator validator = element.getDocument().getValidator();
final StringBuffer result = new StringBuffer();
- for (final Attribute attribute : element.getAttributes())
+ for (final Attribute attribute : element.getAttributes()) {
if (!attrHasDefaultValue(validator, attribute)) {
result.append(" ");
result.append(attribute.getPrefixedName());
@@ -332,6 +343,7 @@ public class DocumentWriter {
result.append(escape(attribute.getValue()));
result.append("\"");
}
+ }
return result.toString();
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Element.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Element.java
index 66479a1f..800aacb1 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Element.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Element.java
@@ -28,107 +28,114 @@ import org.eclipse.vex.core.internal.undo.CannotUndoException;
import org.eclipse.vex.core.internal.undo.IUndoableEdit;
/**
- * Represents a tag in an XML document. Methods are
- * available for managing the element's attributes and children.
+ * Represents a tag in an XML document. Methods are available for managing the element's attributes and children.
*/
public class Element extends Node implements Cloneable {
private static final QualifiedName XML_BASE_ATTRIBUTE = new QualifiedName(Namespace.XML_NAMESPACE_URI, "base");
-
+
private final QualifiedName name;
-
+
private Element parent = null;
- private List<Node> childNodes = new ArrayList<Node>();
- private Map<QualifiedName, Attribute> attributes = new HashMap<QualifiedName, Attribute>();
- private Map<String, String> namespaceDeclarations = new HashMap<String, String>();
+ private final List<Node> childNodes = new ArrayList<Node>();
+ private final Map<QualifiedName, Attribute> attributes = new HashMap<QualifiedName, Attribute>();
+ private final Map<String, String> namespaceDeclarations = new HashMap<String, String>();
public Element(final String localName) {
this(new QualifiedName(null, localName));
}
-
+
public Element(final QualifiedName qualifiedName) {
- this.name = qualifiedName;
+ name = qualifiedName;
}
- public void addChild(Element child) {
+ public void addChild(final Element child) {
childNodes.add(child);
child.setParent(this);
}
+ @Override
public Element clone() {
try {
final Element element = new Element(getQualifiedName());
//add the attributes to the element instance to be cloned
- for (Map.Entry<QualifiedName, Attribute> attr : this.attributes.entrySet())
+ for (final Map.Entry<QualifiedName, Attribute> attr : attributes.entrySet()) {
element.setAttribute(attr.getKey(), attr.getValue().getValue());
- for (Map.Entry<String, String> namespaceDeclaration : this.namespaceDeclarations.entrySet()) {
- if (namespaceDeclaration.getKey() == null)
+ }
+ for (final Map.Entry<String, String> namespaceDeclaration : namespaceDeclarations.entrySet()) {
+ if (namespaceDeclaration.getKey() == null) {
element.declareDefaultNamespace(namespaceDeclaration.getValue());
- else
+ } else {
element.declareNamespace(namespaceDeclaration.getKey(), namespaceDeclaration.getValue());
+ }
}
return element;
- } catch (DocumentValidationException ex) {
+ } catch (final DocumentValidationException ex) {
ex.printStackTrace();
return null;
}
}
- public Attribute getAttribute(String localName) {
+ public Attribute getAttribute(final String localName) {
return getAttribute(qualify(localName));
}
-
- public Attribute getAttribute(QualifiedName name) {
+
+ public Attribute getAttribute(final QualifiedName name) {
return attributes.get(name);
}
-
- public String getAttributeValue(String localName) {
+
+ public String getAttributeValue(final String localName) {
return getAttributeValue(qualify(localName));
}
- public String getAttributeValue(QualifiedName name) {
+ public String getAttributeValue(final QualifiedName name) {
final Attribute attribute = getAttribute(name);
- if (attribute == null || "".equals(attribute.getValue().trim()))
+ if (attribute == null || "".equals(attribute.getValue().trim())) {
return null;
+ }
return attribute.getValue();
}
-
- public void removeAttribute(String localName) throws DocumentValidationException {
+
+ public void removeAttribute(final String localName) throws DocumentValidationException {
removeAttribute(qualify(localName));
}
-
- public void removeAttribute(QualifiedName name) throws DocumentValidationException {
+
+ public void removeAttribute(final QualifiedName name) throws DocumentValidationException {
final Attribute attribute = this.getAttribute(name);
- if (attribute == null)
+ if (attribute == null) {
return;
+ }
final String oldValue = attribute.getValue();
final String newValue = null;
- if (oldValue != null)
- this.attributes.remove(name);
+ if (oldValue != null) {
+ attributes.remove(name);
+ }
final Document document = getDocument();
- if (document == null) // document may be null, e.g. when we're cloning an element to produce a document fragment
+ if (document == null) {
return;
+ }
final IUndoableEdit edit = document.isUndoEnabled() ? new AttributeChangeEdit(name, oldValue, newValue) : null;
document.fireAttributeChanged(new DocumentEvent(document, this, name, oldValue, newValue, edit));
}
- public void setAttribute(String name, String value) throws DocumentValidationException {
+ public void setAttribute(final String name, final String value) throws DocumentValidationException {
setAttribute(qualify(name), value);
}
-
- private QualifiedName qualify(String localName) {
+
+ private QualifiedName qualify(final String localName) {
return new QualifiedName(name.getQualifier(), localName);
}
-
- public void setAttribute(QualifiedName name, String value) throws DocumentValidationException {
+
+ public void setAttribute(final QualifiedName name, final String value) throws DocumentValidationException {
final Attribute oldAttribute = attributes.get(name);
final String oldValue = oldAttribute != null ? oldAttribute.getValue() : null;
-
- if (value == null && oldValue == null)
+
+ if (value == null && oldValue == null) {
return;
-
+ }
+
if (value == null) {
this.removeAttribute(name);
} else {
@@ -136,11 +143,12 @@ public class Element extends Node implements Cloneable {
return;
} else {
final Attribute newAttribute = new Attribute(this, name, value);
- this.attributes.put(name, newAttribute);
+ attributes.put(name, newAttribute);
final Document document = getDocument();
- if (document == null) // doc may be null, e.g. when we're cloning an element to produce a document fragment
+ if (document == null) {
return;
+ }
final IUndoableEdit edit = document.isUndoEnabled() ? new AttributeChangeEdit(name, oldValue, value) : null;
document.fireAttributeChanged(new DocumentEvent(document, this, name, oldValue, value, edit));
@@ -153,10 +161,10 @@ public class Element extends Node implements Cloneable {
Collections.sort(result);
return Collections.unmodifiableCollection(result);
}
-
+
public List<QualifiedName> getAttributeNames() {
- ArrayList<QualifiedName> result = new ArrayList<QualifiedName>();
- for (Attribute attribute : attributes.values()) {
+ final ArrayList<QualifiedName> result = new ArrayList<QualifiedName>();
+ for (final Attribute attribute : attributes.values()) {
result.add(attribute.getQualifiedName());
}
Collections.sort(result, new QualifiedNameComparator());
@@ -168,11 +176,11 @@ public class Element extends Node implements Cloneable {
}
public List<Element> getChildElements() {
- List<Node> nodes = getChildNodes();
- Iterator<Node> iter = nodes.iterator();
- List<Element> elements = new ArrayList<Element>();
+ final List<Node> nodes = getChildNodes();
+ final Iterator<Node> iter = nodes.iterator();
+ final List<Element> elements = new ArrayList<Element>();
while (iter.hasNext()) {
- Node node = iter.next();
+ final Node node = iter.next();
if (node.getNodeType().equals("Element")) {
elements.add((Element) node);
}
@@ -199,31 +207,33 @@ public class Element extends Node implements Cloneable {
public String getLocalName() {
return name.getLocalName();
}
-
+
public QualifiedName getQualifiedName() {
return name;
}
-
+
public String getPrefix() {
return getNamespacePrefix(name.getQualifier());
}
-
+
public String getPrefixedName() {
- String prefix = getPrefix();
- if (prefix == null)
+ final String prefix = getPrefix();
+ if (prefix == null) {
return getLocalName();
+ }
return prefix + ":" + getLocalName();
}
public Element getParent() {
- return this.parent;
+ return parent;
}
+ @Override
public String getText() {
final String s = super.getText();
final StringBuilder sb = new StringBuilder(s.length());
for (int i = 0; i < s.length(); i++) {
- char c = s.charAt(i);
+ final char c = s.charAt(i);
if (!getContent().isElementMarker(c)) {
sb.append(c);
}
@@ -232,25 +242,26 @@ public class Element extends Node implements Cloneable {
}
/**
- * Inserts the given element as a child at the given child index. Sets the
- * parent attribute of the given element to this element.
+ * Inserts the given element as a child at the given child index. Sets the parent attribute of the given element to
+ * this element.
*/
- public void insertChild(int index, Element child) {
+ public void insertChild(final int index, final Element child) {
childNodes.add(index, child);
child.setParent(this);
}
public boolean isEmpty() {
- return this.getStartOffset() + 1 == this.getEndOffset();
+ return getStartOffset() + 1 == getEndOffset();
}
+ @Override
public String toString() {
- StringBuffer sb = new StringBuffer();
+ final StringBuffer sb = new StringBuffer();
sb.append("<");
- sb.append(this.getPrefixedName().toString());
-
- for (Attribute attribute : getAttributes()) {
+ sb.append(getPrefixedName().toString());
+
+ for (final Attribute attribute : getAttributes()) {
sb.append(" ");
sb.append(attribute.getPrefixedName());
sb.append("=\"");
@@ -259,102 +270,117 @@ public class Element extends Node implements Cloneable {
}
sb.append("> (");
- sb.append(this.getStartPosition());
+ sb.append(getStartPosition());
sb.append(",");
- sb.append(this.getEndPosition());
+ sb.append(getEndPosition());
sb.append(")");
return sb.toString();
}
- public void setParent(Element parent) {
+ public void setParent(final Element parent) {
this.parent = parent;
}
public String getNamespaceURI(final String namespacePrefix) {
- if (namespaceDeclarations.containsKey(namespacePrefix))
+ if (namespaceDeclarations.containsKey(namespacePrefix)) {
return namespaceDeclarations.get(namespacePrefix);
- if (parent != null)
+ }
+ if (parent != null) {
return parent.getNamespaceURI(namespacePrefix);
+ }
return null;
}
-
+
public String getDefaultNamespaceURI() {
return getNamespaceURI(null);
}
-
+
public String getDeclaredDefaultNamespaceURI() {
return namespaceDeclarations.get(null);
}
public String getNamespacePrefix(final String namespaceURI) {
- if (namespaceURI == null)
+ if (namespaceURI == null) {
return null;
- if (Namespace.XML_NAMESPACE_URI.equals(namespaceURI))
+ }
+ if (Namespace.XML_NAMESPACE_URI.equals(namespaceURI)) {
return Namespace.XML_NAMESPACE_PREFIX;
- if (Namespace.XMLNS_NAMESPACE_URI.equals(namespaceURI))
+ }
+ if (Namespace.XMLNS_NAMESPACE_URI.equals(namespaceURI)) {
return Namespace.XMLNS_NAMESPACE_PREFIX;
- for (Entry<String, String> entry: namespaceDeclarations.entrySet())
- if (entry.getValue().equals(namespaceURI))
+ }
+ for (final Entry<String, String> entry : namespaceDeclarations.entrySet()) {
+ if (entry.getValue().equals(namespaceURI)) {
return entry.getKey();
+ }
+ }
if (parent != null) {
final String parentPrefix = parent.getNamespacePrefix(namespaceURI);
- if (!namespaceDeclarations.containsKey(parentPrefix))
+ if (!namespaceDeclarations.containsKey(parentPrefix)) {
return parentPrefix;
+ }
}
return null;
}
-
+
public Collection<String> getDeclaredNamespacePrefixes() {
final ArrayList<String> result = new ArrayList<String>();
for (final String prefix : namespaceDeclarations.keySet()) {
- if (prefix != null)
+ if (prefix != null) {
result.add(prefix);
+ }
}
Collections.sort(result);
return result;
}
-
+
public Collection<String> getNamespacePrefixes() {
final HashSet<String> result = new HashSet<String>();
result.addAll(getDeclaredNamespacePrefixes());
- if (parent != null)
+ if (parent != null) {
result.addAll(parent.getNamespacePrefixes());
+ }
return result;
}
-
+
public void declareNamespace(final String namespacePrefix, final String namespaceURI) {
- if (namespaceURI == null || "".equals(namespaceURI.trim()))
+ if (namespaceURI == null || "".equals(namespaceURI.trim())) {
return;
+ }
final String oldNamespaceURI = namespaceDeclarations.put(namespacePrefix, namespaceURI);
final Document document = getDocument();
- if (document == null) // doc may be null, e.g. when we're cloning an element to produce a document fragment
+ if (document == null) {
return;
+ }
- if (namespaceURI.equals(oldNamespaceURI)) // if we do not change anything, we do not fire anything
+ if (namespaceURI.equals(oldNamespaceURI)) {
return;
-
+ }
+
final IUndoableEdit edit = document.isUndoEnabled() ? new NamespaceChangeEdit(namespacePrefix, oldNamespaceURI, namespaceURI) : null;
document.fireNamespaceChanged(new DocumentEvent(document, this, getStartOffset(), 0, edit));
}
-
- public void removeNamespace(String namespacePrefix) {
+
+ public void removeNamespace(final String namespacePrefix) {
final String oldNamespaceURI = namespaceDeclarations.remove(namespacePrefix);
final Document document = getDocument();
- if (document == null) // doc may be null, e.g. when we're cloning an element to produce a document fragment
+ if (document == null) {
return;
+ }
- if (oldNamespaceURI == null)
+ if (oldNamespaceURI == null) {
return; // we have actually removed nothing, so we should not tell anybody about it
-
+ }
+
final IUndoableEdit edit = document.isUndoEnabled() ? new NamespaceChangeEdit(namespacePrefix, oldNamespaceURI, null) : null;
document.fireNamespaceChanged(new DocumentEvent(document, this, getStartOffset(), 0, edit));
}
-
+
public void declareDefaultNamespace(final String namespaceURI) {
declareNamespace(null, namespaceURI);
}
-
+
public void removeDefaultNamespace() {
removeNamespace(null);
}
@@ -364,22 +390,26 @@ public class Element extends Node implements Cloneable {
return "Element";
}
- public void setContent(Content content, int startOffset, int endOffset) {
+ @Override
+ public void setContent(final Content content, final int startOffset, final int endOffset) {
super.setContent(content, startOffset, endOffset);
}
@Override
public String getBaseURI() {
final Attribute baseAttribute = getAttribute(XML_BASE_ATTRIBUTE);
- if (baseAttribute != null)
+ if (baseAttribute != null) {
return baseAttribute.getValue();
- if (getParent() != null)
+ }
+ if (getParent() != null) {
return getParent().getBaseURI();
- if (getDocument() != null)
+ }
+ if (getDocument() != null) {
return getDocument().getBaseURI();
+ }
return null;
}
-
+
private class AttributeChangeEdit implements IUndoableEdit {
private final QualifiedName name;
@@ -392,16 +422,16 @@ public class Element extends Node implements Cloneable {
this.newValue = newValue;
}
- public boolean combine(IUndoableEdit edit) {
+ public boolean combine(final IUndoableEdit edit) {
return false;
}
public void undo() throws CannotUndoException {
- final Document doc = (Document) getDocument();
+ final Document doc = getDocument();
try {
doc.setUndoEnabled(false);
setAttribute(name, oldValue);
- } catch (DocumentValidationException ex) {
+ } catch (final DocumentValidationException ex) {
throw new CannotUndoException();
} finally {
doc.setUndoEnabled(true);
@@ -409,58 +439,60 @@ public class Element extends Node implements Cloneable {
}
public void redo() throws CannotRedoException {
- final Document doc = (Document) getDocument();
+ final Document doc = getDocument();
try {
doc.setUndoEnabled(false);
setAttribute(name, newValue);
- } catch (DocumentValidationException ex) {
+ } catch (final DocumentValidationException ex) {
throw new CannotUndoException();
} finally {
doc.setUndoEnabled(true);
}
}
}
-
+
private class NamespaceChangeEdit implements IUndoableEdit {
-
+
private final String prefix;
private final String oldUri;
private final String newUri;
-
+
public NamespaceChangeEdit(final String prefix, final String oldUri, final String newUri) {
this.prefix = prefix;
this.oldUri = oldUri;
this.newUri = newUri;
}
-
- public boolean combine(IUndoableEdit edit) {
+
+ public boolean combine(final IUndoableEdit edit) {
return false;
}
public void undo() throws CannotUndoException {
- final Document doc = (Document) getDocument();
+ final Document doc = getDocument();
try {
doc.setUndoEnabled(false);
- if (oldUri == null)
+ if (oldUri == null) {
removeNamespace(prefix);
- else
+ } else {
declareNamespace(prefix, oldUri);
- } catch (DocumentValidationException ex) {
+ }
+ } catch (final DocumentValidationException ex) {
throw new CannotUndoException();
} finally {
doc.setUndoEnabled(true);
}
}
-
+
public void redo() throws CannotRedoException {
- final Document doc = (Document) getDocument();
+ final Document doc = getDocument();
try {
doc.setUndoEnabled(false);
- if (newUri == null)
+ if (newUri == null) {
removeNamespace(prefix);
- else
+ } else {
declareNamespace(prefix, newUri);
- } catch (DocumentValidationException ex) {
+ }
+ } catch (final DocumentValidationException ex) {
throw new CannotUndoException();
} finally {
doc.setUndoEnabled(true);
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/GapContent.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/GapContent.java
index f214de25..de213143 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/GapContent.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/GapContent.java
@@ -15,17 +15,15 @@ import java.util.HashMap;
import java.util.Map;
/**
- * Implementation of the <code>Content</code> interface that manages changes
- * efficiently. Implements a buffer that keeps its free space (the "gap") at the
- * location of the last change. Insertions at the start of the gap require no
- * other chars to be moved so long as the insertion is smaller than the gap.
- * Deletions that end of the gap are also very efficent. Furthermore, changes
- * near the gap require relatively few characters to be moved.
+ * Implementation of the <code>Content</code> interface that manages changes efficiently. Implements a buffer that keeps
+ * its free space (the "gap") at the location of the last change. Insertions at the start of the gap require no other
+ * chars to be moved so long as the insertion is smaller than the gap. Deletions that end of the gap are also very
+ * efficent. Furthermore, changes near the gap require relatively few characters to be moved.
*/
public class GapContent implements Content {
private static final char ELEMENT_MARKER = '\0';
-
+
private char[] content;
private int gapStart;
private int gapEnd;
@@ -37,12 +35,12 @@ public class GapContent implements Content {
* @param initialCapacity
* initial capacity of the content.
*/
- public GapContent(int initialCapacity) {
+ public GapContent(final int initialCapacity) {
assertPositive(initialCapacity);
- this.content = new char[initialCapacity];
- this.gapStart = 0;
- this.gapEnd = initialCapacity;
+ content = new char[initialCapacity];
+ gapStart = 0;
+ gapEnd = initialCapacity;
}
/**
@@ -51,12 +49,12 @@ public class GapContent implements Content {
* @param offset
* initial offset of the position
*/
- public Position createPosition(int offset) {
+ public Position createPosition(final int offset) {
- assertOffset(offset, 0, this.getLength());
+ assertOffset(offset, 0, getLength());
- Position pos = new GapContentPosition(offset);
- this.positions.put(pos, pos);
+ final Position pos = new GapContentPosition(offset);
+ positions.put(pos, pos);
return pos;
}
@@ -69,12 +67,12 @@ public class GapContent implements Content {
* @param s
* String to insert.
*/
- public void insertString(int offset, String s) {
+ public void insertString(final int offset, final String s) {
- assertOffset(offset, 0, this.getLength());
+ assertOffset(offset, 0, getLength());
- if (s.length() > (this.gapEnd - this.gapStart)) {
- this.expandContent(this.getLength() + s.length());
+ if (s.length() > gapEnd - gapStart) {
+ expandContent(getLength() + s.length());
}
//
@@ -84,16 +82,16 @@ public class GapContent implements Content {
//
// This significantly improves document load speed.
//
- boolean atEnd = (offset == this.getLength() && offset == gapStart);
+ final boolean atEnd = offset == getLength() && offset == gapStart;
- this.moveGap(offset);
- s.getChars(0, s.length(), this.content, offset);
- this.gapStart += s.length();
+ moveGap(offset);
+ s.getChars(0, s.length(), content, offset);
+ gapStart += s.length();
if (!atEnd) {
// Update positions
- for (Position pos : this.positions.keySet()) {
+ for (final Position pos : positions.keySet()) {
if (pos.getOffset() >= offset) {
pos.setOffset(pos.getOffset() + s.length());
}
@@ -101,12 +99,12 @@ public class GapContent implements Content {
}
}
-
- public void insertElementMarker(int offset) {
+
+ public void insertElementMarker(final int offset) {
insertString(offset, Character.toString(ELEMENT_MARKER));
}
-
- public boolean isElementMarker(char c) {
+
+ public boolean isElementMarker(final char c) {
return c == ELEMENT_MARKER;
}
@@ -118,15 +116,15 @@ public class GapContent implements Content {
* @param length
* Number of characters to delete.
*/
- public void remove(int offset, int length) {
+ public void remove(final int offset, final int length) {
- assertOffset(offset, 0, this.getLength() - length);
+ assertOffset(offset, 0, getLength() - length);
assertPositive(length);
- this.moveGap(offset + length);
- this.gapStart -= length;
+ moveGap(offset + length);
+ gapStart -= length;
- for (Position pos : this.positions.keySet()) {
+ for (final Position pos : positions.keySet()) {
if (pos.getOffset() >= offset + length) {
pos.setOffset(pos.getOffset() - length);
} else if (pos.getOffset() >= offset) {
@@ -143,21 +141,19 @@ public class GapContent implements Content {
* @param length
* Number of characters to return.
*/
- public String getString(int offset, int length) {
+ public String getString(final int offset, final int length) {
- assertOffset(offset, 0, this.getLength() - length);
+ assertOffset(offset, 0, getLength() - length);
assertPositive(length);
- if (offset + length <= this.gapStart) {
- return new String(this.content, offset, length);
- } else if (offset >= this.gapStart) {
- return new String(this.content, offset - this.gapStart
- + this.gapEnd, length);
+ if (offset + length <= gapStart) {
+ return new String(content, offset, length);
+ } else if (offset >= gapStart) {
+ return new String(content, offset - gapStart + gapEnd, length);
} else {
- StringBuffer sb = new StringBuffer(length);
- sb.append(this.content, offset, this.gapStart - offset);
- sb.append(this.content, this.gapEnd, offset + length
- - this.gapStart);
+ final StringBuffer sb = new StringBuffer(length);
+ sb.append(content, offset, gapStart - offset);
+ sb.append(content, gapEnd, offset + length - gapStart);
return sb.toString();
}
}
@@ -166,7 +162,7 @@ public class GapContent implements Content {
* Return the length of the content.
*/
public int getLength() {
- return this.content.length - (this.gapEnd - this.gapStart);
+ return content.length - (gapEnd - gapStart);
}
// ====================================================== PRIVATE
@@ -181,8 +177,8 @@ public class GapContent implements Content {
private static class GapContentPosition implements Position {
private int offset;
-
- public GapContentPosition(int offset) {
+
+ public GapContentPosition(final int offset) {
this.offset = offset;
}
@@ -190,83 +186,77 @@ public class GapContent implements Content {
return offset;
}
- public void setOffset(int offset) {
+ public void setOffset(final int offset) {
this.offset = offset;
}
+ @Override
public String toString() {
return Integer.toString(offset);
}
}
/**
- * Assert that the given offset is within the given range, throwing
- * IllegalArgumentException if not.
+ * Assert that the given offset is within the given range, throwing IllegalArgumentException if not.
*/
- private static void assertOffset(int offset, int min, int max) {
+ private static void assertOffset(final int offset, final int min, final int max) {
if (offset < min || offset > max) {
- throw new IllegalArgumentException("Bad offset " + offset
- + "must be between " + min + " and " + max);
+ throw new IllegalArgumentException("Bad offset " + offset + "must be between " + min + " and " + max);
}
}
/**
- * Assert that the given value is zero or positive. throwing
- * IllegalArgumentException if not.
+ * Assert that the given value is zero or positive. throwing IllegalArgumentException if not.
*/
- private static void assertPositive(int value) {
+ private static void assertPositive(final int value) {
if (value < 0) {
- throw new IllegalArgumentException(
- "Value should be zero or positive, but it was " + value);
+ throw new IllegalArgumentException("Value should be zero or positive, but it was " + value);
}
}
/**
* Expand the content array to fit at least the given length.
*/
- private void expandContent(int newLength) {
+ private void expandContent(final int newLength) {
// grow quickly when small, slower when large
int newCapacity;
if (newLength < GROWTH_SLOWDOWN_SIZE) {
- newCapacity = Math.max((int) (newLength * GROWTH_RATE_FAST), 32);
+ newCapacity = Math.max(newLength * GROWTH_RATE_FAST, 32);
} else {
newCapacity = (int) (newLength * GROWTH_RATE_SLOW);
}
- char[] newContent = new char[newCapacity];
+ final char[] newContent = new char[newCapacity];
- System.arraycopy(this.content, 0, newContent, 0, this.gapStart);
+ System.arraycopy(content, 0, newContent, 0, gapStart);
- int tailLength = this.content.length - this.gapEnd;
- System.arraycopy(this.content, this.gapEnd, newContent, newCapacity
- - tailLength, tailLength);
+ final int tailLength = content.length - gapEnd;
+ System.arraycopy(content, gapEnd, newContent, newCapacity - tailLength, tailLength);
- this.content = newContent;
- this.gapEnd = newCapacity - tailLength;
+ content = newContent;
+ gapEnd = newCapacity - tailLength;
}
/**
* Move the gap to the given offset.
*/
- private void moveGap(int offset) {
+ private void moveGap(final int offset) {
- assertOffset(offset, 0, this.getLength());
+ assertOffset(offset, 0, getLength());
- if (offset <= this.gapStart) {
- int length = this.gapStart - offset;
- System.arraycopy(this.content, offset, this.content, this.gapEnd
- - length, length);
- this.gapStart -= length;
- this.gapEnd -= length;
+ if (offset <= gapStart) {
+ final int length = gapStart - offset;
+ System.arraycopy(content, offset, content, gapEnd - length, length);
+ gapStart -= length;
+ gapEnd -= length;
} else {
- int length = offset - this.gapStart;
- System.arraycopy(this.content, this.gapEnd, this.content,
- this.gapStart, length);
- this.gapStart += length;
- this.gapEnd += length;
+ final int length = offset - gapStart;
+ System.arraycopy(content, gapEnd, content, gapStart, length);
+ gapStart += length;
+ gapEnd += length;
}
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/IWhitespacePolicy.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/IWhitespacePolicy.java
index 3b56f94b..cfe8ce11 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/IWhitespacePolicy.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/IWhitespacePolicy.java
@@ -11,9 +11,8 @@
package org.eclipse.vex.core.internal.dom;
/**
- * Determines whitespace policy for document elements. For example, a CSS
- * stylesheet implements a whitespace policy via its display and white-space
- * properties.
+ * Determines whitespace policy for document elements. For example, a CSS stylesheet implements a whitespace policy via
+ * its display and white-space properties.
*/
public interface IWhitespacePolicy {
@@ -21,11 +20,11 @@ public interface IWhitespacePolicy {
* A NULL object of this type. No blocks and no pre elements.
*/
IWhitespacePolicy NULL = new IWhitespacePolicy() {
- public boolean isBlock(Element element) {
+ public boolean isBlock(final Element element) {
return false;
}
- public boolean isPre(Element element) {
+ public boolean isPre(final Element element) {
return false;
}
};
@@ -39,8 +38,7 @@ public interface IWhitespacePolicy {
boolean isBlock(Element element);
/**
- * Returns true if the given element is pre-formatted, that is, all of its
- * contained whitespace should be preserved.
+ * Returns true if the given element is pre-formatted, that is, all of its contained whitespace should be preserved.
*
* @param element
* Element to test.
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/IWhitespacePolicyFactory.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/IWhitespacePolicyFactory.java
index 035b3005..d20fd183 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/IWhitespacePolicyFactory.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/IWhitespacePolicyFactory.java
@@ -10,19 +10,17 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.dom;
-
/**
- * Factory for returning a WhitespacePolicy object given a document type public
- * ID. This is required by DocumentBuilder, since we don't know what
- * WhitespacePolicy we need before we begin parsing the document.
+ * Factory for returning a WhitespacePolicy object given a document type public ID. This is required by DocumentBuilder,
+ * since we don't know what WhitespacePolicy we need before we begin parsing the document.
*/
public interface IWhitespacePolicyFactory {
-
+
/**
* A factory that always returns the NULL whitespace policy.
*/
IWhitespacePolicyFactory NULL = new IWhitespacePolicyFactory() {
- public IWhitespacePolicy getPolicy(String publicId) {
+ public IWhitespacePolicy getPolicy(final String publicId) {
return IWhitespacePolicy.NULL;
}
};
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Namespace.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Namespace.java
index 04dc51ff..2333a3fc 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Namespace.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Namespace.java
@@ -14,13 +14,13 @@ package org.eclipse.vex.core.internal.dom;
* @author Florian Thienel
*/
public class Namespace {
-
+
public static final String XML_NAMESPACE_URI = "http://www.w3.org/XML/1998/namespace";
-
+
public static final String XML_NAMESPACE_PREFIX = "xml";
-
+
public static final String XMLNS_NAMESPACE_URI = "http://www.w3.org/2000/xmlns/";
-
+
public static final String XMLNS_NAMESPACE_PREFIX = "xmlns";
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/NamespaceStack.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/NamespaceStack.java
index e02c0083..b652645e 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/NamespaceStack.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/NamespaceStack.java
@@ -34,8 +34,9 @@ public class NamespaceStack {
private List<String> getStack(final String prefix) {
final List<String> result = stacks.get(prefix);
- if (result != null)
+ if (result != null) {
return result;
+ }
return putNewStack(prefix);
}
@@ -46,14 +47,16 @@ public class NamespaceStack {
}
private String peek(final List<String> stack) {
- if (stack.isEmpty())
+ if (stack.isEmpty()) {
return null;
+ }
return stack.get(stack.size() - 1);
}
private void removeTop(final List<String> stack) {
- if (stack.isEmpty())
+ if (stack.isEmpty()) {
return;
+ }
stack.remove(stack.size() - 1);
}
@@ -79,12 +82,14 @@ public class NamespaceStack {
public void clear() {
stacks.clear();
}
-
+
public Collection<String> getPrefixes() {
final ArrayList<String> result = new ArrayList<String>();
- for (String key : stacks.keySet())
- if (key != DEFAULT_PREFIX)
+ for (final String key : stacks.keySet()) {
+ if (key != DEFAULT_PREFIX) {
result.add(key);
+ }
+ }
return result;
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Node.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Node.java
index a46e9343..f72cda7d 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Node.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Node.java
@@ -12,14 +12,14 @@ package org.eclipse.vex.core.internal.dom;
/**
* <code>Node</code> represents a component of an XML document. .
- *
+ *
*/
public abstract class Node {
private Content content;
private Position startPosition;
private Position endPosition;
-
+
public Content getContent() {
return content;
}
@@ -54,13 +54,13 @@ public abstract class Node {
* @param endOffset
* offset at which the node's content ends
*/
- public void setContent(Content content, int startOffset, int endOffset) {
+ public void setContent(final Content content, final int startOffset, final int endOffset) {
this.content = content;
startPosition = content.createPosition(startOffset);
endPosition = content.createPosition(endOffset);
}
public abstract String getNodeType();
-
+
public abstract String getBaseURI();
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Position.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Position.java
index c493be5d..fa8b3158 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Position.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Position.java
@@ -11,9 +11,8 @@
package org.eclipse.vex.core.internal.dom;
/**
- * Represents a logical location in a document. As the document is modified,
- * existing <code>Position</code> objects are updated to reflect the appropriate
- * character offset in the document.
+ * Represents a logical location in a document. As the document is modified, existing <code>Position</code> objects are
+ * updated to reflect the appropriate character offset in the document.
*/
public interface Position {
@@ -21,9 +20,10 @@ public interface Position {
* @return the character offset corresponding to the position.
*/
int getOffset();
-
+
/**
- * @param offset the character offset corresponding to the position
+ * @param offset
+ * the character offset corresponding to the position
*/
void setOffset(int offset);
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/RootElement.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/RootElement.java
index ad3cae4e..1f74080c 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/RootElement.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/RootElement.java
@@ -13,11 +13,9 @@ package org.eclipse.vex.core.internal.dom;
import org.eclipse.core.runtime.QualifiedName;
/**
- * The root element of a document. Keeps track of the document to which it is
- * associated. Any element can find the document to which it is associated by
- * following its parents to this root. This would be done, for example, to
- * notify document listeners that the document has changed when the element
- * changes.
+ * The root element of a document. Keeps track of the document to which it is associated. Any element can find the
+ * document to which it is associated by following its parents to this root. This would be done, for example, to notify
+ * document listeners that the document has changed when the element changes.
*/
public class RootElement extends Element {
@@ -26,16 +24,17 @@ public class RootElement extends Element {
public RootElement(final String localName) {
super(localName);
}
-
+
public RootElement(final QualifiedName qualifiedName) {
super(qualifiedName);
}
-
+
+ @Override
public Document getDocument() {
return document;
}
- public void setDocument(Document document) {
+ public void setDocument(final Document document) {
this.document = document;
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Text.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Text.java
index 3611d068..2ddae8c1 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Text.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Text.java
@@ -11,9 +11,8 @@
package org.eclipse.vex.core.internal.dom;
/**
- * <code>Text</code> represents a run of text in a document. Text objects are
- * not used in the internal document structure; they are only returned as needed
- * by the <code>Element.getContent</code> method.
+ * <code>Text</code> represents a run of text in a document. Text objects are not used in the internal document
+ * structure; they are only returned as needed by the <code>Element.getContent</code> method.
*/
public class Text extends Node {
@@ -27,15 +26,15 @@ public class Text extends Node {
* @param endOffset
* character offset of the end of the run
*/
- public Text(Content content, int startOffset, int endOffset) {
+ public Text(final Content content, final int startOffset, final int endOffset) {
setContent(content, startOffset, endOffset);
}
-
+
@Override
public String getNodeType() {
return "Text";
- }
-
+ }
+
@Override
public String getBaseURI() {
return null;
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/TextWrapper.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/TextWrapper.java
index 499d2325..956cc336 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/TextWrapper.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/TextWrapper.java
@@ -20,7 +20,7 @@ import java.util.List;
*/
public class TextWrapper {
- private List<String> parts = new ArrayList<String>();
+ private final List<String> parts = new ArrayList<String>();
private boolean lastIsWhite = true;
@@ -36,7 +36,7 @@ public class TextWrapper {
* @param s
* Text to be added.
*/
- public void add(String s) {
+ public void add(final String s) {
int i = 0;
int j = 0;
boolean thisIsWhite = true;
@@ -55,48 +55,45 @@ public class TextWrapper {
}
if (lastIsWhite || parts.isEmpty()) {
- this.parts.add(s.substring(i, j));
+ parts.add(s.substring(i, j));
+ } else if (!parts.isEmpty()) {
+
+ parts.add(parts.remove(parts.size() - 1) + s.substring(i, j));
}
- else if (!parts.isEmpty()) {
-
- this.parts.add(((String) this.parts
- .remove(this.parts.size() - 1))
- + s.substring(i, j));
- }
i = j;
lastIsWhite = thisIsWhite;
}
}
/**
- * Adds text to the list of things to be wrapped. The given text will be
- * treated as a single unit and will not be split across lines.
+ * Adds text to the list of things to be wrapped. The given text will be treated as a single unit and will not be
+ * split across lines.
*
* @param s
* Text to be added.
*/
- public void addNoSplit(String s) {
- this.parts.add(s);
+ public void addNoSplit(final String s) {
+ parts.add(s);
}
/**
* Clears any added text.
*/
public void clear() {
- this.parts.clear();
+ parts.clear();
}
/**
- * Wraps the text into the given width. The text is only broken at spaces,
- * meaning the returned lines will not necessarily fit within width.
+ * Wraps the text into the given width. The text is only broken at spaces, meaning the returned lines will not
+ * necessarily fit within width.
*
* @param width
*/
- public String[] wrap(int width) {
- List<String> lines = new ArrayList<String>();
- StringBuffer line = new StringBuffer();
+ public String[] wrap(final int width) {
+ final List<String> lines = new ArrayList<String>();
+ final StringBuffer line = new StringBuffer();
- for (String s : this.parts) {
+ for (final String s : parts) {
if (line.length() > 0 && line.length() + s.length() > width) {
// part won't fit on the current line
lines.add(line.toString());
@@ -116,7 +113,7 @@ public class TextWrapper {
lines.add(line.toString());
}
- return (String[]) lines.toArray(new String[lines.size()]);
+ return lines.toArray(new String[lines.size()]);
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Validator.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Validator.java
index 8ddf0c2f..2054ba7d 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Validator.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Validator.java
@@ -18,15 +18,15 @@ import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.vex.core.internal.validator.AttributeDefinition;
/**
- * Represents an object that can validate the structure of a document.
- * Validators must be serializable.
+ * Represents an object that can validate the structure of a document. Validators must be serializable.
+ *
* @model
*/
public interface Validator {
/**
- * QualifiedName indicating that character data is allowed at the given point in
- * the document.
+ * QualifiedName indicating that character data is allowed at the given point in the document.
+ *
* @model
*/
public static final QualifiedName PCDATA = new QualifiedName(null, "#PCDATA");
@@ -52,27 +52,25 @@ public interface Validator {
public List<AttributeDefinition> getAttributeDefinitions(Element element);
/**
- * Returns a set of QualifiedNames representing valid root elements for the given
- * document type.
- * @model
+ * Returns a set of QualifiedNames representing valid root elements for the given document type.
+ *
+ * @model
*/
public Set<QualifiedName> getValidRootElements();
/**
- * Returns a set of QualifiedNames representing items that are valid at point in
- * the child nodes of a given element. Each string is either an element name
- * or Validator.PCDATA.
+ * Returns a set of QualifiedNames representing items that are valid at point in the child nodes of a given element.
+ * Each string is either an element name or Validator.PCDATA.
*
* @param element
* the parent element.
- * @model
+ * @model
*/
public Set<QualifiedName> getValidItems(final Element element);
/**
- * Returns true if the given sequence is valid for the given element.
- * Accepts three sequences, which will be concatenated before doing the
- * check.
+ * Returns true if the given sequence is valid for the given element. Accepts three sequences, which will be
+ * concatenated before doing the check.
*
* @param element
* Name of the element being tested.
@@ -82,30 +80,25 @@ public interface Validator {
* If true, an valid but incomplete sequence is acceptable.
* @model
*/
- public boolean isValidSequence(QualifiedName element, List<QualifiedName> nodes,
- boolean partial);
+ public boolean isValidSequence(QualifiedName element, List<QualifiedName> nodes, boolean partial);
/**
- * Returns true if the given sequence is valid for the given element.
- * Accepts three sequences, which will be concatenated before doing the
- * check.
+ * Returns true if the given sequence is valid for the given element. Accepts three sequences, which will be
+ * concatenated before doing the check.
*
* @param element
* Name of the element being tested.
* @param seq1
* List of element names and Validator.PCDATA.
* @param seq2
- * List of element names and Validator.PCDATA. May be null or
- * empty.
+ * List of element names and Validator.PCDATA. May be null or empty.
* @param seq3
- * List of element names and Validator.PCDATA. May be null or
- * empty.
+ * List of element names and Validator.PCDATA. May be null or empty.
* @param partial
* If true, an valid but incomplete sequence is acceptable.
* @model
*/
- public boolean isValidSequence(QualifiedName element, List<QualifiedName> seq1,
- List<QualifiedName> seq2, List<QualifiedName> seq3, boolean partial);
+ public boolean isValidSequence(QualifiedName element, List<QualifiedName> seq1, List<QualifiedName> seq2, List<QualifiedName> seq3, boolean partial);
public Set<String> getRequiredNamespaces();
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AbstractBlockBox.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AbstractBlockBox.java
index f2236793..374621fa 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AbstractBlockBox.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AbstractBlockBox.java
@@ -31,17 +31,15 @@ import org.eclipse.vex.core.internal.dom.Element;
import org.eclipse.vex.core.internal.dom.Position;
/**
- * Base class of block boxes that can contain other block boxes. This class
- * implements the layout method and various navigation methods. Subclasses must
- * implement the createChildren method.
+ * Base class of block boxes that can contain other block boxes. This class implements the layout method and various
+ * navigation methods. Subclasses must implement the createChildren method.
*
- * Subclasses can be anonymous or non-anonymous (i.e. generated by an element).
- * Since the vast majority of instances will be non-anonymous, this class can
- * manage the element and top and bottom margins without too much inefficiency.
+ * Subclasses can be anonymous or non-anonymous (i.e. generated by an element). Since the vast majority of instances
+ * will be non-anonymous, this class can manage the element and top and bottom margins without too much inefficiency.
*
* <p>
- * Subclasses that can be anonymous must override the getStartPosition and
- * getEndPosition classes to return the range covered by the box.
+ * Subclasses that can be anonymous must override the getStartPosition and getEndPosition classes to return the range
+ * covered by the box.
* </p>
*/
public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
@@ -56,16 +54,15 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
* @param element
* Element associated with this box. anonymous box.
*/
- public AbstractBlockBox(LayoutContext context, BlockBox parent,
- Element element) {
+ public AbstractBlockBox(final LayoutContext context, final BlockBox parent, final Element element) {
this.parent = parent;
this.element = element;
- Styles styles = context.getStyleSheet().getStyles(element);
- int parentWidth = parent.getWidth();
- this.marginTop = styles.getMarginTop().get(parentWidth);
- this.marginBottom = styles.getMarginBottom().get(parentWidth);
+ final Styles styles = context.getStyleSheet().getStyles(element);
+ final int parentWidth = parent.getWidth();
+ marginTop = styles.getMarginTop().get(parentWidth);
+ marginBottom = styles.getMarginBottom().get(parentWidth);
}
@@ -81,15 +78,14 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
* @param endOffset
* End of the range covered by the box.
*/
- public AbstractBlockBox(LayoutContext context, BlockBox parent,
- int startOffset, int endOffset) {
+ public AbstractBlockBox(final LayoutContext context, final BlockBox parent, final int startOffset, final int endOffset) {
this.parent = parent;
- this.marginTop = 0;
- this.marginBottom = 0;
+ marginTop = 0;
+ marginBottom = 0;
- Document doc = context.getDocument();
- this.startPosition = doc.createPosition(startOffset);
- this.endPosition = doc.createPosition(endOffset);
+ final Document doc = context.getDocument();
+ startPosition = doc.createPosition(startOffset);
+ endPosition = doc.createPosition(endOffset);
}
/**
@@ -109,66 +105,66 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
* Returns this box's children as an array of BlockBoxes.
*/
protected BlockBox[] getBlockChildren() {
- return (BlockBox[]) this.getChildren();
+ return (BlockBox[]) getChildren();
}
- public Caret getCaret(LayoutContext context, int offset) {
+ @Override
+ public Caret getCaret(final LayoutContext context, final int offset) {
// If we haven't yet laid out this block, estimate the caret.
- if (this.getLayoutState() != LAYOUT_OK) {
- int relative = offset - this.getStartOffset();
- int size = this.getEndOffset() - this.getStartOffset();
+ if (getLayoutState() != LAYOUT_OK) {
+ final int relative = offset - getStartOffset();
+ final int size = getEndOffset() - getStartOffset();
int y = 0;
if (size > 0) {
- y = this.getHeight() * relative / size;
+ y = getHeight() * relative / size;
}
- return new HCaret(0, y, this.getHCaretWidth());
+ return new HCaret(0, y, getHCaretWidth());
}
int y;
- Box[] children = this.getContentChildren();
+ final Box[] children = getContentChildren();
for (int i = 0; i < children.length; i++) {
if (offset < children[i].getStartOffset()) {
if (i > 0) {
- y = (children[i - 1].getY() + children[i - 1].getHeight() + children[i]
- .getY()) / 2;
+ y = (children[i - 1].getY() + children[i - 1].getHeight() + children[i].getY()) / 2;
} else {
y = 0;
}
- return new HCaret(0, y, this.getHCaretWidth());
+ return new HCaret(0, y, getHCaretWidth());
}
- if (offset >= children[i].getStartOffset()
- && offset <= children[i].getEndOffset()) {
+ if (offset >= children[i].getStartOffset() && offset <= children[i].getEndOffset()) {
- Caret caret = children[i].getCaret(context, offset);
+ final Caret caret = children[i].getCaret(context, offset);
caret.translate(children[i].getX(), children[i].getY());
return caret;
}
}
- if (this.hasChildren()) {
- y = this.getHeight();
+ if (hasChildren()) {
+ y = getHeight();
} else {
- y = this.getHeight() / 2;
+ y = getHeight() / 2;
}
- return new HCaret(0, y, this.getHCaretWidth());
+ return new HCaret(0, y, getHCaretWidth());
}
+ @Override
public Box[] getChildren() {
- return this.children;
+ return children;
}
/**
* Return an array of children that contain content.
*/
protected BlockBox[] getContentChildren() {
- Box[] children = this.getChildren();
- List<BlockBox> result = new ArrayList<BlockBox>(children.length);
- for (Box child : children) {
+ final Box[] children = getChildren();
+ final List<BlockBox> result = new ArrayList<BlockBox>(children.length);
+ for (final Box child : children) {
if (child.hasContent()) {
result.add((BlockBox) child);
}
@@ -176,47 +172,47 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
return result.toArray(new BlockBox[result.size()]);
}
+ @Override
public Element getElement() {
return element;
}
+ @Override
public int getEndOffset() {
- Element element = this.getElement();
+ final Element element = getElement();
if (element != null) {
return element.getEndOffset();
- } else if (this.getEndPosition() != null) {
- return this.getEndPosition().getOffset();
+ } else if (getEndPosition() != null) {
+ return getEndPosition().getOffset();
} else {
throw new IllegalStateException();
}
}
/**
- * Returns the estimated size of the box, based on the the current font size
- * and the number of characters covered by the box. This is a utility method
- * that can be used in implementation of setInitialSize. It assumes the
- * width of the box has already been correctly set.
+ * Returns the estimated size of the box, based on the the current font size and the number of characters covered by
+ * the box. This is a utility method that can be used in implementation of setInitialSize. It assumes the width of
+ * the box has already been correctly set.
*
* @param context
* LayoutContext to use.
*/
- protected int getEstimatedHeight(LayoutContext context) {
+ protected int getEstimatedHeight(final LayoutContext context) {
- Element element = this.findContainingElement();
- Styles styles = context.getStyleSheet().getStyles(element);
- int charCount = this.getEndOffset() - this.getStartOffset();
+ final Element element = findContainingElement();
+ final Styles styles = context.getStyleSheet().getStyles(element);
+ final int charCount = getEndOffset() - getStartOffset();
- float fontSize = styles.getFontSize();
- float lineHeight = styles.getLineHeight();
- float estHeight = lineHeight * fontSize * 0.6f * charCount
- / this.getWidth();
+ final float fontSize = styles.getFontSize();
+ final float lineHeight = styles.getLineHeight();
+ final float estHeight = lineHeight * fontSize * 0.6f * charCount / getWidth();
return Math.round(Math.max(estHeight, lineHeight));
}
public LineBox getFirstLine() {
- if (this.hasChildren()) {
- BlockBox firstChild = (BlockBox) this.getChildren()[0];
+ if (hasChildren()) {
+ final BlockBox firstChild = (BlockBox) getChildren()[0];
return firstChild.getFirstLine();
} else {
return null;
@@ -224,43 +220,36 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
}
/**
- * Returns the width of the horizontal caret. This is overridden by TableBox
- * to return a caret that is the full width of the table.
+ * Returns the width of the horizontal caret. This is overridden by TableBox to return a caret that is the full
+ * width of the table.
*/
protected int getHCaretWidth() {
return H_CARET_LENGTH;
}
- public Insets getInsets(LayoutContext context, int containerWidth) {
+ @Override
+ public Insets getInsets(final LayoutContext context, final int containerWidth) {
- if (this.getElement() != null) {
- Styles styles = context.getStyleSheet()
- .getStyles(this.getElement());
+ if (getElement() != null) {
+ final Styles styles = context.getStyleSheet().getStyles(getElement());
- int top = this.marginTop + styles.getBorderTopWidth()
- + styles.getPaddingTop().get(containerWidth);
+ final int top = marginTop + styles.getBorderTopWidth() + styles.getPaddingTop().get(containerWidth);
- int left = styles.getMarginLeft().get(containerWidth)
- + styles.getBorderLeftWidth()
- + styles.getPaddingLeft().get(containerWidth);
+ final int left = styles.getMarginLeft().get(containerWidth) + styles.getBorderLeftWidth() + styles.getPaddingLeft().get(containerWidth);
- int bottom = this.marginBottom + styles.getBorderBottomWidth()
- + styles.getPaddingBottom().get(containerWidth);
+ final int bottom = marginBottom + styles.getBorderBottomWidth() + styles.getPaddingBottom().get(containerWidth);
- int right = styles.getMarginRight().get(containerWidth)
- + styles.getBorderRightWidth()
- + styles.getPaddingRight().get(containerWidth);
+ final int right = styles.getMarginRight().get(containerWidth) + styles.getBorderRightWidth() + styles.getPaddingRight().get(containerWidth);
return new Insets(top, left, bottom, right);
} else {
- return new Insets(this.marginTop, 0, this.marginBottom, 0);
+ return new Insets(marginTop, 0, marginBottom, 0);
}
}
public LineBox getLastLine() {
- if (this.hasChildren()) {
- BlockBox lastChild = (BlockBox) this.getChildren()[this
- .getChildren().length - 1];
+ if (hasChildren()) {
+ final BlockBox lastChild = (BlockBox) getChildren()[getChildren().length - 1];
return lastChild.getLastLine();
} else {
return null;
@@ -271,63 +260,60 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
* Returns the layout state of this box.
*/
protected byte getLayoutState() {
- return this.layoutState;
+ return layoutState;
}
- public int getLineEndOffset(int offset) {
- BlockBox[] children = this.getContentChildren();
- for (int i = 0; i < children.length; i++) {
- if (children[i].containsOffset(offset)) {
- return children[i].getLineEndOffset(offset);
+ public int getLineEndOffset(final int offset) {
+ final BlockBox[] children = getContentChildren();
+ for (final BlockBox element2 : children) {
+ if (element2.containsOffset(offset)) {
+ return element2.getLineEndOffset(offset);
}
}
return offset;
}
- public int getLineStartOffset(int offset) {
- BlockBox[] children = this.getContentChildren();
- for (int i = 0; i < children.length; i++) {
- if (children[i].containsOffset(offset)) {
- return children[i].getLineStartOffset(offset);
+ public int getLineStartOffset(final int offset) {
+ final BlockBox[] children = getContentChildren();
+ for (final BlockBox element2 : children) {
+ if (element2.containsOffset(offset)) {
+ return element2.getLineStartOffset(offset);
}
}
return offset;
}
public int getMarginBottom() {
- return this.marginBottom;
+ return marginBottom;
}
public int getMarginTop() {
- return this.marginTop;
+ return marginTop;
}
- public int getNextLineOffset(LayoutContext context, int offset, int x) {
+ public int getNextLineOffset(final LayoutContext context, final int offset, final int x) {
//
// This algorithm works when this block owns the offsets between
// its children.
//
- if (offset == this.getEndOffset()) {
+ if (offset == getEndOffset()) {
return -1;
}
- BlockBox[] children = this.getContentChildren();
+ final BlockBox[] children = getContentChildren();
- if (offset < this.getStartOffset() && children.length > 0
- && children[0].getStartOffset() > this.getStartOffset()) {
+ if (offset < getStartOffset() && children.length > 0 && children[0].getStartOffset() > getStartOffset()) {
//
// If there's an offset before the first child, put the caret there.
//
- return this.getStartOffset();
+ return getStartOffset();
}
- for (int i = 0; i < children.length; i++) {
- BlockBox child = children[i];
+ for (final BlockBox child : children) {
if (offset <= child.getEndOffset()) {
- int newOffset = child.getNextLineOffset(context, offset, x
- - child.getX());
+ final int newOffset = child.getNextLineOffset(context, offset, x - child.getX());
if (newOffset < 0 /* && i < children.length-1 */) {
return child.getEndOffset() + 1;
} else {
@@ -336,36 +322,32 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
}
}
- return this.getEndOffset();
+ return getEndOffset();
}
public BlockBox getParent() {
- return this.parent;
+ return parent;
}
- public int getPreviousLineOffset(LayoutContext context, int offset, int x) {
+ public int getPreviousLineOffset(final LayoutContext context, final int offset, final int x) {
- if (offset == this.getStartOffset()) {
+ if (offset == getStartOffset()) {
return -1;
}
- BlockBox[] children = this.getContentChildren();
+ final BlockBox[] children = getContentChildren();
- if (offset > this.getEndOffset()
- && children.length > 0
- && children[children.length - 1].getEndOffset() < this
- .getEndOffset()) {
+ if (offset > getEndOffset() && children.length > 0 && children[children.length - 1].getEndOffset() < getEndOffset()) {
//
// If there's an offset after the last child, put the caret there.
//
- return this.getEndOffset();
+ return getEndOffset();
}
for (int i = children.length; i > 0; i--) {
- BlockBox child = children[i - 1];
+ final BlockBox child = children[i - 1];
if (offset >= child.getStartOffset()) {
- int newOffset = child.getPreviousLineOffset(context, offset, x
- - child.getX());
+ final int newOffset = child.getPreviousLineOffset(context, offset, x - child.getX());
if (newOffset < 0 && i > 0) {
return child.getStartOffset() - 1;
} else {
@@ -374,108 +356,112 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
}
}
- return this.getStartOffset();
+ return getStartOffset();
}
+ @Override
public int getStartOffset() {
- Element element = this.getElement();
+ final Element element = getElement();
if (element != null) {
return element.getStartOffset() + 1;
- } else if (this.getStartPosition() != null) {
- return this.getStartPosition().getOffset();
+ } else if (getStartPosition() != null) {
+ return getStartPosition().getOffset();
} else {
throw new IllegalStateException();
}
}
+ @Override
public boolean hasContent() {
return true;
}
- public void invalidate(boolean direct) {
+ public void invalidate(final boolean direct) {
if (direct) {
- this.layoutState = LAYOUT_REDO;
+ layoutState = LAYOUT_REDO;
} else {
- this.layoutState = LAYOUT_PROPAGATE;
+ layoutState = LAYOUT_PROPAGATE;
}
- if (this.getParent() instanceof AbstractBlockBox) {
- ((AbstractBlockBox) this.getParent()).invalidate(false);
+ if (getParent() instanceof AbstractBlockBox) {
+ ((AbstractBlockBox) getParent()).invalidate(false);
}
}
+ @Override
public boolean isAnonymous() {
- return this.getElement() == null;
+ return getElement() == null;
}
/**
- * Call the given callback for each child matching one of the given display
- * styles. Any nodes that do not match one of the given display types cause
- * the onRange callback to be called, with a range covering all such
- * contiguous nodes.
+ * Call the given callback for each child matching one of the given display styles. Any nodes that do not match one
+ * of the given display types cause the onRange callback to be called, with a range covering all such contiguous
+ * nodes.
*
* @param styleSheet
* StyleSheet from which to determine display styles.
* @param displayStyles
* Display types to be explicitly recognized.
* @param callback
- * DisplayStyleCallback through which the caller is notified of
- * matching elements and non-matching ranges.
+ * DisplayStyleCallback through which the caller is notified of matching elements and non-matching
+ * ranges.
*/
- protected void iterateChildrenByDisplayStyle(StyleSheet styleSheet,
- Set<String> displayStyles, ElementOrRangeCallback callback) {
- LayoutUtils.iterateChildrenByDisplayStyle(styleSheet, displayStyles,
- this.findContainingElement(), this.getStartOffset(), this
- .getEndOffset(), callback);
+ protected void iterateChildrenByDisplayStyle(final StyleSheet styleSheet, final Set<String> displayStyles, final ElementOrRangeCallback callback) {
+ LayoutUtils.iterateChildrenByDisplayStyle(styleSheet, displayStyles, findContainingElement(), getStartOffset(), getEndOffset(), callback);
}
- public void paint(LayoutContext context, int x, int y) {
+ @Override
+ public void paint(final LayoutContext context, final int x, final int y) {
- if (this.skipPaint(context, x, y)) {
+ if (skipPaint(context, x, y)) {
return;
}
- boolean drawBorders = !context.isElementSelected(this.getElement());
+ final boolean drawBorders = !context.isElementSelected(getElement());
- this.drawBox(context, x, y, this.getParent().getWidth(), drawBorders);
+ this.drawBox(context, x, y, getParent().getWidth(), drawBorders);
- this.paintChildren(context, x, y);
+ paintChildren(context, x, y);
- this.paintSelectionFrame(context, x, y, true);
+ paintSelectionFrame(context, x, y, true);
}
/**
- * Default implementation. Width is calculated as the parent's width minus
- * this box's insets. Height is calculated by getEstimatedHeight.
+ * Default implementation. Width is calculated as the parent's width minus this box's insets. Height is calculated
+ * by getEstimatedHeight.
*/
- public void setInitialSize(LayoutContext context) {
- int parentWidth = this.getParent().getWidth();
- Insets insets = this.getInsets(context, parentWidth);
- this.setWidth(Math.max(0, parentWidth - insets.getLeft()
- - insets.getRight()));
- this.setHeight(this.getEstimatedHeight(context));
+ public void setInitialSize(final LayoutContext context) {
+ final int parentWidth = getParent().getWidth();
+ final Insets insets = this.getInsets(context, parentWidth);
+ setWidth(Math.max(0, parentWidth - insets.getLeft() - insets.getRight()));
+ setHeight(getEstimatedHeight(context));
}
- public int viewToModel(LayoutContext context, int x, int y) {
- Box[] children = getChildren();
+ @Override
+ public int viewToModel(final LayoutContext context, final int x, final int y) {
+ final Box[] children = getChildren();
if (children == null) {
- int charCount = getEndOffset() - getStartOffset() - 1;
- if (charCount == 0 || getHeight() == 0) return getEndOffset();
+ final int charCount = getEndOffset() - getStartOffset() - 1;
+ if (charCount == 0 || getHeight() == 0) {
+ return getEndOffset();
+ }
return getStartOffset() + charCount * y / getHeight();
}
- for (Box child : children) {
- if (!child.hasContent()) continue;
+ for (final Box child : children) {
+ if (!child.hasContent()) {
+ continue;
+ }
- if (y < child.getY()) return child.getStartOffset() - 1;
+ if (y < child.getY()) {
+ return child.getStartOffset() - 1;
+ }
if (y < child.getY() + child.getHeight()) {
- return child.viewToModel(context,
- x - child.getX(),
- y - child.getY());
+ return child.viewToModel(context, x - child.getX(), y - child.getY());
}
}
@@ -485,7 +471,7 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
// ===================================================== PRIVATE
- private BlockBox parent;
+ private final BlockBox parent;
private Box[] children;
/**
@@ -499,20 +485,18 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
* y-coordinate at which to draw.
* @param selected
*/
- protected void paintSelectionFrame(LayoutContext context, int x, int y,
- boolean selected) {
+ protected void paintSelectionFrame(final LayoutContext context, final int x, final int y, final boolean selected) {
- Element element = this.getElement();
- Element parent = element == null ? null : element.getParent();
+ final Element element = getElement();
+ final Element parent = element == null ? null : element.getParent();
- boolean paintFrame = context.isElementSelected(element)
- && !context.isElementSelected(parent);
+ final boolean paintFrame = context.isElementSelected(element) && !context.isElementSelected(parent);
if (!paintFrame) {
return;
}
- Graphics g = context.getGraphics();
+ final Graphics g = context.getGraphics();
ColorResource foreground;
ColorResource background;
@@ -524,20 +508,18 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
background = g.createColor(new Color(0xcc, 0xcc, 0xcc));
}
- FontMetrics fm = g.getFontMetrics();
- ColorResource oldColor = g.setColor(background);
+ final FontMetrics fm = g.getFontMetrics();
+ final ColorResource oldColor = g.setColor(background);
g.setLineStyle(Graphics.LINE_SOLID);
g.setLineWidth(1);
- int tabWidth = g.stringWidth(this.getElement().getPrefixedName())
- + fm.getLeading();
- int tabHeight = fm.getHeight();
- int tabX = x + this.getWidth() - tabWidth;
- int tabY = y + this.getHeight() - tabHeight;
- g.drawRect(x, y, this.getWidth(), this.getHeight());
+ final int tabWidth = g.stringWidth(getElement().getPrefixedName()) + fm.getLeading();
+ final int tabHeight = fm.getHeight();
+ final int tabX = x + getWidth() - tabWidth;
+ final int tabY = y + getHeight() - tabHeight;
+ g.drawRect(x, y, getWidth(), getHeight());
g.fillRect(tabX, tabY, tabWidth, tabHeight);
g.setColor(foreground);
- g.drawString(this.getElement().getPrefixedName(), tabX + fm.getLeading() / 2,
- tabY);
+ g.drawString(getElement().getPrefixedName(), tabX + fm.getLeading() / 2, tabY);
g.setColor(oldColor);
if (!selected) {
@@ -557,66 +539,60 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
private byte layoutState = LAYOUT_REDO;
- public IntRange layout(LayoutContext context, int top, int bottom) {
+ public IntRange layout(final LayoutContext context, final int top, final int bottom) {
int repaintStart = Integer.MAX_VALUE;
int repaintEnd = 0;
boolean repaintToBottom = false;
- int originalHeight = this.getHeight();
+ final int originalHeight = getHeight();
- if (this.layoutState == LAYOUT_REDO) {
+ if (layoutState == LAYOUT_REDO) {
// System.out.println("Redo layout of " +
// this.getElement().getName());
- List<Box> childList = this.createChildren(context);
- this.children = (BlockBox[]) childList
- .toArray(new BlockBox[childList.size()]);
+ final List<Box> childList = createChildren(context);
+ children = childList.toArray(new BlockBox[childList.size()]);
// Even though we position children after layout, we have to
// do a preliminary positioning here so we now which ones
// overlap our layout band
- for (int i = 0; i < this.children.length; i++) {
- BlockBox child = (BlockBox) this.children[i];
+ for (final Box element2 : children) {
+ final BlockBox child = (BlockBox) element2;
child.setInitialSize(context);
}
- this.positionChildren(context);
+ positionChildren(context);
// repaint everything
repaintToBottom = true;
repaintStart = 0;
}
- Box[] children = this.getChildren();
- for (int i = 0; i < children.length; i++) {
- if (children[i] instanceof BlockBox) {
- BlockBox child = (BlockBox) children[i];
- if (top <= child.getY() + child.getHeight()
- && bottom >= child.getY()) {
+ final Box[] children = getChildren();
+ for (final Box element2 : children) {
+ if (element2 instanceof BlockBox) {
+ final BlockBox child = (BlockBox) element2;
+ if (top <= child.getY() + child.getHeight() && bottom >= child.getY()) {
- IntRange repaintRange = child.layout(context, top
- - child.getY(), bottom - child.getY());
+ final IntRange repaintRange = child.layout(context, top - child.getY(), bottom - child.getY());
if (repaintRange != null) {
- repaintStart = Math.min(repaintStart, repaintRange
- .getStart()
- + child.getY());
- repaintEnd = Math.max(repaintEnd, repaintRange.getEnd()
- + child.getY());
+ repaintStart = Math.min(repaintStart, repaintRange.getStart() + child.getY());
+ repaintEnd = Math.max(repaintEnd, repaintRange.getEnd() + child.getY());
}
}
}
}
- int childRepaintStart = this.positionChildren(context);
+ final int childRepaintStart = positionChildren(context);
if (childRepaintStart != -1) {
repaintToBottom = true;
repaintStart = Math.min(repaintStart, childRepaintStart);
}
- this.layoutState = LAYOUT_OK;
+ layoutState = LAYOUT_OK;
if (repaintToBottom) {
- repaintEnd = Math.max(originalHeight, this.getHeight());
+ repaintEnd = Math.max(originalHeight, getHeight());
}
if (repaintStart < repaintEnd) {
@@ -629,53 +605,47 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
protected abstract List<Box> createChildren(LayoutContext context);
/**
- * Creates a list of block boxes for a given document range. beforeInlines
- * and afterInlines are prepended/appended to the first/last block child,
- * and each may be null.
+ * Creates a list of block boxes for a given document range. beforeInlines and afterInlines are prepended/appended
+ * to the first/last block child, and each may be null.
*/
- protected List<Box> createBlockBoxes(LayoutContext context, int startOffset,
- int endOffset, int width, List<InlineBox> beforeInlines, List<InlineBox> afterInlines) {
+ protected List<Box> createBlockBoxes(final LayoutContext context, final int startOffset, final int endOffset, final int width, final List<InlineBox> beforeInlines,
+ final List<InlineBox> afterInlines) {
final List<Box> blockBoxes = new ArrayList<Box>();
final List<InlineBox> pendingInlines = new ArrayList<InlineBox>();
- if (beforeInlines != null)
+ if (beforeInlines != null) {
pendingInlines.addAll(beforeInlines);
-
- Document document = context.getDocument();
- Element element = document.findCommonElement(startOffset,
- endOffset);
+ }
+
+ final Document document = context.getDocument();
+ final Element element = document.findCommonElement(startOffset, endOffset);
if (startOffset == endOffset) {
- int relOffset = startOffset - element.getStartOffset();
+ final int relOffset = startOffset - element.getStartOffset();
pendingInlines.add(new PlaceholderBox(context, element, relOffset));
} else {
- BlockInlineIterator iter = new BlockInlineIterator(context,
- element, startOffset, endOffset);
+ final BlockInlineIterator iter = new BlockInlineIterator(context, element, startOffset, endOffset);
while (true) {
Object next = iter.next();
- if (next == null)
+ if (next == null) {
break;
+ }
if (next instanceof IntRange) {
- IntRange range = (IntRange) next;
- InlineElementBox.InlineBoxes inlineBoxes = InlineElementBox
- .createInlineBoxes(context, element, range
- .getStart(), range.getEnd());
+ final IntRange range = (IntRange) next;
+ final InlineElementBox.InlineBoxes inlineBoxes = InlineElementBox.createInlineBoxes(context, element, range.getStart(), range.getEnd());
pendingInlines.addAll(inlineBoxes.boxes);
- pendingInlines.add(new PlaceholderBox(context, element,
- range.getEnd() - element.getStartOffset()));
+ pendingInlines.add(new PlaceholderBox(context, element, range.getEnd() - element.getStartOffset()));
} else {
if (!pendingInlines.isEmpty()) {
- blockBoxes.add(ParagraphBox.create(context, element,
- pendingInlines, width));
+ blockBoxes.add(ParagraphBox.create(context, element, pendingInlines, width));
pendingInlines.clear();
}
if (isTableChild(context, next)) {
// Consume continguous table children and create an
// anonymous table.
- int tableStartOffset = ((Element) next)
- .getStartOffset();
+ final int tableStartOffset = ((Element) next).getStartOffset();
int tableEndOffset = -1; // dummy to hide warning
while (isTableChild(context, next)) {
tableEndOffset = ((Element) next).getEndOffset() + 1;
@@ -683,28 +653,26 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
}
// add anonymous table
- blockBoxes.add(new TableBox(context, this,
- tableStartOffset, tableEndOffset));
+ blockBoxes.add(new TableBox(context, this, tableStartOffset, tableEndOffset));
if (next == null) {
break;
} else {
iter.push(next);
}
} else { // next is a block box element
- Element blockElement = (Element) next;
- blockBoxes.add(context.getBoxFactory().createBox(
- context, blockElement, this, width));
+ final Element blockElement = (Element) next;
+ blockBoxes.add(context.getBoxFactory().createBox(context, blockElement, this, width));
}
}
}
}
- if (afterInlines != null)
+ if (afterInlines != null) {
pendingInlines.addAll(afterInlines);
-
+ }
+
if (!pendingInlines.isEmpty()) {
- blockBoxes.add(ParagraphBox.create(context, element,
- pendingInlines, width));
+ blockBoxes.add(ParagraphBox.create(context, element, pendingInlines, width));
pendingInlines.clear();
}
@@ -713,8 +681,7 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
private static class BlockInlineIterator {
- public BlockInlineIterator(LayoutContext context, Element element,
- int startOffset, int endOffset) {
+ public BlockInlineIterator(final LayoutContext context, final Element element, final int startOffset, final int endOffset) {
this.context = context;
this.element = element;
this.startOffset = startOffset;
@@ -722,29 +689,26 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
}
/**
- * Returns the next block element or inline range, or null if we're at
- * the end.
+ * Returns the next block element or inline range, or null if we're at the end.
*/
public Object next() {
- if (!this.pushStack.isEmpty()) {
- return this.pushStack.removeLast();
+ if (!pushStack.isEmpty()) {
+ return pushStack.removeLast();
} else if (startOffset == endOffset) {
return null;
} else {
- Element blockElement = findNextBlockElement(this.context,
- this.element, startOffset, endOffset);
+ final Element blockElement = findNextBlockElement(context, element, startOffset, endOffset);
if (blockElement == null) {
if (startOffset < endOffset) {
- IntRange result = new IntRange(startOffset, endOffset);
+ final IntRange result = new IntRange(startOffset, endOffset);
startOffset = endOffset;
return result;
} else {
return null;
}
} else if (blockElement.getStartOffset() > startOffset) {
- this.pushStack.addLast(blockElement);
- IntRange result = new IntRange(startOffset, blockElement
- .getStartOffset());
+ pushStack.addLast(blockElement);
+ final IntRange result = new IntRange(startOffset, blockElement.getStartOffset());
startOffset = blockElement.getEndOffset() + 1;
return result;
} else {
@@ -754,52 +718,49 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
}
}
- public void push(Object pushed) {
- this.pushStack.addLast(pushed);
+ public void push(final Object pushed) {
+ pushStack.addLast(pushed);
}
- private LayoutContext context;
- private Element element;
+ private final LayoutContext context;
+ private final Element element;
private int startOffset;
- private int endOffset;
- private LinkedList<Object> pushStack = new LinkedList<Object>();
+ private final int endOffset;
+ private final LinkedList<Object> pushStack = new LinkedList<Object>();
}
protected boolean hasChildren() {
- return this.getChildren() != null && this.getChildren().length > 0;
+ return getChildren() != null && getChildren().length > 0;
}
/**
- * Positions the children of this box. Vertical margins are collapsed here.
- * Returns the vertical offset of the top of the first child to move, or -1
- * if not children were actually moved.
+ * Positions the children of this box. Vertical margins are collapsed here. Returns the vertical offset of the top
+ * of the first child to move, or -1 if not children were actually moved.
*/
- protected int positionChildren(LayoutContext context) {
+ protected int positionChildren(final LayoutContext context) {
int childY = 0;
int prevMargin = 0;
- BlockBox[] children = this.getBlockChildren();
+ final BlockBox[] children = getBlockChildren();
int repaintStart = -1;
Styles styles = null;
- if (!this.isAnonymous()) {
- styles = context.getStyleSheet().getStyles(this.getElement());
+ if (!isAnonymous()) {
+ styles = context.getStyleSheet().getStyles(getElement());
}
if (styles != null && children.length > 0) {
- if (styles.getBorderTopWidth()
- + styles.getPaddingTop().get(this.getWidth()) == 0) {
+ if (styles.getBorderTopWidth() + styles.getPaddingTop().get(getWidth()) == 0) {
// first child's top margin collapses into ours
- this.marginTop = Math.max(this.marginTop, children[0]
- .getMarginTop());
+ marginTop = Math.max(marginTop, children[0].getMarginTop());
childY -= children[0].getMarginTop();
}
}
for (int i = 0; i < children.length; i++) {
- Insets insets = children[i].getInsets(context, this.getWidth());
+ final Insets insets = children[i].getInsets(context, getWidth());
childY += insets.getTop();
@@ -819,15 +780,14 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
}
if (styles != null && children.length > 0) {
- if (styles.getBorderBottomWidth()
- + styles.getPaddingBottom().get(this.getWidth()) == 0) {
+ if (styles.getBorderBottomWidth() + styles.getPaddingBottom().get(getWidth()) == 0) {
// last child's bottom margin collapses into ours
- this.marginBottom = Math.max(this.marginBottom, prevMargin);
+ marginBottom = Math.max(marginBottom, prevMargin);
childY -= prevMargin;
}
}
- this.setHeight(childY);
+ setHeight(childY);
return repaintStart;
}
@@ -838,7 +798,7 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
* @param layoutState
* One of the LAYOUT_* constants
*/
- protected void setLayoutState(byte layoutState) {
+ protected void setLayoutState(final byte layoutState) {
this.layoutState = layoutState;
}
@@ -852,15 +812,13 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
private Element element;
/*
- * We cache the top and bottom margins, since they may be affected by our
- * children.
+ * We cache the top and bottom margins, since they may be affected by our children.
*/
private int marginTop;
private int marginBottom;
/**
- * Start position of an anonymous box. For non-anonymous boxes, this is
- * null.
+ * Start position of an anonymous box. For non-anonymous boxes, this is null.
*/
private Position startPosition;
@@ -881,23 +839,27 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
* @param endOffset
* The offset at which to end the search.
*/
- private static Element findNextBlockElement(LayoutContext context,
- Element element, int startOffset, int endOffset) {
+ private static Element findNextBlockElement(final LayoutContext context, final Element element, final int startOffset, final int endOffset) {
- List<Element> children = element.getChildElements();
+ final List<Element> children = element.getChildElements();
for (int i = 0; i < children.size(); i++) {
- Element child = children.get(i);
+ final Element child = children.get(i);
- // inside range?
- if (child.getEndOffset() < startOffset) continue;
- if (child.getStartOffset() >= endOffset) break;
+ // inside range?
+ if (child.getEndOffset() < startOffset) {
+ continue;
+ }
+ if (child.getStartOffset() >= endOffset) {
+ break;
+ }
- // found?
- if (!isInline(context, child, element)) return child;
+ // found?
+ if (!isInline(context, child, element)) {
+ return child;
+ }
// recursion
- Element fromChild =
- findNextBlockElement(context, child, startOffset, endOffset);
+ final Element fromChild = findNextBlockElement(context, child, startOffset, endOffset);
if (fromChild != null) {
return fromChild;
}
@@ -905,90 +867,74 @@ public abstract class AbstractBlockBox extends AbstractBox implements BlockBox {
return null;
}
-
- private static boolean isInline(LayoutContext context,
- Element child,
- Element parent) {
- String style = displayStyleOf(child, context);
- String parentStyle = displayStyleOf(parent, context);
+ private static boolean isInline(final LayoutContext context, final Element child, final Element parent) {
+
+ final String style = displayStyleOf(child, context);
+ final String parentStyle = displayStyleOf(parent, context);
if (style.equals(CSS.INLINE)) {
return true;
}
-
+
// invalid nested table elements have to be shown as 'inline':
-
+
// parent of 'table-cell': 'table-row'
- if ( style.equals(CSS.TABLE_CELL)
- && !parentStyle.equals(CSS.TABLE_ROW)) {
+ if (style.equals(CSS.TABLE_CELL) && !parentStyle.equals(CSS.TABLE_ROW)) {
return true;
}
-
+
// parent of 'table-row': 'table', 'table-row-group',
// 'table-header-group' or 'table-footer-group'
- if ( style.equals(CSS.TABLE_ROW)
- && !parentStyle.equals(CSS.TABLE)
- && !parentStyle.equals(CSS.TABLE_ROW_GROUP)
- && !parentStyle.equals(CSS.TABLE_HEADER_GROUP)
- && !parentStyle.equals(CSS.TABLE_FOOTER_GROUP)) {
+ if (style.equals(CSS.TABLE_ROW) && !parentStyle.equals(CSS.TABLE) && !parentStyle.equals(CSS.TABLE_ROW_GROUP) && !parentStyle.equals(CSS.TABLE_HEADER_GROUP)
+ && !parentStyle.equals(CSS.TABLE_FOOTER_GROUP)) {
return true;
}
-
+
// parent of 'table-row-group', table-header-group'
// or 'table-footer-group': 'table'
- if ( ( style.equals(CSS.TABLE_ROW_GROUP)
- || style.equals(CSS.TABLE_HEADER_GROUP)
- || style.equals(CSS.TABLE_FOOTER_GROUP))
- && !parentStyle.equals(CSS.TABLE)) {
+ if ((style.equals(CSS.TABLE_ROW_GROUP) || style.equals(CSS.TABLE_HEADER_GROUP) || style.equals(CSS.TABLE_FOOTER_GROUP)) && !parentStyle.equals(CSS.TABLE)) {
return true;
}
-
+
// parent of 'table-column': 'table-column-group'
- if ( style.equals(CSS.TABLE_COLUMN)
- && !parentStyle.equals(CSS.TABLE_COLUMN_GROUP)) {
+ if (style.equals(CSS.TABLE_COLUMN) && !parentStyle.equals(CSS.TABLE_COLUMN_GROUP)) {
return true;
}
-
+
// parent of 'table-column-group': 'table'
- if ( style.equals(CSS.TABLE_COLUMN_GROUP)
- && !parentStyle.equals(CSS.TABLE)) {
+ if (style.equals(CSS.TABLE_COLUMN_GROUP) && !parentStyle.equals(CSS.TABLE)) {
return true;
}
-
+
// parent of 'table-caption': 'table'
- if ( style.equals(CSS.TABLE_CAPTION)
- && !parentStyle.equals(CSS.TABLE)) {
+ if (style.equals(CSS.TABLE_CAPTION) && !parentStyle.equals(CSS.TABLE)) {
return true;
}
-
+
return false;
}
-
- private static String displayStyleOf(Element element,
- LayoutContext context) {
+
+ private static String displayStyleOf(final Element element, final LayoutContext context) {
return context.getStyleSheet().getStyles(element).getDisplay();
}
/**
- * Return the end position of an anonymous box. The default implementation
- * returns null.
+ * Return the end position of an anonymous box. The default implementation returns null.
*/
private Position getEndPosition() {
- return this.endPosition;
+ return endPosition;
}
/**
- * Return the start position of an anonymous box. The default implementation
- * returns null.
+ * Return the start position of an anonymous box. The default implementation returns null.
*/
private Position getStartPosition() {
- return this.startPosition;
+ return startPosition;
}
- private boolean isTableChild(LayoutContext context, Object rangeOrElement) {
+ private boolean isTableChild(final LayoutContext context, final Object rangeOrElement) {
if (rangeOrElement != null && rangeOrElement instanceof Element) {
- return LayoutUtils.isTableChild(context.getStyleSheet(),
- (Element) rangeOrElement);
+ return LayoutUtils.isTableChild(context.getStyleSheet(), (Element) rangeOrElement);
} else {
return false;
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AbstractBox.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AbstractBox.java
index d69057c0..bb3ca825 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AbstractBox.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AbstractBox.java
@@ -21,8 +21,7 @@ import org.eclipse.vex.core.internal.css.Styles;
import org.eclipse.vex.core.internal.dom.Element;
/**
- * Base implementation of the <code>Box</code> interface, implementing some
- * common methods.
+ * Base implementation of the <code>Box</code> interface, implementing some common methods.
*/
public abstract class AbstractBox implements Box {
@@ -40,23 +39,20 @@ public abstract class AbstractBox implements Box {
}
/**
- * Returns true if the given offset is between startOffset and endOffset,
- * inclusive.
+ * Returns true if the given offset is between startOffset and endOffset, inclusive.
*
* @see org.eclipse.vex.core.internal.layout.Box#containsOffset(int)
*/
- public boolean containsOffset(int offset) {
- return offset >= this.getStartOffset() && offset <= this.getEndOffset();
+ public boolean containsOffset(final int offset) {
+ return offset >= getStartOffset() && offset <= getEndOffset();
}
/**
- * Throws <code>IllegalStateException</code>. Boxes with content must
- * provide an implementation of this method.
+ * Throws <code>IllegalStateException</code>. Boxes with content must provide an implementation of this method.
*
- * @see org.eclipse.vex.core.internal.layout.Box#getCaret(org.eclipse.vex.core.internal.layout.LayoutContext,
- * int)
+ * @see org.eclipse.vex.core.internal.layout.Box#getCaret(org.eclipse.vex.core.internal.layout.LayoutContext, int)
*/
- public Caret getCaret(LayoutContext context, int offset) {
+ public Caret getCaret(final LayoutContext context, final int offset) {
throw new IllegalStateException();
}
@@ -70,8 +66,7 @@ public abstract class AbstractBox implements Box {
}
/**
- * Returns null. Boxes associated with elements must provide an
- * implementation of this method.
+ * Returns null. Boxes associated with elements must provide an implementation of this method.
*
* @see org.eclipse.vex.core.internal.layout.Box#getElement()
*/
@@ -80,8 +75,7 @@ public abstract class AbstractBox implements Box {
}
/**
- * Throws <code>IllegalStateException</code>. Boxes with content must
- * provide an implementation of this method.
+ * Throws <code>IllegalStateException</code>. Boxes with content must provide an implementation of this method.
*
* @see org.eclipse.vex.core.internal.layout.Box#getEndOffset()
*/
@@ -95,12 +89,11 @@ public abstract class AbstractBox implements Box {
* @see org.eclipse.vex.core.internal.layout.Box#getHeight()
*/
public int getHeight() {
- return this.height;
+ return height;
}
/**
- * Throws <code>IllegalStateException</code>. Boxes with content must
- * provide an implementation of this method.
+ * Throws <code>IllegalStateException</code>. Boxes with content must provide an implementation of this method.
*
* @see org.eclipse.vex.core.internal.layout.Box#getStartOffset()
*/
@@ -109,23 +102,21 @@ public abstract class AbstractBox implements Box {
}
/**
- * Returns the insets of this box, which is the sum of the margin, border,
- * and padding on each side. If no element is associated with this box
- * returns all zeros.
+ * Returns the insets of this box, which is the sum of the margin, border, and padding on each side. If no element
+ * is associated with this box returns all zeros.
*/
- public Insets getInsets(LayoutContext context, int containerWidth) {
- Element element = this.getElement();
+ public Insets getInsets(final LayoutContext context, final int containerWidth) {
+ final Element element = getElement();
if (element == null) {
return Insets.ZERO_INSETS;
} else {
- return getInsets(context.getStyleSheet().getStyles(element),
- containerWidth);
+ return getInsets(context.getStyleSheet().getStyles(element), containerWidth);
}
}
/**
- * Returns false. Boxes with content must override this method and return
- * true, and must provide implementations for the following methods.
+ * Returns false. Boxes with content must override this method and return true, and must provide implementations for
+ * the following methods.
*
* <ul>
* <li>{@link Box#getCaretShapes}</li>
@@ -150,7 +141,7 @@ public abstract class AbstractBox implements Box {
* @see org.eclipse.vex.core.internal.layout.Box#getWidth()
*/
public int getWidth() {
- return this.width;
+ return width;
}
/**
@@ -159,7 +150,7 @@ public abstract class AbstractBox implements Box {
* @see org.eclipse.vex.core.internal.layout.Box#getX()
*/
public int getX() {
- return this.x;
+ return x;
}
/**
@@ -168,20 +159,20 @@ public abstract class AbstractBox implements Box {
* @see org.eclipse.vex.core.internal.layout.Box#getY()
*/
public int getY() {
- return this.y;
+ return y;
}
/**
* Paint all children of this box.
*
- * @see org.eclipse.vex.core.internal.layout.Box#paint(org.eclipse.vex.core.internal.layout.LayoutContext,
- * int, int)
+ * @see org.eclipse.vex.core.internal.layout.Box#paint(org.eclipse.vex.core.internal.layout.LayoutContext, int, int)
*/
- public void paint(LayoutContext context, int x, int y) {
- if (this.skipPaint(context, x, y))
+ public void paint(final LayoutContext context, final int x, final int y) {
+ if (skipPaint(context, x, y)) {
return;
+ }
- this.paintChildren(context, x, y);
+ paintChildren(context, x, y);
}
/**
@@ -194,33 +185,33 @@ public abstract class AbstractBox implements Box {
* @param y
* y-coordinate at which to paint
*/
- protected void paintChildren(LayoutContext context, int x, int y) {
- Box[] children = this.getChildren();
+ protected void paintChildren(final LayoutContext context, final int x, final int y) {
+ final Box[] children = getChildren();
for (int i = 0; children != null && i < children.length; i++) {
- Box child = children[i];
+ final Box child = children[i];
child.paint(context, x + child.getX(), y + child.getY());
}
}
- public void setHeight(int height) {
+ public void setHeight(final int height) {
this.height = height;
}
- public void setWidth(int width) {
+ public void setWidth(final int width) {
this.width = width;
}
- public void setX(int x) {
+ public void setX(final int x) {
this.x = x;
}
- public void setY(int y) {
+ public void setY(final int y) {
this.y = y;
}
/**
- * Returns true if this box is outside the clip region. Implementations of
- * <code>paint</code> should use this to avoid unnecessary painting.
+ * Returns true if this box is outside the clip region. Implementations of <code>paint</code> should use this to
+ * avoid unnecessary painting.
*
* @param context
* <code>LayoutContext</code> in effect.
@@ -229,22 +220,20 @@ public abstract class AbstractBox implements Box {
* @param y
* the y-coordinate at which the box is being painted
*/
- protected boolean skipPaint(LayoutContext context, int x, int y) {
- Rectangle clipBounds = context.getGraphics().getClipBounds();
+ protected boolean skipPaint(final LayoutContext context, final int x, final int y) {
+ final Rectangle clipBounds = context.getGraphics().getClipBounds();
- return clipBounds.getY() + clipBounds.getHeight() <= y
- || clipBounds.getY() >= y + this.getHeight();
+ return clipBounds.getY() + clipBounds.getHeight() <= y || clipBounds.getY() >= y + getHeight();
}
/**
- * Throws <code>IllegalStateException</code>. Boxes with content must
- * provide an implementation of this method.
+ * Throws <code>IllegalStateException</code>. Boxes with content must provide an implementation of this method.
*
* @see org.eclipse.vex.core.internal.layout.Box#viewToModel(org.eclipse.vex.core.internal.layout.LayoutContext,
* int, int)
*/
- public int viewToModel(LayoutContext context, int x, int y) {
+ public int viewToModel(final LayoutContext context, final int x, final int y) {
throw new IllegalStateException();
}
@@ -258,17 +247,13 @@ public abstract class AbstractBox implements Box {
* @param y
* y-coordinate of the top of the box
* @param containerWidth
- * width of the containing client area. Used for calculating
- * padding expressed as a percentage.
+ * width of the containing client area. Used for calculating padding expressed as a percentage.
* @param drawBorders
- * If true, the background is filled and the borders are drawn;
- * otherwise, just the background is filled. This is handy when
- * removing the borders when drawing the selection frame.
+ * If true, the background is filled and the borders are drawn; otherwise, just the background is filled.
+ * This is handy when removing the borders when drawing the selection frame.
*/
- protected void drawBox(LayoutContext context, int x, int y,
- int containerWidth, boolean drawBorders) {
- this.drawBox(context, this.getElement(), x, y, containerWidth,
- drawBorders);
+ protected void drawBox(final LayoutContext context, final int x, final int y, final int containerWidth, final boolean drawBorders) {
+ this.drawBox(context, getElement(), x, y, containerWidth, drawBorders);
}
/**
@@ -277,47 +262,38 @@ public abstract class AbstractBox implements Box {
* @param context
* LayoutContext used for drawing.
* @param element
- * Element to use when determining styles. This is used by
- * TableBodyBox to specify the corresponding table element.
+ * Element to use when determining styles. This is used by TableBodyBox to specify the corresponding
+ * table element.
* @param x
* x-coordinate of the left side of the box
* @param y
* y-coordinate of the top of the box
* @param containerWidth
- * width of the containing client area. Used for calculating
- * padding expressed as a percentage.
+ * width of the containing client area. Used for calculating padding expressed as a percentage.
* @param drawBorders
- * If true, the background is filled and the borders are drawn;
- * otherwise, just the background is filled. This is handy when
- * removing the borders when drawing the selection frame.
+ * If true, the background is filled and the borders are drawn; otherwise, just the background is filled.
+ * This is handy when removing the borders when drawing the selection frame.
*/
- protected void drawBox(LayoutContext context, Element element, int x,
- int y, int containerWidth, boolean drawBorders) {
+ protected void drawBox(final LayoutContext context, final Element element, final int x, final int y, final int containerWidth, final boolean drawBorders) {
if (element == null) {
return;
}
- Graphics g = context.getGraphics();
- Styles styles = context.getStyleSheet().getStyles(element);
+ final Graphics g = context.getGraphics();
+ final Styles styles = context.getStyleSheet().getStyles(element);
boolean hasLeft = true;
boolean hasRight = true;
- int left = x - styles.getPaddingLeft().get(containerWidth)
- - styles.getBorderLeftWidth();
- int top = y - styles.getPaddingTop().get(containerWidth)
- - styles.getBorderTopWidth();
- int right = x + this.getWidth()
- + styles.getPaddingRight().get(containerWidth)
- + styles.getBorderRightWidth();
- int bottom = y + this.getHeight()
- + styles.getPaddingBottom().get(containerWidth)
- + styles.getBorderBottomWidth();
+ final int left = x - styles.getPaddingLeft().get(containerWidth) - styles.getBorderLeftWidth();
+ final int top = y - styles.getPaddingTop().get(containerWidth) - styles.getBorderTopWidth();
+ final int right = x + getWidth() + styles.getPaddingRight().get(containerWidth) + styles.getBorderRightWidth();
+ final int bottom = y + getHeight() + styles.getPaddingBottom().get(containerWidth) + styles.getBorderBottomWidth();
if (this instanceof InlineElementBox) {
// TODO fix boxes for inline elements
- hasLeft = this.getStartOffset() == element.getStartOffset() + 1;
- hasRight = this.getEndOffset() == element.getEndOffset();
+ hasLeft = getStartOffset() == element.getStartOffset() + 1;
+ hasRight = getEndOffset() == element.getEndOffset();
if (hasLeft) {
// left += styles.getMarginLeft().get(0);
}
@@ -330,11 +306,11 @@ public abstract class AbstractBox implements Box {
// styles.getBorderBottomWidth();
}
- Color backgroundColor = styles.getBackgroundColor();
+ final Color backgroundColor = styles.getBackgroundColor();
if (backgroundColor != null) {
- ColorResource color = g.createColor(backgroundColor);
- ColorResource oldColor = g.setColor(color);
+ final ColorResource color = g.createColor(backgroundColor);
+ final ColorResource oldColor = g.setColor(color);
g.fillRect(left, top, right - left, bottom - top);
g.setColor(oldColor);
color.dispose();
@@ -347,32 +323,29 @@ public abstract class AbstractBox implements Box {
// g.setRenderingHint(
// RenderingHints.KEY_ANTIALIASING,
// RenderingHints.VALUE_ANTIALIAS_OFF);
- boolean oldAntiAlias = g.isAntiAliased();
+ final boolean oldAntiAlias = g.isAntiAliased();
g.setAntiAliased(false);
- int bw2 = styles.getBorderBottomWidth() / 2;
- int lw2 = styles.getBorderLeftWidth() / 2;
- int rw2 = styles.getBorderRightWidth() / 2;
- int tw2 = styles.getBorderTopWidth() / 2;
+ final int bw2 = styles.getBorderBottomWidth() / 2;
+ final int lw2 = styles.getBorderLeftWidth() / 2;
+ final int rw2 = styles.getBorderRightWidth() / 2;
+ final int tw2 = styles.getBorderTopWidth() / 2;
// Bottom border
if (styles.getBorderBottomWidth() > 0) {
- ColorResource color = g.createColor(styles
- .getBorderBottomColor());
- ColorResource oldColor = g.setColor(color);
+ final ColorResource color = g.createColor(styles.getBorderBottomColor());
+ final ColorResource oldColor = g.setColor(color);
g.setLineStyle(lineStyle(styles.getBorderBottomStyle()));
g.setLineWidth(styles.getBorderBottomWidth());
- g.drawLine(left + bw2, bottom - bw2 - 1, right - bw2, bottom
- - bw2 - 1);
+ g.drawLine(left + bw2, bottom - bw2 - 1, right - bw2, bottom - bw2 - 1);
g.setColor(oldColor);
color.dispose();
}
// Left border
if (hasLeft && styles.getBorderLeftWidth() > 0) {
- ColorResource color = g
- .createColor(styles.getBorderLeftColor());
- ColorResource oldColor = g.setColor(color);
+ final ColorResource color = g.createColor(styles.getBorderLeftColor());
+ final ColorResource oldColor = g.setColor(color);
g.setLineStyle(lineStyle(styles.getBorderLeftStyle()));
g.setLineWidth(styles.getBorderLeftWidth());
g.drawLine(left + lw2, top + lw2, left + lw2, bottom - lw2 - 1);
@@ -382,21 +355,19 @@ public abstract class AbstractBox implements Box {
// Right border
if (hasRight && styles.getBorderRightWidth() > 0) {
- ColorResource color = g.createColor(styles
- .getBorderRightColor());
- ColorResource oldColor = g.setColor(color);
+ final ColorResource color = g.createColor(styles.getBorderRightColor());
+ final ColorResource oldColor = g.setColor(color);
g.setLineStyle(lineStyle(styles.getBorderRightStyle()));
g.setLineWidth(styles.getBorderRightWidth());
- g.drawLine(right - rw2 - 1, top + rw2, right - rw2 - 1, bottom
- - rw2 - 1);
+ g.drawLine(right - rw2 - 1, top + rw2, right - rw2 - 1, bottom - rw2 - 1);
g.setColor(oldColor);
color.dispose();
}
// Top border
if (styles.getBorderTopWidth() > 0) {
- ColorResource color = g.createColor(styles.getBorderTopColor());
- ColorResource oldColor = g.setColor(color);
+ final ColorResource color = g.createColor(styles.getBorderTopColor());
+ final ColorResource oldColor = g.setColor(color);
g.setLineStyle(lineStyle(styles.getBorderTopStyle()));
g.setLineWidth(styles.getBorderTopWidth());
g.drawLine(left + tw2, top + tw2, right - tw2, top + tw2);
@@ -412,10 +383,9 @@ public abstract class AbstractBox implements Box {
}
/**
- * Convert a CSS line style string (e.g. "dotted") to the corresponding
- * Graphics.LINE_XXX style.
+ * Convert a CSS line style string (e.g. "dotted") to the corresponding Graphics.LINE_XXX style.
*/
- private static int lineStyle(String style) {
+ private static int lineStyle(final String style) {
if (style.equals(CSS.DOTTED)) {
return Graphics.LINE_DOT;
} else if (style.equals(CSS.DASHED)) {
@@ -434,23 +404,15 @@ public abstract class AbstractBox implements Box {
* @param containerWidth
* Content area of the containing box.
*/
- public static Insets getInsets(Styles styles, int containerWidth) {
+ public static Insets getInsets(final Styles styles, final int containerWidth) {
- int top = styles.getMarginTop().get(containerWidth)
- + styles.getBorderTopWidth()
- + styles.getPaddingTop().get(containerWidth);
+ final int top = styles.getMarginTop().get(containerWidth) + styles.getBorderTopWidth() + styles.getPaddingTop().get(containerWidth);
- int left = styles.getMarginLeft().get(containerWidth)
- + styles.getBorderLeftWidth()
- + styles.getPaddingLeft().get(containerWidth);
+ final int left = styles.getMarginLeft().get(containerWidth) + styles.getBorderLeftWidth() + styles.getPaddingLeft().get(containerWidth);
- int bottom = styles.getMarginBottom().get(containerWidth)
- + styles.getBorderBottomWidth()
- + styles.getPaddingBottom().get(containerWidth);
+ final int bottom = styles.getMarginBottom().get(containerWidth) + styles.getBorderBottomWidth() + styles.getPaddingBottom().get(containerWidth);
- int right = styles.getMarginRight().get(containerWidth)
- + styles.getBorderRightWidth()
- + styles.getPaddingRight().get(containerWidth);
+ final int right = styles.getMarginRight().get(containerWidth) + styles.getBorderRightWidth() + styles.getPaddingRight().get(containerWidth);
return new Insets(top, left, bottom, right);
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AbstractInlineBox.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AbstractInlineBox.java
index 9a6b87ad..7d2e9098 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AbstractInlineBox.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AbstractInlineBox.java
@@ -15,7 +15,7 @@ package org.eclipse.vex.core.internal.layout;
*/
public abstract class AbstractInlineBox extends AbstractBox implements InlineBox {
- public void alignOnBaseline(int baseline) {
+ public void alignOnBaseline(final int baseline) {
setY(baseline - getBaseline());
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AnonymousBlockBox.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AnonymousBlockBox.java
index d10d5da9..6ce13f20 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AnonymousBlockBox.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/AnonymousBlockBox.java
@@ -18,15 +18,14 @@ import java.util.List;
*/
public class AnonymousBlockBox extends AbstractBlockBox {
- public AnonymousBlockBox(LayoutContext context, BlockBox parent,
- int startOffset, int endOffset) {
+ public AnonymousBlockBox(final LayoutContext context, final BlockBox parent, final int startOffset, final int endOffset) {
super(context, parent, startOffset, endOffset);
}
- protected List<Box> createChildren(LayoutContext context) {
- return createBlockBoxes(context, this.getStartOffset(), this
- .getEndOffset(), this.getWidth(), null, null);
+ @Override
+ protected List<Box> createChildren(final LayoutContext context) {
+ return createBlockBoxes(context, getStartOffset(), getEndOffset(), getWidth(), null, null);
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BlockBox.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BlockBox.java
index 1e869d75..9fce64a8 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BlockBox.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BlockBox.java
@@ -18,14 +18,12 @@ import org.eclipse.vex.core.internal.core.IntRange;
public interface BlockBox extends Box {
/**
- * Returns the first LineBox contained by this block, or null if the block
- * contains no lines.
+ * Returns the first LineBox contained by this block, or null if the block contains no lines.
*/
public LineBox getFirstLine();
/**
- * Returns the last LineBox contained by this block, or null if the block
- * contains no lines.
+ * Returns the last LineBox contained by this block, or null if the block contains no lines.
*/
public LineBox getLastLine();
@@ -56,9 +54,8 @@ public interface BlockBox extends Box {
public int getMarginTop();
/**
- * Returns the offset on the next line that is closest to the given x
- * coordinate. The given offset may be before the start of this box in which
- * case this method should return the offset of the first line in this box.
+ * Returns the offset on the next line that is closest to the given x coordinate. The given offset may be before the
+ * start of this box in which case this method should return the offset of the first line in this box.
*
* @param context
* LayoutContext used for the layout
@@ -70,9 +67,8 @@ public interface BlockBox extends Box {
public int getNextLineOffset(LayoutContext context, int offset, int x);
/**
- * Returns the offset on the previous line that is closest to the given x
- * coordinate. The given offset may be after the end of this box in which
- * case this method should return the offset of the last line in this box.
+ * Returns the offset on the previous line that is closest to the given x coordinate. The given offset may be after
+ * the end of this box in which case this method should return the offset of the last line in this box.
*
* @param context
* LayoutContext used for the layout
@@ -89,13 +85,11 @@ public interface BlockBox extends Box {
public BlockBox getParent();
/**
- * Informs this box that its layout has become invalid, and that it should
- * re-do it the next time layout is called.
+ * Informs this box that its layout has become invalid, and that it should re-do it the next time layout is called.
*
* @param direct
- * If true, the box's content has changed and it must re-create
- * it's children on the next call to layout. Otherwise, it should
- * just propagate the next layout call to its children.
+ * If true, the box's content has changed and it must re-create it's children on the next call to layout.
+ * Otherwise, it should just propagate the next layout call to its children.
*/
public void invalidate(boolean direct);
@@ -105,25 +99,22 @@ public interface BlockBox extends Box {
* <ul>
* <li>Creating any child boxes.</li>
* <li>Calling layout on the child boxes.</li>
- * <li>Positioning the child boxes (i.e. calling child.setX() and
- * child.setY())</li>
+ * <li>Positioning the child boxes (i.e. calling child.setX() and child.setY())</li>
* <li>Determining this box's height and width.</li>
* </ul>
*
* <p>
- * Boxes with no children should simply calculate their width and height
- * here
+ * Boxes with no children should simply calculate their width and height here
* </p>
*
* <p>
- * This method is passed a vertical range to be layed out. Children falling
- * outside this range need not be layed out.
+ * This method is passed a vertical range to be layed out. Children falling outside this range need not be layed
+ * out.
* </p>
*
* <p>
- * This method returns an IntRange object representing the vertical range to
- * re-draw due to layout change. Null may be returned if there were no
- * changes that need to be re-drawn.
+ * This method returns an IntRange object representing the vertical range to re-draw due to layout change. Null may
+ * be returned if there were no changes that need to be re-drawn.
* </p>
*
* @param context
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BlockElementBox.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BlockElementBox.java
index 919ea9ff..9c58ef98 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BlockElementBox.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BlockElementBox.java
@@ -25,9 +25,8 @@ import org.eclipse.vex.core.internal.css.Styles;
import org.eclipse.vex.core.internal.dom.Element;
/**
- * A block box corresponding to a DOM Element. Block boxes lay their children
- * out stacked top to bottom. Block boxes correspond to the
- * <code>display: block;</code> CSS property.
+ * A block box corresponding to a DOM Element. Block boxes lay their children out stacked top to bottom. Block boxes
+ * correspond to the <code>display: block;</code> CSS property.
*/
public class BlockElementBox extends AbstractBlockBox {
@@ -42,9 +41,8 @@ public class BlockElementBox extends AbstractBlockBox {
BlockBox beforeMarker;
/**
- * Class constructor. This box's children are not created here but in the
- * first call to layout. Instead, we estimate the box's height here based on
- * the given width.
+ * Class constructor. This box's children are not created here but in the first call to layout. Instead, we estimate
+ * the box's height here based on the given width.
*
* @param context
* LayoutContext used for this layout.
@@ -53,7 +51,7 @@ public class BlockElementBox extends AbstractBlockBox {
* @param element
* Element to which this box corresponds.
*/
- public BlockElementBox(LayoutContext context, BlockBox parent, Element element) {
+ public BlockElementBox(final LayoutContext context, final BlockBox parent, final Element element) {
super(context, parent, element);
}
@@ -64,65 +62,72 @@ public class BlockElementBox extends AbstractBlockBox {
return boxCount;
}
+ @Override
public int getEndOffset() {
- return this.getElement().getEndOffset();
+ return getElement().getEndOffset();
}
+ @Override
public int getStartOffset() {
- return this.getElement().getStartOffset() + 1;
+ return getElement().getStartOffset() + 1;
}
+ @Override
public boolean hasContent() {
return true;
}
- public void paint(LayoutContext context, int x, int y) {
+ @Override
+ public void paint(final LayoutContext context, final int x, final int y) {
super.paint(context, x, y);
- if (this.beforeMarker != null) {
- this.beforeMarker.paint(context, x + this.beforeMarker.getX(), y + this.beforeMarker.getY());
+ if (beforeMarker != null) {
+ beforeMarker.paint(context, x + beforeMarker.getX(), y + beforeMarker.getY());
}
}
- protected int positionChildren(LayoutContext context) {
+ @Override
+ protected int positionChildren(final LayoutContext context) {
- int repaintStart = super.positionChildren(context);
+ final int repaintStart = super.positionChildren(context);
- Styles styles = context.getStyleSheet().getStyles(this.getElement());
- if (this.beforeMarker != null) {
- int x = -this.beforeMarker.getWidth() - Math.round(BULLET_SPACE * styles.getFontSize());
- int y = this.getFirstLineTop(context);
- LineBox firstLine = this.getFirstLine();
+ final Styles styles = context.getStyleSheet().getStyles(getElement());
+ if (beforeMarker != null) {
+ final int x = -beforeMarker.getWidth() - Math.round(BULLET_SPACE * styles.getFontSize());
+ int y = getFirstLineTop(context);
+ final LineBox firstLine = getFirstLine();
if (firstLine != null) {
- y += firstLine.getBaseline() - this.beforeMarker.getFirstLine().getBaseline();
+ y += firstLine.getBaseline() - beforeMarker.getFirstLine().getBaseline();
}
- this.beforeMarker.setX(x);
- this.beforeMarker.setY(y);
+ beforeMarker.setX(x);
+ beforeMarker.setY(y);
}
return repaintStart;
}
+ @Override
public String toString() {
- return "BlockElementBox: <" + this.getElement().getPrefixedName() + ">" + "[x=" + this.getX() + ",y=" + this.getY() + ",width=" + this.getWidth()
- + ",height=" + this.getHeight() + "]";
+ return "BlockElementBox: <" + getElement().getPrefixedName() + ">" + "[x=" + getX() + ",y=" + getY() + ",width=" + getWidth() + ",height=" + getHeight() + "]";
}
// ===================================================== PRIVATE
/**
- * Lays out the children as vertically stacked blocks. Runs of text and
- * inline elements are wrapped in DummyBlockBox's.
+ * Lays out the children as vertically stacked blocks. Runs of text and inline elements are wrapped in
+ * DummyBlockBox's.
*/
- public List<Box> createChildren(LayoutContext context) {
+ @Override
+ public List<Box> createChildren(final LayoutContext context) {
long start = 0;
- if (VEXCorePlugin.getInstance().isDebugging())
+ if (VEXCorePlugin.getInstance().isDebugging()) {
start = System.currentTimeMillis();
+ }
- final Element element = this.getElement();
- int width = this.getWidth();
+ final Element element = getElement();
+ final int width = getWidth();
final List<Box> childList = new ArrayList<Box>();
@@ -134,7 +139,7 @@ public class BlockElementBox extends AbstractBlockBox {
// :before content
List<InlineBox> beforeInlines = null;
- genElement = context.getStyleSheet().getBeforeElement(this.getElement());
+ genElement = context.getStyleSheet().getBeforeElement(getElement());
if (genElement != null) {
genStyles = styleSheet.getStyles(genElement);
if (genStyles.getDisplay().equals(CSS.INLINE)) {
@@ -146,12 +151,13 @@ public class BlockElementBox extends AbstractBlockBox {
}
// background image
- final Styles styles = context.getStyleSheet().getStyles(this.getElement());
+ final Styles styles = context.getStyleSheet().getStyles(getElement());
if (styles.hasBackgroundImage() && !styles.getDisplay().equalsIgnoreCase(CSS.NONE)) {
final InlineBox imageBox = ImageBox.create(getElement(), context, getWidth());
if (imageBox != null) {
- if (beforeInlines == null)
+ if (beforeInlines == null) {
beforeInlines = new ArrayList<InlineBox>();
+ }
beforeInlines.add(imageBox);
}
}
@@ -159,7 +165,7 @@ public class BlockElementBox extends AbstractBlockBox {
// :after content
Box afterBlock = null;
List<InlineBox> afterInlines = null;
- genElement = context.getStyleSheet().getAfterElement(this.getElement());
+ genElement = context.getStyleSheet().getAfterElement(getElement());
if (genElement != null) {
genStyles = context.getStyleSheet().getStyles(genElement);
if (genStyles.getDisplay().equals(CSS.INLINE)) {
@@ -172,20 +178,21 @@ public class BlockElementBox extends AbstractBlockBox {
final int startOffset = element.getStartOffset() + 1;
final int endOffset = element.getEndOffset();
- List<Box> blockBoxes = createBlockBoxes(context, startOffset, endOffset, width, beforeInlines, afterInlines);
+ final List<Box> blockBoxes = createBlockBoxes(context, startOffset, endOffset, width, beforeInlines, afterInlines);
childList.addAll(blockBoxes);
- if (afterBlock != null)
+ if (afterBlock != null) {
childList.add(afterBlock);
+ }
if (styles.getDisplay().equals(CSS.LIST_ITEM) && !styles.getListStyleType().equals(CSS.NONE)) {
- this.createListMarker(context);
+ createListMarker(context);
}
if (VEXCorePlugin.getInstance().isDebugging()) {
- long end = System.currentTimeMillis();
+ final long end = System.currentTimeMillis();
if (end - start > 10) {
- System.out.println("BEB.layout for " + this.getElement().getPrefixedName() + " took " + (end - start) + "ms");
+ System.out.println("BEB.layout for " + getElement().getPrefixedName() + " took " + (end - start) + "ms");
}
}
@@ -193,40 +200,39 @@ public class BlockElementBox extends AbstractBlockBox {
}
/**
- * Creates a marker box for this primary box and puts it in the beforeMarker
- * field.
+ * Creates a marker box for this primary box and puts it in the beforeMarker field.
*/
- private void createListMarker(LayoutContext context) {
+ private void createListMarker(final LayoutContext context) {
- Styles styles = context.getStyleSheet().getStyles(this.getElement());
+ final Styles styles = context.getStyleSheet().getStyles(getElement());
InlineBox markerInline;
- String type = styles.getListStyleType();
+ final String type = styles.getListStyleType();
if (type.equals(CSS.NONE)) {
return;
} else if (type.equals(CSS.CIRCLE)) {
- markerInline = createCircleBullet(this.getElement(), styles);
+ markerInline = createCircleBullet(getElement(), styles);
} else if (type.equals(CSS.SQUARE)) {
- markerInline = createSquareBullet(this.getElement(), styles);
+ markerInline = createSquareBullet(getElement(), styles);
} else if (isEnumeratedListStyleType(type)) {
- String item = this.getItemNumberString(type);
- markerInline = new StaticTextBox(context, this.getElement(), item + ".");
+ final String item = getItemNumberString(type);
+ markerInline = new StaticTextBox(context, getElement(), item + ".");
} else {
- markerInline = createDiscBullet(this.getElement(), styles);
+ markerInline = createDiscBullet(getElement(), styles);
}
- this.beforeMarker = ParagraphBox.create(context, this.getElement(), new InlineBox[] { markerInline }, Integer.MAX_VALUE);
+ beforeMarker = ParagraphBox.create(context, getElement(), new InlineBox[] { markerInline }, Integer.MAX_VALUE);
}
/**
* Returns a Drawable that draws a circle-style list item bullet.
*/
- private static InlineBox createCircleBullet(Element element, Styles styles) {
+ private static InlineBox createCircleBullet(final Element element, final Styles styles) {
final int size = Math.round(0.5f * styles.getFontSize());
final int lift = Math.round(0.1f * styles.getFontSize());
- Drawable drawable = new Drawable() {
- public void draw(Graphics g, int x, int y) {
+ final Drawable drawable = new Drawable() {
+ public void draw(final Graphics g, final int x, final int y) {
g.setLineStyle(Graphics.LINE_SOLID);
g.setLineWidth(1);
g.drawOval(x, y - size - lift, size, size);
@@ -242,11 +248,11 @@ public class BlockElementBox extends AbstractBlockBox {
/**
* Returns a Drawable that draws a disc-style list item bullet.
*/
- private static InlineBox createDiscBullet(Element element, Styles styles) {
+ private static InlineBox createDiscBullet(final Element element, final Styles styles) {
final int size = Math.round(0.5f * styles.getFontSize());
final int lift = Math.round(0.1f * styles.getFontSize());
- Drawable drawable = new Drawable() {
- public void draw(Graphics g, int x, int y) {
+ final Drawable drawable = new Drawable() {
+ public void draw(final Graphics g, final int x, final int y) {
g.fillOval(x, y - size - lift, size, size);
}
@@ -260,11 +266,11 @@ public class BlockElementBox extends AbstractBlockBox {
/**
* Returns a Drawable that draws a square-style list item bullet.
*/
- private static InlineBox createSquareBullet(Element element, Styles styles) {
+ private static InlineBox createSquareBullet(final Element element, final Styles styles) {
final int size = Math.round(0.5f * styles.getFontSize());
final int lift = Math.round(0.1f * styles.getFontSize());
- Drawable drawable = new Drawable() {
- public void draw(Graphics g, int x, int y) {
+ final Drawable drawable = new Drawable() {
+ public void draw(final Graphics g, final int x, final int y) {
g.setLineStyle(Graphics.LINE_SOLID);
g.setLineWidth(1);
g.drawRect(x, y - size - lift, size, size);
@@ -278,13 +284,12 @@ public class BlockElementBox extends AbstractBlockBox {
}
/**
- * Returns the vertical distance from the top of this box to the top of its
- * first line.
+ * Returns the vertical distance from the top of this box to the top of its first line.
*/
- int getFirstLineTop(LayoutContext context) {
- Styles styles = context.getStyleSheet().getStyles(this.getElement());
- int top = styles.getBorderTopWidth() + styles.getPaddingTop().get(0);
- Box[] children = this.getChildren();
+ int getFirstLineTop(final LayoutContext context) {
+ final Styles styles = context.getStyleSheet().getStyles(getElement());
+ final int top = styles.getBorderTopWidth() + styles.getPaddingTop().get(0);
+ final Box[] children = getChildren();
if (children != null && children.length > 0 && children[0] instanceof BlockElementBox) {
return top + ((BlockElementBox) children[0]).getFirstLineTop(context);
} else {
@@ -293,20 +298,19 @@ public class BlockElementBox extends AbstractBlockBox {
}
/**
- * Returns the item number of this box. The item number indicates the
- * ordinal number of the corresponding element amongst its siblings starting
- * with 1.
+ * Returns the item number of this box. The item number indicates the ordinal number of the corresponding element
+ * amongst its siblings starting with 1.
*/
private int getItemNumber() {
- Element element = this.getElement();
- Element parent = element.getParent();
+ final Element element = getElement();
+ final Element parent = element.getParent();
if (parent == null) {
return 1;
}
int item = 1;
- List<Element> children = parent.getChildElements();
+ final List<Element> children = parent.getChildElements();
for (int i = 0; i < children.size(); i++) {
if (children.get(i) == element) {
return item;
@@ -319,8 +323,8 @@ public class BlockElementBox extends AbstractBlockBox {
throw new IllegalStateException();
}
- private String getItemNumberString(String style) {
- int item = getItemNumber();
+ private String getItemNumberString(final String style) {
+ final int item = getItemNumber();
if (style.equals(CSS.DECIMAL_LEADING_ZERO)) {
if (item < 10) {
return "0" + Integer.toString(item);
@@ -328,42 +332,41 @@ public class BlockElementBox extends AbstractBlockBox {
return Integer.toString(item);
}
} else if (style.equals(CSS.LOWER_ALPHA) || style.equals(CSS.LOWER_LATIN)) {
- return this.getAlpha(item);
+ return getAlpha(item);
} else if (style.equals(CSS.LOWER_ROMAN)) {
- return this.getRoman(item);
+ return getRoman(item);
} else if (style.equals(CSS.UPPER_ALPHA) || style.equals(CSS.UPPER_LATIN)) {
- return this.getAlpha(item).toUpperCase();
+ return getAlpha(item).toUpperCase();
} else if (style.equals(CSS.UPPER_ROMAN)) {
- return this.getRoman(item).toUpperCase();
+ return getRoman(item).toUpperCase();
} else {
return Integer.toString(item);
}
}
- private String getAlpha(int n) {
+ private String getAlpha(final int n) {
final String alpha = "abcdefghijklmnopqrstuvwxyz";
return String.valueOf(alpha.charAt((n - 1) % 26));
}
- private String getRoman(int n) {
+ private String getRoman(final int n) {
final String[] ones = { "", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix" };
final String[] tens = { "", "x", "xx", "xxx", "xl", "l", "lx", "lxx", "lxxx", "xc" };
final String[] hundreds = { "", "c", "cc", "ccc", "cd", "d", "dc", "dcc", "dccc", "cm" };
- StringBuffer sb = new StringBuffer();
+ final StringBuffer sb = new StringBuffer();
for (int i = 0; i < n / 1000; i++) {
sb.append("m");
}
- sb.append(hundreds[(n / 100) % 10]);
- sb.append(tens[(n / 10) % 10]);
+ sb.append(hundreds[n / 100 % 10]);
+ sb.append(tens[n / 10 % 10]);
sb.append(ones[n % 10]);
return sb.toString();
}
- private static boolean isEnumeratedListStyleType(String s) {
- return s.equals(CSS.ARMENIAN) || s.equals(CSS.CJK_IDEOGRAPHIC) || s.equals(CSS.DECIMAL) || s.equals(CSS.DECIMAL_LEADING_ZERO) || s.equals(CSS.GEORGIAN)
- || s.equals(CSS.HEBREW) || s.equals(CSS.HIRAGANA) || s.equals(CSS.HIRAGANA_IROHA) || s.equals(CSS.KATAKANA) || s.equals(CSS.KATAKANA_IROHA)
- || s.equals(CSS.LOWER_ALPHA) || s.equals(CSS.LOWER_GREEK) || s.equals(CSS.LOWER_LATIN) || s.equals(CSS.LOWER_ROMAN)
- || s.equals(CSS.UPPER_ALPHA) || s.equals(CSS.UPPER_LATIN) || s.equals(CSS.UPPER_ROMAN);
+ private static boolean isEnumeratedListStyleType(final String s) {
+ return s.equals(CSS.ARMENIAN) || s.equals(CSS.CJK_IDEOGRAPHIC) || s.equals(CSS.DECIMAL) || s.equals(CSS.DECIMAL_LEADING_ZERO) || s.equals(CSS.GEORGIAN) || s.equals(CSS.HEBREW)
+ || s.equals(CSS.HIRAGANA) || s.equals(CSS.HIRAGANA_IROHA) || s.equals(CSS.KATAKANA) || s.equals(CSS.KATAKANA_IROHA) || s.equals(CSS.LOWER_ALPHA) || s.equals(CSS.LOWER_GREEK)
+ || s.equals(CSS.LOWER_LATIN) || s.equals(CSS.LOWER_ROMAN) || s.equals(CSS.UPPER_ALPHA) || s.equals(CSS.UPPER_LATIN) || s.equals(CSS.UPPER_ROMAN);
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BlockPseudoElementBox.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BlockPseudoElementBox.java
index 53d38318..f993e745 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BlockPseudoElementBox.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BlockPseudoElementBox.java
@@ -22,41 +22,34 @@ import org.eclipse.vex.core.internal.dom.Element;
*/
public class BlockPseudoElementBox extends AbstractBox implements BlockBox {
- private Element pseudoElement;
- private BlockBox parent;
- private ParagraphBox para;
+ private final Element pseudoElement;
+ private final BlockBox parent;
+ private final ParagraphBox para;
- private int marginTop;
- private int marginBottom;
+ private final int marginTop;
+ private final int marginBottom;
- public BlockPseudoElementBox(LayoutContext context, Element pseudoElement,
- BlockBox parent, int width) {
+ public BlockPseudoElementBox(final LayoutContext context, final Element pseudoElement, final BlockBox parent, final int width) {
this.pseudoElement = pseudoElement;
this.parent = parent;
- Styles styles = context.getStyleSheet().getStyles(pseudoElement);
+ final Styles styles = context.getStyleSheet().getStyles(pseudoElement);
- this.marginTop = styles.getMarginTop().get(width);
- this.marginBottom = styles.getMarginBottom().get(width);
+ marginTop = styles.getMarginTop().get(width);
+ marginBottom = styles.getMarginBottom().get(width);
- int leftInset = styles.getMarginLeft().get(width)
- + styles.getBorderLeftWidth()
- + styles.getPaddingLeft().get(width);
- int rightInset = styles.getMarginRight().get(width)
- + styles.getBorderRightWidth()
- + styles.getPaddingRight().get(width);
+ final int leftInset = styles.getMarginLeft().get(width) + styles.getBorderLeftWidth() + styles.getPaddingLeft().get(width);
+ final int rightInset = styles.getMarginRight().get(width) + styles.getBorderRightWidth() + styles.getPaddingRight().get(width);
- int childWidth = width - leftInset - rightInset;
- List<InlineBox> inlines = LayoutUtils.createGeneratedInlines(context,
- pseudoElement);
- this.para = ParagraphBox.create(context, pseudoElement, inlines,
- childWidth);
+ final int childWidth = width - leftInset - rightInset;
+ final List<InlineBox> inlines = LayoutUtils.createGeneratedInlines(context, pseudoElement);
+ para = ParagraphBox.create(context, pseudoElement, inlines, childWidth);
- this.para.setX(0);
- this.para.setY(0);
- this.setWidth(width - leftInset - rightInset);
- this.setHeight(this.para.getHeight());
+ para.setX(0);
+ para.setY(0);
+ setWidth(width - leftInset - rightInset);
+ setHeight(para.getHeight());
}
/**
@@ -64,15 +57,17 @@ public class BlockPseudoElementBox extends AbstractBox implements BlockBox {
*
* @see org.eclipse.vex.core.internal.layout.Box#getChildren()
*/
+ @Override
public Box[] getChildren() {
- return new Box[] { this.para };
+ return new Box[] { para };
}
/**
* @see org.eclipse.vex.core.internal.layout.Box#getElement()
*/
+ @Override
public Element getElement() {
- return this.pseudoElement;
+ return pseudoElement;
}
/**
@@ -92,30 +87,30 @@ public class BlockPseudoElementBox extends AbstractBox implements BlockBox {
/**
* @see org.eclipse.vex.core.internal.layout.BlockBox#getLineEndOffset(int)
*/
- public int getLineEndOffset(int offset) {
+ public int getLineEndOffset(final int offset) {
throw new IllegalStateException();
}
/**
* @see org.eclipse.vex.core.internal.layout.BlockBox#getLineStartOffset(int)
*/
- public int getLineStartOffset(int offset) {
+ public int getLineStartOffset(final int offset) {
throw new IllegalStateException();
}
public int getMarginBottom() {
- return this.marginBottom;
+ return marginBottom;
}
public int getMarginTop() {
- return this.marginTop;
+ return marginTop;
}
/**
* @see org.eclipse.vex.core.internal.layout.BlockBox#getNextLineOffset(org.eclipse.vex.core.internal.layout.LayoutContext,
* int, int)
*/
- public int getNextLineOffset(LayoutContext context, int offset, int x) {
+ public int getNextLineOffset(final LayoutContext context, final int offset, final int x) {
throw new IllegalStateException();
}
@@ -123,38 +118,37 @@ public class BlockPseudoElementBox extends AbstractBox implements BlockBox {
* Returns this box's parent.
*/
public BlockBox getParent() {
- return this.parent;
+ return parent;
}
/**
* @see org.eclipse.vex.core.internal.layout.BlockBox#getPreviousLineOffset(org.eclipse.vex.core.internal.layout.LayoutContext,
* int, int)
*/
- public int getPreviousLineOffset(LayoutContext context, int offset, int x) {
+ public int getPreviousLineOffset(final LayoutContext context, final int offset, final int x) {
throw new IllegalStateException();
}
- public IntRange layout(LayoutContext context, int top, int bottom) {
+ public IntRange layout(final LayoutContext context, final int top, final int bottom) {
return null;
}
- public void invalidate(boolean direct) {
- throw new IllegalStateException(
- "invalidate called on a non-element BlockBox");
+ public void invalidate(final boolean direct) {
+ throw new IllegalStateException("invalidate called on a non-element BlockBox");
}
/**
* Draw boxes before painting our child.
*
- * @see org.eclipse.vex.core.internal.layout.Box#paint(org.eclipse.vex.core.internal.layout.LayoutContext,
- * int, int)
+ * @see org.eclipse.vex.core.internal.layout.Box#paint(org.eclipse.vex.core.internal.layout.LayoutContext, int, int)
*/
- public void paint(LayoutContext context, int x, int y) {
- this.drawBox(context, x, y, this.getParent().getWidth(), true);
+ @Override
+ public void paint(final LayoutContext context, final int x, final int y) {
+ this.drawBox(context, x, y, getParent().getWidth(), true);
super.paint(context, x, y);
}
- public void setInitialSize(LayoutContext context) {
+ public void setInitialSize(final LayoutContext context) {
// NOP - size calculated in the ctor
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/Box.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/Box.java
index ac8e7ca9..cb05b3e6 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/Box.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/Box.java
@@ -15,10 +15,9 @@ import org.eclipse.vex.core.internal.core.Insets;
import org.eclipse.vex.core.internal.dom.Element;
/**
- * Represents a rectangular area in the layout. The height and width of the box
- * are measured from the inner edges of the box's padding, as in CSS. Similarly,
- * the (x, y) position of the box are with respect to the inner top-left corner
- * of the box's padding, and are relative to the parent's (x, y) position.
+ * Represents a rectangular area in the layout. The height and width of the box are measured from the inner edges of the
+ * box's padding, as in CSS. Similarly, the (x, y) position of the box are with respect to the inner top-left corner of
+ * the box's padding, and are relative to the parent's (x, y) position.
*/
public interface Box {
@@ -46,9 +45,8 @@ public interface Box {
public Box[] getChildren();
/**
- * Returns the Element with which this box is associated, or null if there
- * is no such box. The box may directly represent the Element, or simply use
- * it for formatting information.
+ * Returns the Element with which this box is associated, or null if there is no such box. The box may directly
+ * represent the Element, or simply use it for formatting information.
*/
public Element getElement();
@@ -58,14 +56,13 @@ public interface Box {
public int getEndOffset();
/**
- * Returns the height of the box. For boxes subject to the CSS box model,
- * this is the inner height, exclusive of margins, borders, and padding.
+ * Returns the height of the box. For boxes subject to the CSS box model, this is the inner height, exclusive of
+ * margins, borders, and padding.
*/
public int getHeight();
/**
- * Return an Insets object representing the total width of margins, borders,
- * and padding for this box.
+ * Return an Insets object representing the total width of margins, borders, and padding for this box.
*
* @param context
* LayoutContext being used for this layout.
@@ -80,29 +77,26 @@ public interface Box {
public int getStartOffset();
/**
- * Returns the width of the box. For boxes subject to the CSS box model,
- * this is the inner width, exclusive of margins, borders, and padding.
+ * Returns the width of the box. For boxes subject to the CSS box model, this is the inner width, exclusive of
+ * margins, borders, and padding.
*/
public int getWidth();
/**
- * Returns the x-coordinate of the box, relative to its parent. For boxes
- * subject to the CSS box model, this is the left edge of the box's content
- * area.
+ * Returns the x-coordinate of the box, relative to its parent. For boxes subject to the CSS box model, this is the
+ * left edge of the box's content area.
*/
public int getX();
/**
- * Returns the y-coordinate of the box, relative to its parent. For boxes
- * subject to the CSS box model, this is the top edge of the box's content
- * area.
+ * Returns the y-coordinate of the box, relative to its parent. For boxes subject to the CSS box model, this is the
+ * top edge of the box's content area.
*/
public int getY();
/**
- * Returns true if this box represents a portion of the XML document's
- * content. If false is returned, the following methods are not supported by
- * this box.
+ * Returns true if this box represents a portion of the XML document's content. If false is returned, the following
+ * methods are not supported by this box.
*
* <ul>
* <li>getCaretShapes()</li>
@@ -114,8 +108,7 @@ public interface Box {
public boolean hasContent();
/**
- * Returns true if the box is anonymous, that is, it is not directly
- * associated with an element.
+ * Returns true if the box is anonymous, that is, it is not directly associated with an element.
*/
public boolean isAnonymous();
@@ -123,8 +116,7 @@ public interface Box {
* Draws the box's content in the given Graphics context.
*
* @param context
- * <code>LayoutContext</code> containing the
- * <code>Graphics</code> object into which the box should be
+ * <code>LayoutContext</code> containing the <code>Graphics</code> object into which the box should be
* painted
* @param x
* the x-offset at which the box should be painted
@@ -171,11 +163,9 @@ public interface Box {
* @param context
* <code>LayoutContext</code> for this box tree
* @param x
- * x offset of the view position for which the model offset is to
- * be determined.
+ * x offset of the view position for which the model offset is to be determined.
* @param y
- * y offset of the view position for which the model offset is to
- * be determined.
+ * y offset of the view position for which the model offset is to be determined.
*/
public int viewToModel(LayoutContext context, int x, int y);
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BoxFactory.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BoxFactory.java
index 33625184..b2b3413a 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BoxFactory.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/BoxFactory.java
@@ -15,8 +15,7 @@ import java.io.Serializable;
import org.eclipse.vex.core.internal.dom.Element;
/**
- * Interface to an object that creates boxes from elements. Implementations of
- * this interface must be serializable.
+ * Interface to an object that creates boxes from elements. Implementations of this interface must be serializable.
*/
public interface BoxFactory extends Serializable {
@@ -32,7 +31,6 @@ public interface BoxFactory extends Serializable {
* @param containerWidth
* Width of the box to be created.
*/
- public Box createBox(LayoutContext context, Element element,
- BlockBox parent, int containerWidth);
+ public Box createBox(LayoutContext context, Element element, BlockBox parent, int containerWidth);
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/CommentBlockElementBox.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/CommentBlockElementBox.java
index cf4e5b66..655763f3 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/CommentBlockElementBox.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/CommentBlockElementBox.java
@@ -31,8 +31,9 @@ public class CommentBlockElementBox extends BlockElementBox {
@Override
public List<Box> createChildren(final LayoutContext context) {
long start = 0;
- if (VEXCorePlugin.getInstance().isDebugging())
+ if (VEXCorePlugin.getInstance().isDebugging()) {
start = System.currentTimeMillis();
+ }
final Element element = getElement();
final int width = getWidth();
@@ -54,8 +55,9 @@ public class CommentBlockElementBox extends BlockElementBox {
if (VEXCorePlugin.getInstance().isDebugging()) {
final long end = System.currentTimeMillis();
- if (end - start > 10)
+ if (end - start > 10) {
System.out.println("CommentBlockElementBox.layout for " + getElement().getPrefixedName() + " took " + (end - start) + "ms");
+ }
}
return childList;
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/CompositeInlineBox.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/CompositeInlineBox.java
index ebcb6ce9..b2d50028 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/CompositeInlineBox.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/CompositeInlineBox.java
@@ -23,18 +23,19 @@ import org.eclipse.vex.core.internal.core.Graphics;
import org.eclipse.vex.core.internal.css.Styles;
/**
- * InlineBox consisting of several children. This is the parent class of
- * InlineElementBox and LineBox, and implements the split method.
+ * InlineBox consisting of several children. This is the parent class of InlineElementBox and LineBox, and implements
+ * the split method.
*/
public abstract class CompositeInlineBox extends AbstractInlineBox {
/**
* Returns true if any of the children have content.
*/
+ @Override
public boolean hasContent() {
- Box[] children = this.getChildren();
- for (int i = 0; i < children.length; i++) {
- if (children[i].hasContent()) {
+ final Box[] children = getChildren();
+ for (final Box element : children) {
+ if (element.hasContent()) {
return true;
}
}
@@ -42,19 +43,18 @@ public abstract class CompositeInlineBox extends AbstractInlineBox {
}
public boolean isEOL() {
- Box[] children = this.getChildren();
- return children.length > 0
- && ((InlineBox) children[children.length - 1]).isEOL();
+ final Box[] children = getChildren();
+ return children.length > 0 && ((InlineBox) children[children.length - 1]).isEOL();
}
/**
- * @see org.eclipse.vex.core.internal.layout.Box#getCaret(org.eclipse.vex.core.internal.layout.LayoutContext,
- * int)
+ * @see org.eclipse.vex.core.internal.layout.Box#getCaret(org.eclipse.vex.core.internal.layout.LayoutContext, int)
*/
- public Caret getCaret(LayoutContext context, int offset) {
+ @Override
+ public Caret getCaret(final LayoutContext context, final int offset) {
int x = 0;
- Box[] children = this.getChildren();
+ final Box[] children = getChildren();
// we want the caret to be to the right of any leading static boxes...
int start = 0;
@@ -70,12 +70,12 @@ public abstract class CompositeInlineBox extends AbstractInlineBox {
}
for (int i = start; i < end; i++) {
- Box child = children[i];
+ final Box child = children[i];
if (child.hasContent()) {
if (offset < child.getStartOffset()) {
break;
} else if (offset <= child.getEndOffset()) {
- Caret caret = child.getCaret(context, offset);
+ final Caret caret = child.getCaret(context, offset);
caret.translate(child.getX(), child.getY());
return caret;
}
@@ -83,18 +83,18 @@ public abstract class CompositeInlineBox extends AbstractInlineBox {
x += child.getWidth();
}
- Graphics g = context.getGraphics();
- Styles styles = context.getStyleSheet().getStyles(this.getElement());
+ final Graphics g = context.getGraphics();
+ final Styles styles = context.getStyleSheet().getStyles(getElement());
- FontResource font = g.createFont(styles.getFont());
- FontResource oldFont = g.setFont(font);
- FontMetrics fm = g.getFontMetrics();
- int height = fm.getAscent() + fm.getDescent();
+ final FontResource font = g.createFont(styles.getFont());
+ final FontResource oldFont = g.setFont(font);
+ final FontMetrics fm = g.getFontMetrics();
+ final int height = fm.getAscent() + fm.getDescent();
g.setFont(oldFont);
font.dispose();
- int lineHeight = styles.getLineHeight();
- int y = (lineHeight - height) / 2;
+ final int lineHeight = styles.getLineHeight();
+ final int y = (lineHeight - height) / 2;
return new TextCaret(x, y, height);
}
@@ -102,25 +102,24 @@ public abstract class CompositeInlineBox extends AbstractInlineBox {
* @see org.eclipse.vex.core.internal.layout.InlineBox#split(org.eclipse.vex.core.internal.layout.LayoutContext,
* int, boolean)
*/
- public Pair split(LayoutContext context, int maxWidth, boolean force) {
+ public Pair split(final LayoutContext context, final int maxWidth, final boolean force) {
// list of children that have yet to be added to the left side
- LinkedList<Box> rights = new LinkedList<Box>(Arrays.asList(this.getChildren()));
+ final LinkedList<Box> rights = new LinkedList<Box>(Arrays.asList(getChildren()));
// pending is a list of inlines we are trying to add to the left side
// but which cannot end at a split
- List<InlineBox> pending = new ArrayList<InlineBox>();
+ final List<InlineBox> pending = new ArrayList<InlineBox>();
// list of inlines that make up the left side
- List<InlineBox> lefts = new ArrayList<InlineBox>();
+ final List<InlineBox> lefts = new ArrayList<InlineBox>();
int remaining = maxWidth;
boolean eol = false;
while (!rights.isEmpty() && remaining >= 0) {
- InlineBox inline = (InlineBox) rights.removeFirst();
- InlineBox.Pair pair = inline.split(context, remaining, force
- && lefts.isEmpty());
+ final InlineBox inline = (InlineBox) rights.removeFirst();
+ final InlineBox.Pair pair = inline.split(context, remaining, force && lefts.isEmpty());
if (pair.getLeft() != null) {
lefts.addAll(pending);
@@ -141,14 +140,14 @@ public abstract class CompositeInlineBox extends AbstractInlineBox {
}
- if (((force && lefts.isEmpty()) || remaining >= 0) && !eol) {
+ if ((force && lefts.isEmpty() || remaining >= 0) && !eol) {
lefts.addAll(pending);
} else {
rights.addAll(0, pending);
}
- InlineBox[] leftKids = lefts.toArray(new InlineBox[lefts.size()]);
- InlineBox[] rightKids = rights.toArray(new InlineBox[rights.size()]);
+ final InlineBox[] leftKids = lefts.toArray(new InlineBox[lefts.size()]);
+ final InlineBox[] rightKids = rights.toArray(new InlineBox[rights.size()]);
return this.split(context, leftKids, rightKids);
}
@@ -163,25 +162,23 @@ public abstract class CompositeInlineBox extends AbstractInlineBox {
* Child boxes to be given to the right box.
* @return
*/
- protected abstract Pair split(LayoutContext context, InlineBox[] lefts,
- InlineBox[] rights);
+ protected abstract Pair split(LayoutContext context, InlineBox[] lefts, InlineBox[] rights);
/**
* @see org.eclipse.vex.core.internal.layout.Box#viewToModel(org.eclipse.vex.core.internal.layout.LayoutContext,
* int, int)
*/
- public int viewToModel(LayoutContext context, int x, int y) {
+ @Override
+ public int viewToModel(final LayoutContext context, final int x, final int y) {
- if (!this.hasContent()) {
- throw new RuntimeException(
- "Oops. Calling viewToModel on a line with no content");
+ if (!hasContent()) {
+ throw new RuntimeException("Oops. Calling viewToModel on a line with no content");
}
Box closestContentChild = null;
int delta = Integer.MAX_VALUE;
- Box[] children = this.getChildren();
- for (int i = 0; i < children.length; i++) {
- Box child = children[i];
+ final Box[] children = getChildren();
+ for (final Box child : children) {
if (child.hasContent()) {
int newDelta = 0;
if (x < child.getX()) {
@@ -196,8 +193,7 @@ public abstract class CompositeInlineBox extends AbstractInlineBox {
}
}
- return closestContentChild.viewToModel(context, x
- - closestContentChild.getX(), y - closestContentChild.getY());
+ return closestContentChild.viewToModel(context, x - closestContentChild.getX(), y - closestContentChild.getY());
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/CssBoxFactory.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/CssBoxFactory.java
index 8934b647..9298d70e 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/CssBoxFactory.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/CssBoxFactory.java
@@ -16,8 +16,7 @@ import org.eclipse.vex.core.internal.dom.CommentElement;
import org.eclipse.vex.core.internal.dom.Element;
/**
- * Implementation of the BoxFactory interface that returns boxes that represent
- * CSS semantics.
+ * Implementation of the BoxFactory interface that returns boxes that represent CSS semantics.
*/
public class CssBoxFactory implements BoxFactory {
@@ -25,14 +24,15 @@ public class CssBoxFactory implements BoxFactory {
public Box createBox(final LayoutContext context, final Element element, final BlockBox parent, final int containerWidth) {
final Styles styles = context.getStyleSheet().getStyles(element);
- if (element instanceof CommentElement)
+ if (element instanceof CommentElement) {
return new CommentBlockElementBox(context, parent, element);
- else if (styles.getDisplay().equals(CSS.TABLE))
+ } else if (styles.getDisplay().equals(CSS.TABLE)) {
return new TableBox(context, parent, element);
- else if (styles.isBlock())
+ } else if (styles.isBlock()) {
return new BlockElementBox(context, parent, element);
- else
+ } else {
throw new RuntimeException("Unexpected display property: " + styles.getDisplay());
+ }
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/DocumentTextBox.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/DocumentTextBox.java
index 62aedc6d..fc653835 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/DocumentTextBox.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/DocumentTextBox.java
@@ -19,13 +19,12 @@ import org.eclipse.vex.core.internal.dom.Element;
import org.eclipse.vex.core.internal.dom.Text;
/**
- * A TextBox that gets its text from the document. Represents text which is
- * editable within the VexWidget.
+ * A TextBox that gets its text from the document. Represents text which is editable within the VexWidget.
*/
public class DocumentTextBox extends TextBox {
- private int startRelative;
- private int endRelative;
+ private final int startRelative;
+ private final int endRelative;
/**
* Class constructor, accepting a Text object.
@@ -36,7 +35,7 @@ public class DocumentTextBox extends TextBox {
* Element being used
* @param text
*/
- public DocumentTextBox(LayoutContext context, Element element, Text text) {
+ public DocumentTextBox(final LayoutContext context, final Element element, final Text text) {
this(context, element, text.getStartOffset(), text.getEndOffset());
}
@@ -52,20 +51,18 @@ public class DocumentTextBox extends TextBox {
* @param endOffset
* end offset of the text
*/
- public DocumentTextBox(LayoutContext context, Element element,
- int startOffset, int endOffset) {
+ public DocumentTextBox(final LayoutContext context, final Element element, final int startOffset, final int endOffset) {
super(element);
if (startOffset >= endOffset) {
- throw new IllegalStateException("DocumentTextBox: startOffset ("
- + startOffset + ") >= endOffset (" + endOffset + ")");
+ throw new IllegalStateException("DocumentTextBox: startOffset (" + startOffset + ") >= endOffset (" + endOffset + ")");
}
- this.startRelative = startOffset - element.getStartOffset();
- this.endRelative = endOffset - element.getStartOffset();
- this.calculateSize(context);
+ startRelative = startOffset - element.getStartOffset();
+ endRelative = endOffset - element.getStartOffset();
+ calculateSize(context);
- if (this.getText().length() < (endOffset - startOffset)) {
+ if (getText().length() < endOffset - startOffset) {
throw new IllegalStateException();
}
}
@@ -73,60 +70,64 @@ public class DocumentTextBox extends TextBox {
/**
* @see org.eclipse.vex.core.internal.layout.Box#getEndOffset()
*/
+ @Override
public int getEndOffset() {
- if (this.endRelative == -1) {
+ if (endRelative == -1) {
return -1;
} else {
- return this.getElement().getStartOffset() + this.endRelative - 1;
+ return getElement().getStartOffset() + endRelative - 1;
}
}
/**
* @see org.eclipse.vex.core.internal.layout.Box#getStartOffset()
*/
+ @Override
public int getStartOffset() {
- if (this.startRelative == -1) {
+ if (startRelative == -1) {
return -1;
} else {
- return this.getElement().getStartOffset() + this.startRelative;
+ return getElement().getStartOffset() + startRelative;
}
}
/**
* @see org.eclipse.vex.core.internal.layout.TextBox#getText()
*/
+ @Override
public String getText() {
- Document doc = this.getElement().getDocument();
- return doc.getText(this.getStartOffset(), this.getEndOffset() + 1);
+ final Document doc = getElement().getDocument();
+ return doc.getText(getStartOffset(), getEndOffset() + 1);
}
/**
* @see org.eclipse.vex.core.internal.layout.Box#hasContent()
*/
+ @Override
public boolean hasContent() {
return true;
}
/**
- * @see org.eclipse.vex.core.internal.layout.Box#paint(org.eclipse.vex.core.internal.layout.LayoutContext,
- * int, int)
+ * @see org.eclipse.vex.core.internal.layout.Box#paint(org.eclipse.vex.core.internal.layout.LayoutContext, int, int)
*/
- public void paint(LayoutContext context, int x, int y) {
+ @Override
+ public void paint(final LayoutContext context, final int x, final int y) {
- Styles styles = context.getStyleSheet().getStyles(this.getElement());
- Graphics g = context.getGraphics();
+ final Styles styles = context.getStyleSheet().getStyles(getElement());
+ final Graphics g = context.getGraphics();
- FontResource font = g.createFont(styles.getFont());
- FontResource oldFont = g.setFont(font);
- ColorResource foreground = g.createColor(styles.getColor());
- ColorResource oldForeground = g.setColor(foreground);
+ final FontResource font = g.createFont(styles.getFont());
+ final FontResource oldFont = g.setFont(font);
+ final ColorResource foreground = g.createColor(styles.getColor());
+ final ColorResource oldForeground = g.setColor(foreground);
// ColorResource background =
// g.createColor(styles.getBackgroundColor());
// ColorResource oldBackground = g.setBackgroundColor(background);
- char[] chars = this.getText().toCharArray();
+ final char[] chars = getText().toCharArray();
- if (chars.length < this.getEndOffset() - this.getStartOffset()) {
+ if (chars.length < getEndOffset() - getStartOffset()) {
throw new IllegalStateException();
}
@@ -134,36 +135,36 @@ public class DocumentTextBox extends TextBox {
throw new IllegalStateException();
}
- int start = 0;
+ final int start = 0;
int end = chars.length;
if (chars[end - 1] == NEWLINE_CHAR) {
end--;
}
- int selStart = context.getSelectionStart() - this.getStartOffset();
+ int selStart = context.getSelectionStart() - getStartOffset();
selStart = Math.min(Math.max(selStart, start), end);
- int selEnd = context.getSelectionEnd() - this.getStartOffset();
+ int selEnd = context.getSelectionEnd() - getStartOffset();
selEnd = Math.min(Math.max(selEnd, start), end);
// text before selection
if (start < selStart) {
g.drawChars(chars, start, selStart - start, x, y);
- String s = new String(chars, start, selStart - start);
+ final String s = new String(chars, start, selStart - start);
paintTextDecoration(context, styles, s, x, y);
}
// text after selection
if (selEnd < end) {
- int x1 = x + g.charsWidth(chars, 0, selEnd);
+ final int x1 = x + g.charsWidth(chars, 0, selEnd);
g.drawChars(chars, selEnd, end - selEnd, x1, y);
- String s = new String(chars, selEnd, end - selEnd);
+ final String s = new String(chars, selEnd, end - selEnd);
paintTextDecoration(context, styles, s, x1, y);
}
// text within selection
if (selStart < selEnd) {
- String s = new String(chars, selStart, selEnd - selStart);
- int x1 = x + g.charsWidth(chars, 0, selStart);
- this.paintSelectedText(context, s, x1, y);
+ final String s = new String(chars, selStart, selEnd - selStart);
+ final int x1 = x + g.charsWidth(chars, 0, selStart);
+ paintSelectedText(context, s, x1, y);
paintTextDecoration(context, styles, s, x1, y);
}
@@ -178,28 +179,27 @@ public class DocumentTextBox extends TextBox {
/**
* @see org.eclipse.vex.core.internal.layout.TextBox#splitAt(int)
*/
- public Pair splitAt(LayoutContext context, int offset) {
+ @Override
+ public Pair splitAt(final LayoutContext context, final int offset) {
- if (offset < 0 || offset > (this.endRelative - this.startRelative)) {
+ if (offset < 0 || offset > endRelative - startRelative) {
throw new IllegalStateException();
}
- int split = this.getStartOffset() + offset;
+ final int split = getStartOffset() + offset;
DocumentTextBox left;
if (offset == 0) {
left = null;
} else {
- left = new DocumentTextBox(context, this.getElement(), this
- .getStartOffset(), split);
+ left = new DocumentTextBox(context, getElement(), getStartOffset(), split);
}
InlineBox right;
- if (split == this.getEndOffset() + 1) {
+ if (split == getEndOffset() + 1) {
right = null;
} else {
- right = new DocumentTextBox(context, this.getElement(), split, this
- .getEndOffset() + 1);
+ right = new DocumentTextBox(context, getElement(), split, getEndOffset() + 1);
}
return new Pair(left, right);
}
@@ -208,20 +208,21 @@ public class DocumentTextBox extends TextBox {
* @see org.eclipse.vex.core.internal.layout.Box#viewToModel(org.eclipse.vex.core.internal.layout.LayoutContext,
* int, int)
*/
- public int viewToModel(LayoutContext context, int x, int y) {
+ @Override
+ public int viewToModel(final LayoutContext context, final int x, final int y) {
- Graphics g = context.getGraphics();
- Styles styles = context.getStyleSheet().getStyles(this.getElement());
- FontResource font = g.createFont(styles.getFont());
- FontResource oldFont = g.setFont(font);
- char[] chars = this.getText().toCharArray();
+ final Graphics g = context.getGraphics();
+ final Styles styles = context.getStyleSheet().getStyles(getElement());
+ final FontResource font = g.createFont(styles.getFont());
+ final FontResource oldFont = g.setFont(font);
+ final char[] chars = getText().toCharArray();
- if (this.getWidth() <= 0) {
- return this.getStartOffset();
+ if (getWidth() <= 0) {
+ return getStartOffset();
}
// first, get an estimate based on x / width
- int offset = (x / this.getWidth()) * chars.length;
+ int offset = x / getWidth() * chars.length;
offset = Math.max(0, offset);
offset = Math.min(chars.length, offset);
@@ -229,7 +230,7 @@ public class DocumentTextBox extends TextBox {
// Search backwards
while (offset > 0) {
- int newDelta = Math.abs(x - g.charsWidth(chars, 0, offset - 1));
+ final int newDelta = Math.abs(x - g.charsWidth(chars, 0, offset - 1));
if (newDelta > delta) {
break;
}
@@ -239,7 +240,7 @@ public class DocumentTextBox extends TextBox {
// Search forwards
while (offset < chars.length - 1) {
- int newDelta = Math.abs(x - g.charsWidth(chars, 0, offset + 1));
+ final int newDelta = Math.abs(x - g.charsWidth(chars, 0, offset + 1));
if (newDelta > delta) {
break;
}
@@ -249,7 +250,7 @@ public class DocumentTextBox extends TextBox {
g.setFont(oldFont);
font.dispose();
- return this.getStartOffset() + offset;
+ return getStartOffset() + offset;
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/DrawableBox.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/DrawableBox.java
index 825896f4..63438da6 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/DrawableBox.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/DrawableBox.java
@@ -20,9 +20,8 @@ import org.eclipse.vex.core.internal.css.Styles;
import org.eclipse.vex.core.internal.dom.Element;
/**
- * An inline box that draws a Drawable object. The drawable is drawn relative to
- * the text baseline, therefore it should draw using mostly negative
- * y-coordinates.
+ * An inline box that draws a Drawable object. The drawable is drawn relative to the text baseline, therefore it should
+ * draw using mostly negative y-coordinates.
*/
public class DrawableBox extends AbstractInlineBox {
@@ -30,9 +29,9 @@ public class DrawableBox extends AbstractInlineBox {
public static final byte START_MARKER = 1;
public static final byte END_MARKER = 2;
- private Drawable drawable;
- private Element element;
- private byte marker;
+ private final Drawable drawable;
+ private final Element element;
+ private final byte marker;
/**
* Class constructor.
@@ -42,29 +41,28 @@ public class DrawableBox extends AbstractInlineBox {
* @param element2
* Element whose styles determine the color of the drawable.
*/
- public DrawableBox(Drawable drawable, Element element2) {
+ public DrawableBox(final Drawable drawable, final Element element2) {
this(drawable, element2, NO_MARKER);
}
/**
- * Class constructor. This constructor is called when creating a DrawableBox
- * that represents the start or end marker of an inline element.
+ * Class constructor. This constructor is called when creating a DrawableBox that represents the start or end marker
+ * of an inline element.
*
* @param drawable
* Drawable to draw.
* @param element2
* Element whose styles determine the color of the drawable.
* @param marker
- * which marker should be drawn. Must be one of NO_MARKER,
- * START_MARKER, or END_MARKER.
+ * which marker should be drawn. Must be one of NO_MARKER, START_MARKER, or END_MARKER.
*/
- public DrawableBox(Drawable drawable, Element element2, byte marker) {
+ public DrawableBox(final Drawable drawable, final Element element2, final byte marker) {
this.drawable = drawable;
- this.element = element2;
+ element = element2;
this.marker = marker;
- Rectangle bounds = drawable.getBounds();
- this.setWidth(bounds.getWidth());
- this.setHeight(bounds.getHeight());
+ final Rectangle bounds = drawable.getBounds();
+ setWidth(bounds.getWidth());
+ setHeight(bounds.getHeight());
}
/**
@@ -77,8 +75,9 @@ public class DrawableBox extends AbstractInlineBox {
/**
* Returns the element that controls the styling for this text element.
*/
+ @Override
public Element getElement() {
- return this.element;
+ return element;
}
public boolean isEOL() {
@@ -89,49 +88,43 @@ public class DrawableBox extends AbstractInlineBox {
* @see org.eclipse.vex.core.internal.layout.InlineBox#split(org.eclipse.vex.core.internal.layout.LayoutContext,
* int, boolean)
*/
- public Pair split(LayoutContext context, int maxWidth, boolean force) {
+ public Pair split(final LayoutContext context, final int maxWidth, final boolean force) {
return new Pair(null, this);
}
/**
- * Draw the drawable. The foreground color of the context's Graphics is set
- * before calling the drawable's draw method.
+ * Draw the drawable. The foreground color of the context's Graphics is set before calling the drawable's draw
+ * method.
*/
- public void paint(LayoutContext context, int x, int y) {
+ @Override
+ public void paint(final LayoutContext context, final int x, final int y) {
- Graphics g = context.getGraphics();
- Styles styles = context.getStyleSheet().getStyles(this.element);
+ final Graphics g = context.getGraphics();
+ final Styles styles = context.getStyleSheet().getStyles(element);
boolean drawSelected = false;
- if (this.marker == START_MARKER) {
- drawSelected = this.getElement().getStartOffset() >= context
- .getSelectionStart()
- && this.getElement().getStartOffset() + 1 <= context
- .getSelectionEnd();
- } else if (this.marker == END_MARKER) {
- drawSelected = this.getElement().getEndOffset() >= context
- .getSelectionStart()
- && this.getElement().getEndOffset() + 1 <= context
- .getSelectionEnd();
+ if (marker == START_MARKER) {
+ drawSelected = getElement().getStartOffset() >= context.getSelectionStart() && getElement().getStartOffset() + 1 <= context.getSelectionEnd();
+ } else if (marker == END_MARKER) {
+ drawSelected = getElement().getEndOffset() >= context.getSelectionStart() && getElement().getEndOffset() + 1 <= context.getSelectionEnd();
}
- FontResource font = g.createFont(styles.getFont());
- ColorResource color = g.createColor(styles.getColor());
+ final FontResource font = g.createFont(styles.getFont());
+ final ColorResource color = g.createColor(styles.getColor());
- FontResource oldFont = g.setFont(font);
- ColorResource oldColor = g.setColor(color);
+ final FontResource oldFont = g.setFont(font);
+ final ColorResource oldColor = g.setColor(color);
- FontMetrics fm = g.getFontMetrics();
+ final FontMetrics fm = g.getFontMetrics();
if (drawSelected) {
- Rectangle bounds = this.drawable.getBounds();
+ final Rectangle bounds = drawable.getBounds();
g.setColor(g.getSystemColor(ColorResource.SELECTION_BACKGROUND));
- g.fillRect(x + bounds.getX(), y - fm.getAscent(),
- bounds.getWidth(), styles.getLineHeight());
+ g.fillRect(x + bounds.getX(), y - fm.getAscent(), bounds.getWidth(), styles.getLineHeight());
g.setColor(g.getSystemColor(ColorResource.SELECTION_FOREGROUND));
}
- this.drawable.draw(g, x, y);
+ drawable.draw(g, x, y);
g.setFont(oldFont);
g.setColor(oldColor);
@@ -142,6 +135,7 @@ public class DrawableBox extends AbstractInlineBox {
/**
* @see java.lang.Object#toString()
*/
+ @Override
public String toString() {
return "[shape]";
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/HCaret.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/HCaret.java
index 647d7c2b..78c09c9a 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/HCaret.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/HCaret.java
@@ -33,15 +33,16 @@ public class HCaret extends Caret {
* @param length
* Horizontal length of the caret.
*/
- public HCaret(int x, int y, int length) {
+ public HCaret(final int x, final int y, final int length) {
super(x, y);
this.length = length;
}
- public void draw(Graphics g, Color color) {
- ColorResource newColor = g.createColor(color);
- ColorResource oldColor = g.setColor(newColor);
- g.fillRect(this.getX(), this.getY(), this.length, LINE_WIDTH);
+ @Override
+ public void draw(final Graphics g, final Color color) {
+ final ColorResource newColor = g.createColor(color);
+ final ColorResource oldColor = g.setColor(newColor);
+ g.fillRect(getX(), getY(), length, LINE_WIDTH);
g.setColor(oldColor);
newColor.dispose();
}
@@ -49,11 +50,12 @@ public class HCaret extends Caret {
/**
* @see org.eclipse.vex.core.internal.core.Caret#getBounds()
*/
+ @Override
public Rectangle getBounds() {
- return new Rectangle(this.getX(), this.getY(), this.length, LINE_WIDTH);
+ return new Rectangle(getX(), getY(), length, LINE_WIDTH);
}
// ====================================================== PRIVATE
- private int length;
+ private final int length;
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/ImageBox.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/ImageBox.java
index 26fe442e..62167cfb 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/ImageBox.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/ImageBox.java
@@ -12,12 +12,14 @@ public class ImageBox extends AbstractInlineBox {
private final Image image;